PRIORITY_NEUTRAL
PRIORITY_NEUTRAL
Default priority
addAction(string $hook, callback $function_to_add, integer $priority = self::PRIORITY_NEUTRAL, integer $accepted_args = self::ARGUMENT_NEUTRAL)
Add a new action to the collection to be registered with TriTan CMS.
string | $hook | The name of the TriTan CMS action that is being registered. |
callback | $function_to_add | The name of the function/method that is to be called. |
integer | $priority | Optional. The priority at which the function should be fired. Default is 10. |
integer | $accepted_args | Optional. The number of arguments that should be passed to the $callback. Default is 1. |
hasAction(string $hook, callable|boolean $function_to_check = false) : boolean|integer
Check if any action has been registered for a hook.
string | $hook | The name of the action hook. |
callable|boolean | $function_to_check | Optional. The callback to check for. Default false. |
If $function_to_check is omitted, returns boolean for whether the hook has anything registered. When checking a specific function/method, the priority of that hook is returned, or false if the function/method is not attached. When using the $function_to_check argument, this function/method may return a non-boolean value that evaluates to false (e.g.) 0, so use the === operator for testing the return value.
removeAction(string $hook, callback $function_to_remove, integer $priority = self::PRIORITY_NEUTRAL) : boolean
Removes a function/method from a specified action hook.
string | $hook | The action hook to which the function/method to be removed is hooked. |
callback | $function_to_remove | The name of the function/method which should be removed. |
integer | $priority | optional The priority of the function/method (default: 10). |
Whether the function/method is removed.
addFilter(string $hook, callback $function_to_add, integer $priority = self::PRIORITY_NEUTRAL, integer $accepted_args = self::ARGUMENT_NEUTRAL)
Registers a filtering function
string | $hook | The name of the element to be filtered or action to be triggered |
callback | $function_to_add | The name of the function/method that is to be called. |
integer | $priority | Optional. Used to specify the order in which the functions associated with a particular action are executed (default=10, lower=earlier execution, and functions with the same priority are executed in the order in which they were added to the filter) |
integer | $accepted_args | Optional. The number of arguments the function accept (default is the number provided). |
hasFilter(string $hook, callback $function_to_check = false) : integer|boolean
Check if any filter has been registered for a hook.
string | $hook | The name of the filter hook. |
callback | $function_to_check | Optional. If specified, return the priority of that function on this hook or false if not attached. |
Optionally returns the priority on that hook for the specified function.
removeFilter(string $hook, callback $function_to_remove, integer $priority = self::PRIORITY_NEUTRAL) : boolean
Removes a function from a specified filter hook.
This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.
To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added.
string | $hook | The filter hook to which the function to be removed is hooked. |
callback | $function_to_remove | The name of the function which should be removed. |
integer | $priority | optional. The priority of the function (default: 10). |
Whether the function was registered as a filter before it was removed.
applyFilter(string $hook, mixed $value) : mixed
Performs a filtering operation on a PM element or event.
Typical use:
1) Modify a variable if a function is attached to hook 'hook' $var = "default value"; $var = $this->applyFilter( 'hook', $var );
2) Trigger functions is attached to event $this->applyFilter( 'event' ); (see $this->doAction() )
Returns an element which may have been filtered by a filter.
string | $hook | The name of the the element or action |
mixed | $value | The value of the element before filtering |
applyFilterRefArray(string $tag, array $args) : mixed
Execute functions/methods hooked on a specific filter hook, specifying arguments in an array.
string | $tag | The name of the filter hook. |
array | $args | The arguments supplied to the functions/methods hooked to $tag |
The filtered value after all hooked functions/methods are applied to it.
doAction(string $hook, mixed $arg = '')
Execute functions/methods hooked on a specific action hook.
This method invokes all functions/methods attached to action hook $hook
. It is
possible to create new action hooks by simply calling this method,
specifying the name of the new hook using the $hook
parameter.
You can pass extra arguments to the hooks, much like you can with $this->applyFilter().
string | $hook | The name of the action to be executed. |
mixed | $arg | Optional. Additional arguments which are passed on to the functions/methods hooked to the action. Default empty. |
doActionRefArray(string $hook, array $args) : boolean
Execute functions hooked on a specific action hook, specifying arguments in an array.
string | $hook | The name of the action to be executed. |
array | $args | The arguments supplied to the functions hooked to $hook |
Will return false if $tag does not exist in $filter array.
buildUniqueId(string $hook, string|array $function, integer|boolean $priority) : string
Build Unique ID for storage and retrieval.
Simply using a function name is not enough, as several functions can have the same name when they are enclosed in classes.
string | $hook | |
string|array | $function | Used for creating unique id |
integer|boolean | $priority | Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. |
unique ID for usage as array key
callAllHook(array $args)
Will process the functions hooked into it.
The 'all' hook passes all of the arguments or parameters that were used for the hook, which this function was called for.
This function is used internally for $this->applyFilter(), $this->doAction(), and $this->doActionRefArray() and is not meant to be used from outside those methods. This method does not check for the existence of the all hook, so it will fail unless the all hook exists prior to this method call.
array | $args | The collected parameters from the hook that was called. |