Constants

PRIORITY_NEUTRAL

PRIORITY_NEUTRAL

Default priority

ARGUMENT_NEUTRAL

ARGUMENT_NEUTRAL

Default arguments accepted

Properties

$filters

$filters : array

Type

array

$mergedfilters

$mergedfilters : array

Type

array

$current_filter

$current_filter : array

Type

array

$actions

$actions : array

Type

array

$instance

$instance : self

Type

self — The stored singleton instance

Methods

resetInstance()

resetInstance() 

Reset the Container instance.

getInstance()

getInstance() : self

Creates the original or retrieves the stored singleton instance

Returns

self

addAction()

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.

Parameters

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()

hasAction(string  $hook, callable|boolean  $function_to_check = false) : boolean|integer

Check if any action has been registered for a hook.

Parameters

string $hook

The name of the action hook.

callable|boolean $function_to_check

Optional. The callback to check for. Default false.

Returns

boolean|integer —

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()

removeAction(string  $hook, callback  $function_to_remove, integer  $priority = self::PRIORITY_NEUTRAL) : boolean

Removes a function/method from a specified action hook.

Parameters

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).

Returns

boolean —

Whether the function/method is removed.

removeAllActions()

removeAllActions(string  $hook, integer  $priority = false) : boolean

Remove all of the hooks from an action.

Parameters

string $hook

The action to remove hooks from.

integer $priority

The priority number to remove them from.

Returns

boolean —

True when finished.

addFilter()

addFilter(string  $hook, callback  $function_to_add, integer  $priority = self::PRIORITY_NEUTRAL, integer  $accepted_args = self::ARGUMENT_NEUTRAL) 

Registers a filtering function

Parameters

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()

hasFilter(string  $hook, callback  $function_to_check = false) : integer|boolean

Check if any filter has been registered for a hook.

Parameters

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.

Returns

integer|boolean —

Optionally returns the priority on that hook for the specified function.

removeFilter()

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.

Parameters

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).

Returns

boolean —

Whether the function was registered as a filter before it was removed.

removeAllFilters()

removeAllFilters(string  $hook, integer  $priority = false) : boolean

Remove all of the hooks from a filter.

Parameters

string $hook

The filter to remove hooks from.

integer $priority

The priority number to remove.

Returns

boolean —

True when finished.

applyFilter()

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.

Parameters

string $hook

The name of the the element or action

mixed $value

The value of the element before filtering

Returns

mixed

applyFilterRefArray()

applyFilterRefArray(string  $tag, array  $args) : mixed

Execute functions/methods hooked on a specific filter hook, specifying arguments in an array.

Parameters

string $tag

The name of the filter hook.

array $args

The arguments supplied to the functions/methods hooked to $tag

Returns

mixed —

The filtered value after all hooked functions/methods are applied to it.

doAction()

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().

Parameters

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()

doActionRefArray(string  $hook, array  $args) : boolean

Execute functions hooked on a specific action hook, specifying arguments in an array.

Parameters

string $hook

The name of the action to be executed.

array $args

The arguments supplied to the functions hooked to $hook

Returns

boolean —

Will return false if $tag does not exist in $filter array.

didAction()

didAction(string  $tag) : integer

Retrieve the number of times an action has fired.

Parameters

string $tag

The name of the action hook.

Returns

integer —

The number of times action hook $tag is fired.

current()

current() : string

Retrieve the name of the current filter or action.

Returns

string —

Hook name of the current filter or action.

buildUniqueId()

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.

Parameters

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.

Returns

string —

unique ID for usage as array key

callAllHook()

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.

Parameters

array $args

The collected parameters from the hook that was called.