Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\HooksRegistrationService Class Reference
Inheritance diagram for Elgg\HooksRegistrationService:
Elgg\EventsService Elgg\PluginHooksService

Public Member Functions

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

Public Attributes

const REG_KEY_PRIORITY = 0
 
const REG_KEY_INDEX = 1
 
const REG_KEY_HANDLER = 2
 

Protected Member Functions

 getMatcher ($spec)
 Create a matcher for the given callable (if it's for a static or dynamic method) More...
 

Protected Attributes

 $logger
 

Detailed Description

Definition at line 15 of file HooksRegistrationService.php.

Member Function Documentation

Elgg\HooksRegistrationService::backup ( )

Temporarily remove all event/hook registrations (before tests)

Call backup() before your tests and restore() after.

Note
This behaves like a stack. You must call restore() for each backup() call.
Returns
void
See Also
restore private

Definition at line 267 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::clearHandlers (   $name,
  $type 
)

Clears all handlers for a specific hook.

Parameters
string$name
string$type
Returns
void private

Definition at line 128 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::getAllHandlers ( )

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

private

Returns
array

Definition at line 146 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::getMatcher (   $spec)
protected

Create a matcher for the given callable (if it's for a static or dynamic method)

Parameters
callable$specCallable we're creating a matcher for
Returns
MethodMatcher|null

Definition at line 234 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::getOrderedHandlers (   $name,
  $type 
)

Returns an ordered array of handlers registered for $name and $type.

Parameters
string$nameThe name of the hook
string$typeThe type of the hook
Returns
array
See Also
::getAllHandlers()

private

Definition at line 185 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::hasHandler (   $name,
  $type 
)

Is a handler registered for this specific name and type? "all" handlers are not considered.

If you need to consider "all" handlers, you must check them independently, or use (bool)elgg_get_ordered_hook_handlers().

Parameters
string$nameThe name of the hook
string$typeThe type of the hook
Returns
boolean

Definition at line 171 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::registerHandler (   $name,
  $type,
  $callback,
  $priority = 500 
)

Registers a handler.

Warning
This doesn't check if a callback is valid to be called, only if it is in the correct format as a callable.

private

Definition at line 60 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::restore ( )

Restore backed up event/hook registrations (after tests)

Returns
void
See Also
backup private

Definition at line 280 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::setLogger ( \Elgg\Logger  $logger = null)

Set a logger instance, e.g.

for reporting uncallable handlers

Parameters
\Elgg\Logger$loggerThe logger
Returns
self

Definition at line 47 of file HooksRegistrationService.php.

Elgg\HooksRegistrationService::unregisterHandler (   $name,
  $type,
  $callback 
)

Unregister a handler.

Parameters
string$name
string$type
callable$callback
Returns
bool private

Definition at line 89 of file HooksRegistrationService.php.

Member Data Documentation

Elgg\HooksRegistrationService::$logger
protected

Definition at line 39 of file HooksRegistrationService.php.

const Elgg\HooksRegistrationService::REG_KEY_HANDLER = 2

Definition at line 19 of file HooksRegistrationService.php.

const Elgg\HooksRegistrationService::REG_KEY_INDEX = 1

Definition at line 18 of file HooksRegistrationService.php.

const Elgg\HooksRegistrationService::REG_KEY_PRIORITY = 0

Definition at line 17 of file HooksRegistrationService.php.


The documentation for this class was generated from the following file: