Class Registry
Central database for shared objects.
A registry entry is either an object or a factory description used to create
an object on first request automatically (lazy initialisation).
Factory descriptions are arrays of 2 or three values: the first value is
the factory base class name that implements the autocreate()
method,
the second is the URI string with the driver configuration. An optional
third value is an array of registry keys that the new object depends on;
if dependencies are set, the object for each key is initialised first and
afterwards automatically chained to the new object.
Registry entries shared throughout an application are commonly defined at an early stage (i.e. application stub, configuration parser). A static example:
Registry::instance() ->registerPrimaryController('self:?dispatcher=self:;query=standard:') ->register( array ( 'tr' => array ( '\\Core\\Translation', 'language:?driver=xml://%locale/%domain%3Fpath=language;default-locale=en_GB', ), Registry::DefaultView => array ( '\\Core\\View', 'Application.standard:', array ( 'tr', ), ), ) );
In the given example, two shared registry entries are registered: tr
is
automatically created on first request and provides a XML-based language
repository. The well-known registry key for the default view is as well
automatically created on first request and points to the standard view
driver of the application. Additionally, it depends on the translation
engine which is as well instantiated (if not used before) and automatically
chained to the default view.
Additionally, the URI for the primary controller is as well set.
- Core\Object implements Core\Chainable
- Core\Set implements Core\Accessor
- Core\Registry
Package: Core
Since: 3.0
Requires: PHP 5.3
Version: 1.1.1
Located at Registry.inc.php
Methods summary
public
|
|
public
mixed
|
#
getValueForUndefinedKey( string $key )
Retrieves the value for an undefined key. The default implementation
throws |
public static
|
|
public
boolean
|
#
issetValueForKey( string $key )
Tests, whether a property or method for a given key exists. The default
implementation cannot test, if |
public
|
|
public
|
#
registerEntry( string $key, mixed $objectOrEntryDescription )
Registers a single new registry entry. Convenience method for
|
public
|
#
registerPrimaryController( string $primaryControllerURI )
Registers the primary controller factory. Convenience method for
|
public
|
|
public
string
|
#
temporaryFile( string $prefix = null )
Returns a new temporary file name on each call. The file is located at
the directory determined by |
public
string|false
|
#
temporaryTarget( )
Returns first successfully expanded temporary target. If all configured
temporary targets fail, an exception is thrown. Subsequent calls to
this function will either directly return the cached temporary target or
|
public
|
|
public
|
#
updateEntry( string $key, mixed $objectOrEntryDescription )
Sets or updates a single registry entry. |
Methods inherited from Core\Object
__autocreateFactory()
,
__call()
,
__processParameters()
,
__toString()
,
attachMethod()
,
chain()
,
getValueForKey()
,
getValueForKeyPath()
,
hash()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Constants summary
string |
Configuration
KVC key name of system configuration. |
#
'configuration'
|
string |
DefaultPluginManager
KVC key name of default plugin manger utilised by Core classes if present. |
#
'defaultPluginManager'
|
string |
DefaultView
KVC key name of default view used by the Core MVC implementation. |
#
'defaultView'
|
string |
PrimaryController
KVC key name of the primary controller used by the Core MVC implementation. |
#
'primaryController'
|
Constants inherited from Core\Object
AnyParameterType
,
AutochainParameterType
,
AutocreateParameterType
,
BooleanParameterType
,
CharParameterType
,
EnumParameterType
,
IntegerParameterType
,
RealParameterType
,
StringParameterType
,
UserParameterType
Properties summary
protected
array
|
$_v_entries
Array of raw registry entries. A raw registry entry is either an object or an array storing registration data used to instantiate an object on request (registry entries are instantiated on first request only). |
|
protected static
|
$_instance
Singleton instance. |
|
protected
string
|
$_temporaryTarget
Cached temporary target. |
Magic properties
public read-only
array
|
$entries
Array of raw registry entries. |
public read-only
string
|
$temporaryFile
File name of a new temporary file. |
public read-only
string
|
$temporaryTarget
Temporary target string or |