PHP Class Kahlan\Filter\Filter

Afficher le fichier Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Свойство Type Description
$_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.

Méthodes publiques

Méthode Description
_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.

Méthodes protégées

Méthode Description
_methodFilters ( string | object $context ) : object Gets the MethodFilters instance of a context.

Method Details

_classFilters() public static méthode

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.
Résultat array The whole filters data or filters associated to a class/instance's method.

_methodFilters() protected static méthode

Gets the MethodFilters instance of a context.
protected static _methodFilters ( string | object $context ) : object
$context string | object The class/instance context.
Résultat object

apply() public static méthode

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.
Résultat string The name reference of the applied filter.

detach() public static méthode

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() public static méthode

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

filters() public static méthode

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.
Résultat array The whole filters data or filters associated to a class/instance's method.

on() public static méthode

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.
Résultat mixed Returns The result of the chain.

register() public static méthode

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.
Résultat string | null The registered aspect name identifier or `null` for multiple registration.

registered() public static méthode

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.
Résultat boolean

reset() public static méthode

Removes filters for all classes.
public static reset ( )

unregister() public static méthode

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

Property Details

$_aspects protected_oe static_oe property

An array of Closure indexed by a name identifier.
protected static array $_aspects
Résultat array

$_cachedFilters protected_oe static_oe property

A cached array of filters indexed by class name & method name.
protected static array $_cachedFilters
Résultat array

$_enabled protected_oe static_oe property

Indicates if the filter system is enabled or not.
protected static bool $_enabled
Résultat boolean

$_methodFilters protected_oe static_oe property

An array of MethodFilters indexed by class name.
protected static array $_methodFilters
Résultat array