PHP Класс Kahlan\Filter\Filter

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_aspects array An array of Closure indexed by a name identifier.
$_cachedFilters array A cached array of filters indexed by class name & method name.
$_enabled boolean Indicates if the filter system is enabled or not.
$_methodFilters array An array of MethodFilters indexed by class name.

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

Метод Описание
_classFilters ( mixed $context, string $method ) : array Gets the whole filters associated to a class/instance's method.
apply ( mixed $context, string | array $methods, string $name ) : string Applies a filter to a method.
detach ( mixed $context, string $method, $name = null ) Detaches a filter completely, by class/instance or on a method basis.
enable ( boolean $active = true ) Enables/disables the filter system.
filters ( mixed $context = null, string | null $method = null ) : array Gets the whole filters data or filters associated to a class/instance's method.
on ( mixed $context, string $method, array $params, Closure $callback, array $filters = [] ) : mixed Cuts the normal execution of a method to run all applied filter for the method.
register ( string | array | Closur\Closure $name, $aspect = null ) : string | null Registers an aspect in the system.
registered ( string | null $name = null ) : boolean Checks if as aspect exists or returns all registered aspects if $name is null.
reset ( ) Removes filters for all classes.
unregister ( string $name ) Unregisters an aspect in the system.

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

Метод Описание
_methodFilters ( string | object $context ) : object Gets the MethodFilters instance of a context.

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

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

Gets the whole filters associated to a class/instance's method.
public static _classFilters ( mixed $context, string $method ) : array
$context mixed The class/instance context.
$method string The name of the method to get the filters from.
Результат array The whole filters data or filters associated to a class/instance's method.

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

Gets the MethodFilters instance of a context.
protected static _methodFilters ( string | object $context ) : object
$context string | object The class/instance context.
Результат object

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

Applies a filter to a method.
public static apply ( mixed $context, string | array $methods, string $name ) : string
$context mixed The instance or class name context to apply a new filter.
$methods string | array The name or array of method names to be filtered.
$name string The filter name to apply.
Результат string The name reference of the applied filter.

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

Detaches a filter completely, by class/instance or on a method basis.
public static detach ( mixed $context, string $method, $name = null )
$context mixed The instance or class name context to apply a new filter.
$method string The name of the method to apply the filter.

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

Enables/disables the filter system.
public static enable ( boolean $active = true )
$active boolean

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

Or sets the whole filters data.
public static filters ( mixed $context = null, string | null $method = null ) : array
$context mixed If `null` returns the whole filters data. If `$context` is an array use `$context` as the whole filters data. Otherwise `$context` stands for the class/instance context.
$method string | null The name of the method to get the filters from or `null` to get all of them.
Результат array The whole filters data or filters associated to a class/instance's method.

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

Cuts the normal execution of a method to run all applied filter for the method.
public static on ( mixed $context, string $method, array $params, Closure $callback, array $filters = [] ) : mixed
$context mixed The instance or class name context to perform the filtering on.
$method string The name of the method which is going the be filtered.
$params array The parameters passed to the original method.
$callback Closure The original method logic closure.
$filters array Additional filters to apply to the method for this call only.
Результат mixed Returns The result of the chain.

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

Registers an aspect in the system.
public static register ( string | array | Closur\Closure $name, $aspect = null ) : string | null
$name string | array | Closur\Closure The aspect name identifier, the aspects array or the aspect closure.
Результат string | null The registered aspect name identifier or `null` for multiple registration.

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

Checks if as aspect exists or returns all registered aspects if $name is null.
public static registered ( string | null $name = null ) : boolean
$name string | null The aspect name identifier or `null` to get all registered aspects.
Результат boolean

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

Removes filters for all classes.
public static reset ( )

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

Unregisters an aspect in the system.
public static unregister ( string $name )
$name string The aspect name identifier to unregister.

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

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

An array of Closure indexed by a name identifier.
protected static array $_aspects
Результат array

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

A cached array of filters indexed by class name & method name.
protected static array $_cachedFilters
Результат array

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

Indicates if the filter system is enabled or not.
protected static bool $_enabled
Результат boolean

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

An array of MethodFilters indexed by class name.
protected static array $_methodFilters
Результат array