PHP Класс lithium\core\Object

Options defined: - 'init' boolean Controls constructor behaviour for calling the _init method. If false the method is not called, otherwise it is. Defaults to true.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_autoConfig array Holds an array of values that should be processed on initialization. Each value should have a matching protected property (prefixed with _) defined in the class. If the property is an array, the property name should be the key and the value should be 'merge'. See the _init() method for more details.
$_config array **Do not override.** Pass any additional variables to parent::__construct().
$_methodFilters array Contains a 2-dimensional array of filters applied to this object's methods, indexed by method name. See the associated methods for more details.
$_parents array Parents of the current class.

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

Метод Описание
__construct ( array $config = [] ) : void Constructor. Initializes class configuration ($_config), and assigns object properties using the _init() method, unless otherwise specified by configuration. See below for details.
__set_state ( array $data ) : object PHP magic method used in conjunction with var_export() to allow objects to be re-instantiated with their pre-existing properties and values intact. This method can be called statically on any class that extends Object to return an instance of it.
applyFilter ( mixed $method, Closure $filter = null ) : void Apply a closure to a method of the current object instance.
invokeMethod ( string $method, array $params = [] ) : mixed Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array, and improves performance by using straight method calls in most cases.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.

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

Метод Описание
_filter ( string $method, array $params, Closure $callback, array $filters = [] ) : mixed Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it. This, along with the Filters class, is the core of Lithium's filters system. This system allows you to "reach into" an object's methods which are marked as _filterable_, and intercept calls to those methods, optionally modifying parameters or return values.
_init ( ) : void Initializer function called by the constructor unless the constructor 'init' flag is set to false. May be used for testing purposes, where objects need to be manipulated in an un-initialized state, or for high-overhead operations that require more control than the constructor provides. Additionally, this method iterates over the $_autoConfig property to automatically assign configuration settings to their corresponding properties.
_instance ( string | object $name, array $options = [] ) : object Returns an instance of a class with given config. The name could be a key from the classes array, a fully-namespaced class name, or an object. Typically this method is used in _init to create the dependencies used in the current class.
_parents ( ) : array Gets and caches an array of the parent methods of a class.
_stop ( integer | string $status ) : void Exit immediately. Primarily used for overrides during testing.

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

__construct() публичный Метод

Constructor. Initializes class configuration ($_config), and assigns object properties using the _init() method, unless otherwise specified by configuration. See below for details.
См. также: lithium\core\Object::$_config
См. также: lithium\core\Object::_init()
public __construct ( array $config = [] ) : void
$config array The configuration options which will be assigned to the `$_config` property. This method accepts one configuration option: - `'init'` _boolean_: Controls constructor behavior for calling the `_init()` method. If `false`, the method is not called, otherwise it is. Defaults to `true`.
Результат void

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

PHP magic method used in conjunction with var_export() to allow objects to be re-instantiated with their pre-existing properties and values intact. This method can be called statically on any class that extends Object to return an instance of it.
public static __set_state ( array $data ) : object
$data array An array of properties and values with which to re-instantiate the object. These properties can be both public and protected.
Результат object Returns an instance of the requested object with the given properties set.

_filter() защищенный Метод

Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it. This, along with the Filters class, is the core of Lithium's filters system. This system allows you to "reach into" an object's methods which are marked as _filterable_, and intercept calls to those methods, optionally modifying parameters or return values.
См. также: lithium\core\Object::applyFilter()
См. также: lithium\util\collection\Filters
protected _filter ( string $method, array $params, Closure $callback, array $filters = [] ) : mixed
$method string The name of the method being executed, usually the value of `__METHOD__`.
$params array An associative array containing all the parameters passed into the method.
$callback Closure The method's implementation, wrapped in a closure.
$filters array Additional filters to apply to the method for this call only.
Результат mixed Returns the return value of `$callback`, modified by any filters passed in `$filters` or applied with `applyFilter()`.

_init() защищенный Метод

For example, given the following: class Bar extends \lithium\core\Object { protected $_autoConfig = array('foo'); protected $_foo; } $instance = new Bar(array('foo' => 'value')); The $_foo property of $instance would automatically be set to 'value'. If $_foo was an array, $_autoConfig could be set to array('foo' => 'merge'), and the constructor value of 'foo' would be merged with the default value of $_foo and assigned to it.
См. также: lithium\core\Object::$_autoConfig
protected _init ( ) : void
Результат void

_instance() защищенный Метод

Returns an instance of a class with given config. The name could be a key from the classes array, a fully-namespaced class name, or an object. Typically this method is used in _init to create the dependencies used in the current class.
protected _instance ( string | object $name, array $options = [] ) : object
$name string | object A `classes` key or fully-namespaced class name.
$options array The configuration passed to the constructor.
Результат object

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

Gets and caches an array of the parent methods of a class.
protected static _parents ( ) : array
Результат array Returns an array of parent classes for the current class.

_stop() защищенный Метод

Exit immediately. Primarily used for overrides during testing.
protected _stop ( integer | string $status ) : void
$status integer | string integer range 0 to 254, string printed on exit
Результат void

applyFilter() публичный Метод

Apply a closure to a method of the current object instance.
См. также: lithium\core\Object::_filter()
См. также: lithium\util\collection\Filters
public applyFilter ( mixed $method, Closure $filter = null ) : void
$method mixed The name of the method to apply the closure to. Can either be a single method name as a string, or an array of method names. Can also be false to remove all filters on the current object.
$filter Closure The closure that is used to filter the method(s), can also be false to remove all the current filters for the given method.
Результат void

invokeMethod() публичный Метод

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array, and improves performance by using straight method calls in most cases.
public invokeMethod ( string $method, array $params = [] ) : mixed
$method string Name of the method to call
$params array Parameter list to use when calling $method
Результат mixed Returns the result of the method call

respondsTo() публичный Метод

Determines if a given method can be called.
public respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
Результат boolean Returns `true` if the method can be called, `false` otherwise.

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

$_autoConfig защищенное свойство

Holds an array of values that should be processed on initialization. Each value should have a matching protected property (prefixed with _) defined in the class. If the property is an array, the property name should be the key and the value should be 'merge'. See the _init() method for more details.
См. также: lithium\core\Object::_init()
protected array $_autoConfig
Результат array

$_config защищенное свойство

**Do not override.** Pass any additional variables to parent::__construct().
protected array $_config
Результат array

$_methodFilters защищенное свойство

Contains a 2-dimensional array of filters applied to this object's methods, indexed by method name. See the associated methods for more details.
См. также: lithium\core\Object::_filter()
См. также: lithium\core\Object::applyFilter()
protected array $_methodFilters
Результат array

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

Parents of the current class.
См. также: lithium\core\Object::_parents()
protected static array $_parents
Результат array