PHP Класс lithium\core\Adaptable

Adaptable provides the logic necessary for generic configuration of named adapter configurations (such as the ones used in Cache) as well as a unified method of locating and obtaining an instance to a specified adapter. All immediate subclasses to Adaptable must define the protected attributes $_configurations and $_adapters. The former is where all local adapter named configurations will be stored (as an array of named configuration settings), and the latter must contain the Libraries::locate()-compatible path string (or array of strings) specifying how adapter classes should be located. This static class should **never** be called explicitly.
Наследование: extends StaticObject
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_adapters Must always be re-defined in sub-classes. Holds the Libraries::locate() compatible path string where the adapter in question may be found i.e. 'adapter.storage.cache'.
$_configurations Example: array( 'production' => array(), 'development' => array(), 'test' => array() )
$_strategies Holds the Libraries::locate() compatible path string where the strategy in question may be found i.e. 'strategy.storage.cache'.

Открытые методы

Метод Описание
adapter ( string | null $name = null ) : object Returns adapter class name for given $name configuration, using the $_adapter path defined in Adaptable subclasses.
applyStrategies ( string $method, string $name, mixed $data, array $options = [] ) : mixed Applies strategies configured in $name for $method on $data.
config ( array | string $config = null ) : array | void Sets configurations for a particular adaptable implementation, or returns the current configuration settings.
enabled ( string $name ) : boolean Determines if the adapter specified in the named configuration is enabled.
reset ( ) : void Clears all configurations.
strategies ( string $name ) : object Obtain an SplDoublyLinkedList of the strategies for the given $name configuration, using the $_strategies path defined in Adaptable subclasses.

Защищенные методы

Метод Описание
_class ( array $config, array $paths = [] ) : string Looks up an adapter by class by name.
_config ( string $name ) : array | null Gets an array of settings for the given named configuration in the current environment.
_initAdapter ( string $class, array $config ) : object Provides an extension point for modifying how adapters are instantiated.
_initConfig ( string $name, array $config ) : array A stub method called by _config() which allows Adaptable subclasses to automatically assign or auto-generate additional configuration data, once a configuration is first accessed. This allows configuration data to be lazy-loaded from adapters or other data sources.
_locate ( string | array $paths, string $name ) : string Perform library location for an array of paths or a single string-based path.
_strategy ( string $name, array $paths = [] ) : string Looks up a strategy by class by name.

Описание методов

_class() защищенный статический Метод

Looks up an adapter by class by name.
См. также: lithium\core\libraries::locate()
protected static _class ( array $config, array $paths = [] ) : string
$config array Configuration array of class to be found.
$paths array Optional array of search paths that will be checked.
Результат string Returns a fully-namespaced class reference to the adapter class.

_config() защищенный статический Метод

The default types of settings for all adapters will contain keys for: adapter - The class name of the adapter filters - An array of filters to be applied to the adapter methods
См. также: lithium\core\Environment
protected static _config ( string $name ) : array | null
$name string Named configuration.
Результат array | null Settings for the named configuration.

_initAdapter() защищенный статический Метод

Provides an extension point for modifying how adapters are instantiated.
См. также: lithium\core\Object::__construct()
protected static _initAdapter ( string $class, array $config ) : object
$class string The fully-namespaced class name of the adapter to instantiate.
$config array The configuration array to be passed to the adapter instance. See the `$config` parameter of `Object::__construct()`.
Результат object The adapter's class.

_initConfig() защищенный статический Метод

A stub method called by _config() which allows Adaptable subclasses to automatically assign or auto-generate additional configuration data, once a configuration is first accessed. This allows configuration data to be lazy-loaded from adapters or other data sources.
protected static _initConfig ( string $name, array $config ) : array
$name string The name of the configuration which is being accessed. This is the key name containing the specific set of configuration passed into `config()`.
$config array Contains the configuration assigned to `$name`. If this configuration is segregated by environment, then this will contain the configuration for the current environment.
Результат array Returns the final array of settings for the given named configuration.

_locate() защищенный статический Метод

Perform library location for an array of paths or a single string-based path.
protected static _locate ( string | array $paths, string $name ) : string
$paths string | array Paths that Libraries::locate() will utilize.
$name string The name of the class to be located.
Результат string Fully-namespaced path to the class, or null if not found.

_strategy() защищенный статический Метод

Looks up a strategy by class by name.
См. также: lithium\core\libraries::locate()
protected static _strategy ( string $name, array $paths = [] ) : string
$name string The strategy to locate.
$paths array Optional array of search paths that will be checked.
Результат string Returns a fully-namespaced class reference to the adapter class.

adapter() публичный статический Метод

Returns adapter class name for given $name configuration, using the $_adapter path defined in Adaptable subclasses.
public static adapter ( string | null $name = null ) : object
$name string | null Class name of adapter to load.
Результат object Adapter object.

applyStrategies() публичный статический Метод

Applies strategies configured in $name for $method on $data.
public static applyStrategies ( string $method, string $name, mixed $data, array $options = [] ) : mixed
$method string The strategy method to be applied.
$name string The named configuration
$data mixed The data to which the strategies will be applied.
$options array If `mode` is set to 'LIFO', the strategies are applied in reverse. order of their definition.
Результат mixed Result of application of strategies to data. If no strategies have been configured, this method will simply return the original data.

config() публичный статический Метод

Sets configurations for a particular adaptable implementation, or returns the current configuration settings.
public static config ( array | string $config = null ) : array | void
$config array | string An array of configurations, indexed by name to set configurations in one go or a name for which to return the configuration.
Результат array | void Configuration or void if setting configurations.

enabled() публичный статический Метод

Enabled can mean various things, e.g. having a PECL memcached extension compiled & loaded, as well as having the memcache server up & available.
public static enabled ( string $name ) : boolean
$name string The named configuration whose adapter will be checked.
Результат boolean True if adapter is enabled, false if not. This method will return null if no configuration under the given $name exists.

reset() публичный статический Метод

Clears all configurations.
public static reset ( ) : void
Результат void

strategies() публичный статический Метод

Obtain an SplDoublyLinkedList of the strategies for the given $name configuration, using the $_strategies path defined in Adaptable subclasses.
public static strategies ( string $name ) : object
$name string Class name of adapter to load.
Результат object `SplDoublyLinkedList` of strategies, or `null` if none are defined.

Описание свойств

$_adapters защищенное статическое свойство

Must always be re-defined in sub-classes. Holds the Libraries::locate() compatible path string where the adapter in question may be found i.e. 'adapter.storage.cache'.
protected static $_adapters

$_configurations защищенное статическое свойство

Example: array( 'production' => array(), 'development' => array(), 'test' => array() )
protected static $_configurations

$_strategies защищенное статическое свойство

Holds the Libraries::locate() compatible path string where the strategy in question may be found i.e. 'strategy.storage.cache'.
protected static $_strategies