Provides a method to implement delayed initialization of objects.
With the methods in this class you can implement callbacks to configure singleton classes. In order to do so you will have to change the getInstance() method of your singleton class to include a call to ezcBaseInit::fetchConfig() as in the following example:
You will also need to configure which callback class to call. This you do with the ezcBaseInit::setCallback() method. The following examples sets the callback classname for the configuration identifier 'ezcInitConfigurationManager' to 'cfgConfigurationManager':
The class 'cfgConfigurationManager' is required to implement the ezcBaseConfigurationInitializer interface, which defines only one method: configureObject(). An example on how to implement such a class could be:
Of course the implementation of this callback class is up to the application developer that uses the component (in this example the Configuration component's class ezcConfigurationManager).
Source for this file: /Base/src/init.php
Version: | //autogentag// |
public static mixed |
fetchConfig(
$identifier
, $object
)
Uses the configured callback belonging to $identifier to configure the $object. |
public static void |
setCallback(
$identifier
, $callbackClassname
)
Adds the classname $callbackClassname as callback for the identifier $identifier. |
Uses the configured callback belonging to $identifier to configure the $object.
The method will return the return value of the callback method, or null in case there was no callback set for the specified $identifier.
Name | Type | Description |
---|---|---|
$identifier |
string | |
$object |
object |
Adds the classname $callbackClassname as callback for the identifier $identifier.
Name | Type | Description |
---|---|---|
$identifier |
string | |
$callbackClassname |
string |