PHP Class Elgg\HooksRegistrationService

Use the elgg_* versions instead.
Since: 1.9.0
Show file Open project: elgg/elgg Class Usage Examples

Protected Properties

Property Type Description
$logger Logger

Public Methods

Method Description
backup ( ) : void Temporarily remove all event/hook registrations (before tests)
clearHandlers ( string $name, string $type ) : void Clears all handlers for a specific hook
getAllHandlers ( ) : array Returns all registered handlers as array( $name => array( $type => array( $priority => array( callback, callback, ) ) )
getOrderedHandlers ( string $name, string $type ) : callable[] Returns an ordered array of handlers registered for $name and $type.
hasHandler ( string $name, string $type ) : boolean Is a handler registered for this specific name and type? "all" handlers are not considered.
registerHandler ( $name, $type, $callback, $priority = 500 ) Registers a handler.
restore ( ) : void Restore backed up event/hook registrations (after tests)
setLogger ( Logger $logger = null ) : self Set a logger instance, e.g. for reporting uncallable handlers
unregisterHandler ( string $name, string $type, callable $callback ) : boolean Unregister a handler

Protected Methods

Method Description
getMatcher ( callable $spec ) : elgg\MethodMatcher | null Create a matcher for the given callable (if it's for a static or dynamic method)

Method Details

backup() public method

Call backup() before your tests and restore() after.
See also: restore
public backup ( ) : void
return void

clearHandlers() public method

Clears all handlers for a specific hook
public clearHandlers ( string $name, string $type ) : void
$name string
$type string
return void

getAllHandlers() public method

Returns all registered handlers as array( $name => array( $type => array( $priority => array( callback, callback, ) ) )
public getAllHandlers ( ) : array
return array

getMatcher() protected method

Create a matcher for the given callable (if it's for a static or dynamic method)
protected getMatcher ( callable $spec ) : elgg\MethodMatcher | null
$spec callable Callable we're creating a matcher for
return elgg\MethodMatcher | null

getOrderedHandlers() public method

Returns an ordered array of handlers registered for $name and $type.
See also: Elgg\HooksRegistrationService::getAllHandlers()
public getOrderedHandlers ( string $name, string $type ) : callable[]
$name string The name of the hook
$type string The type of the hook
return callable[]

hasHandler() public method

If you need to consider "all" handlers, you must check them independently, or use (bool)elgg_get_ordered_hook_handlers().
public hasHandler ( string $name, string $type ) : boolean
$name string The name of the hook
$type string The type of the hook
return boolean

registerHandler() public method

Registers a handler.
public registerHandler ( $name, $type, $callback, $priority = 500 )

restore() public method

Restore backed up event/hook registrations (after tests)
See also: backup
public restore ( ) : void
return void

setLogger() public method

Set a logger instance, e.g. for reporting uncallable handlers
public setLogger ( Logger $logger = null ) : self
$logger Logger The logger
return self

unregisterHandler() public method

Unregister a handler
public unregisterHandler ( string $name, string $type, callable $callback ) : boolean
$name string
$type string
$callback callable
return boolean

Property Details

$logger protected property

protected Logger,Elgg $logger
return Logger