xplo.re Medusa Core Framework 3.1
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • Autoloader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Iterator
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • String
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • UseVersion
  • Version

Functions

  • ns_expand
  • ns_file_exists
  • ns_get_version
  • ns_resolve

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
Extended by Core\Set implements Core\Accessor
Extended by Core\Registry
Namespace: Core
Package: Core
Since: 3.0
Requires: PHP 5.3
Version: 1.1
Located at Registry.inc.php

Methods summary

public
# __unset( string $key )

Purges an entry from the registry.

Purges an entry from the registry.

Parameters

$key
Name of registry entry to remove. Non-existing keys are ignored.

Since

3.0
public mixed
# getValueForUndefinedKey( string $key )

Retrieves the value for an undefined key. The default implementation throws Core\Exception\UndefinedKey; subclasses should implement an own version of this method to provide dynamic value access. This method is always called, when Core\Object::getValueForKey() fails. Retrieves a registry entry. If an entry is requested for the first time and is a factory description, it will automatically be instantiated.

Retrieves the value for an undefined key. The default implementation throws Core\Exception\UndefinedKey; subclasses should implement an own version of this method to provide dynamic value access. This method is always called, when Core\Object::getValueForKey() fails. Retrieves a registry entry. If an entry is requested for the first time and is a factory description, it will automatically be instantiated.

Parameters

$key
Key of registry entry to retrieve.

Returns

mixed
Registry entry for given key.

Throws

Core\Exception\UndefinedKey
Failed to resolve value for the given key.

Since

3.0

Overrides

Core\Object::getValueForUndefinedKey
public static Core\Registry
# instance( )

Retrieves the singleton instance.

Retrieves the singleton instance.

Returns

Core\Registry
Singleton instance.

Since

3.0
public boolean
# issetValueForKey( string $key )

Tests, whether a property or method for a given key exists. The default implementation cannot test, if Core\Registry::getValueForUndefinedKey() can handle a key; thus subclasses implementing Core\Registry::getValueForUndefinedKey() should also provide an own implementation for Core\Registry::issetValueForKey().

Tests, whether a property or method for a given key exists. The default implementation cannot test, if Core\Registry::getValueForUndefinedKey() can handle a key; thus subclasses implementing Core\Registry::getValueForUndefinedKey() should also provide an own implementation for Core\Registry::issetValueForKey().

Parameters

$key
Key to check for existence.

Returns

boolean
true, if a property or method for the given key exists, otherwise false.

Since

3.0

Overrides

Core\Object::issetValueForKey
public
# register( array $sets )

Adds an array of entries to the registry.

Adds an array of entries to the registry.

Parameters

$sets

Associative array of registry entries to set. Array keys correspond to registry entry keys. Values are either objects to set for the given registry key or an array describing the object factory and dependency on other registry keys.

New registry entries must not yet exist, otherwise an exception is thrown. To replace a registry entries or add registry entries with overwriting existing entries, use the Core\Registry::update() method.

Returns


$this

Throws

Core\Exception\InvalidArgument
Registry entry of a given key already exists.

Remark

If an array has to be set as the value for a key, the array has to be wrapped in an object. If not special behaviour is required, the simplest way is to wrap the array in an ArrayObject instance.


See

Core\Registry::registerEntry()
Core\Registry::update()
Core\Registry::updateEntry()

Since

3.0
public
# registerEntry( string $key, mixed $objectOrEntryDescription )

Registers a single new registry entry. Convenience method for Core\Registry::register().

Registers a single new registry entry. Convenience method for Core\Registry::register().

Parameters

$key
Key of registry entry to register.
$objectOrEntryDescription

Object to set for registry entry or array describing the object factory and dependency on other registry keys.

Returns


$this

Remark

If an array has to be set as the value for a key, the array has to be wrapped in an object. If not special behaviour is required, the simplest way is to wrap the array in an ArrayObject instance.


See

Core\Registry::register()
Core\Registry::update()
Core\Registry::updateEntry()

Since

3.0
public
# registerPrimaryController( string $primaryControllerURI )

Registers the primary controller factory. Convenience method for Core\Registry::register() with key name set to the constant of the primary controller name and the factory base class set to the primary controller class.

Registers the primary controller factory. Convenience method for Core\Registry::register() with key name set to the constant of the primary controller name and the factory base class set to the primary controller class.

Parameters

$primaryControllerURI
Primary controller URI string.

Returns


$this

Since

3.0
public Core\View[]
# views( )

Retrieves all registered and instantiated views.

Retrieves all registered and instantiated views.

Returns

Core\View[]

Since

3.0
public string
# temporaryFile( string $prefix = null )

Returns a new temporary file name on each call. The file is located at the directory determined by Core\Registry::temporaryTarget() and created during the request; thus a call to unlink() is mandatory. Initial file permissions are 0600.

Returns a new temporary file name on each call. The file is located at the directory determined by Core\Registry::temporaryTarget() and created during the request; thus a call to unlink() is mandatory. Initial file permissions are 0600.

Parameters

$prefix

Optional prefix string used for the temporary file. Note, that some systems restrict the prefix string to three characters (e.g. Windows). If no prefix string is provided, the default prefix »xcf« is used.

Returns

string
File name of a new temporary file.

Throws

Core\Exception\Configuration
A temporary target scheme is invalid or all temporary targets failed.

Remark

If the determined temporary target is not writable, the default system directory is used instead. This behaviour might also differ between systems hence the underlying system call might introduce different priorities on temporary directories.


See

Core\Registry::temporaryTarget()

Since

3.0
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 false, if the initial resolution failed.

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 false, if the initial resolution failed.

Returns

string|false
Temporary target string or false, if the initial resolution failed.

Throws

Core\Exception\Configuration
A temporary target scheme is invalid or all temporary targets failed.

See

Core\Configuration\TemporaryFilesTarget

Since

3.0
public
# update( array $sets )

Sets registry entries with overwriting existing entries.

Sets registry entries with overwriting existing entries.

Parameters

$sets
Associative array of registry keys to set or overwrite.

Returns


$this

See

Core\Registry::register()
Core\Registry::registerEntry()
Core\Registry::updateEntry()

Since

3.1
public
# updateEntry( string $key, mixed $objectOrEntryDescription )

Sets or updates a single registry entry.

Sets or updates a single registry entry.

Parameters

$key
Key of registry entry to set.
$objectOrEntryDescription
See Core\Registry::registerEntry().

Returns


$this

See

Core\Registry::register()
Core\Registry::registerEntry()
Core\Registry::update()

Since

3.1

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), hash(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

string DefaultPluginManager

KVC key name of default plugin manger utilised by Core classes if present.

KVC key name of default plugin manger utilised by Core classes if present.

Since

3.1
# 'defaultPluginManager'
string DefaultView

KVC key name of default view used by the Core MVC implementation.

KVC key name of default view used by the Core MVC implementation.

Since

3.0
# 'defaultView'
string PrimaryController

KVC key name of the primary controller used by the Core MVC implementation.

KVC key name of the primary controller used by the Core MVC implementation.

Since

3.0
# '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).

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).

Since

3.0
#
protected static Core\Registry $_instance

Singleton instance.

Singleton instance.

Since

3.0
#
protected string $_temporaryTarget

Cached temporary target.

Cached temporary target.

Since

3.0
#

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 false, if the initial resolution failed.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.1 API documentation generated by ApiGen