ICanBoogie/Event master
  • Namespace
  • Class

Namespaces

  • ICanBoogie

Classes

  • Event
  • EventCollection
  • EventCollectionProvider
  • EventHook
  • EventHookReflection
  • EventProfiler
  • EventReflection

Functions

  • get_events

Class EventCollection

Events collected from the "hooks" config or attached by the user.

ICanBoogie\EventCollection implements IteratorAggregate
Namespace: ICanBoogie
Located at EventCollection.php

Methods summary

public
# __construct( array $definitions = [] )

Parameters

$definitions
Event hooks grouped by type.
public
# getIterator( )

Returns an iterator for event hooks.

Returns an iterator for event hooks.

Implementation of

IteratorAggregate::getIterator()
protected
# revoke_traces( )

Revokes consolidated hooks and skippable types.

Revokes consolidated hooks and skippable types.

public ICanBoogie\EventHook
# attach( string|callable $type_or_hook, callable $hook = null )

Attaches an event hook.

Attaches an event hook.

The name of the event is resolved from the parameters of the event hook. Consider the following code:

<?php

$events->attach(function(ICanBoogie\Operation\BeforeProcessEvent $event, ICanBoogie\Module\Operation\SaveOperation $target) {

    // …

});

The hook will be attached to the ICanBoogie\Module\Operation\SaveOperation::process:before event.

Parameters

$type_or_hook
Event type or event hook.
$hook
The event hook, or nothing if $type is the event hook.

Returns

ICanBoogie\EventHook

An event hook reference that can be used to easily detach the event hook.

Throws

InvalidArgumentException
when $hook is not a callable.
public
# attach_many( array $definitions )

Attaches many event hooks at once.

Attaches many event hooks at once.

Note: The event hooks must be grouped by event type.

Parameters

$definitions
public ICanBoogie\EventHook
# attach_to( object $target, callable $hook )

Attaches an event hook to a specific target.

Attaches an event hook to a specific target.

Parameters

$target
$hook

Returns

ICanBoogie\EventHook
public ICanBoogie\EventHook
# once( string|callable $type_or_hook, callable $hook = null )

Attaches an event hook that is detached once used.

Attaches an event hook that is detached once used.

Parameters

$type_or_hook
Event type or event hook.
$hook
The event hook, or nothing if $type is the event hook.

Returns

ICanBoogie\EventHook

See

ICanBoogie\EventCollection::attach()
public
# detach( string $type, callable $hook )

Detaches an event hook.

Detaches an event hook.

Parameters

$type
The name of the event.
$hook
The event hook.

Throws

Exception
when the event hook is not attached to the event name.
public
# skip( string $type )

Marks an event as skippable.

Marks an event as skippable.

Parameters

$type
The event type.
public boolean
# is_skippable( string $type )

Returns whether or not an event has been marked as skippable.

Returns whether or not an event has been marked as skippable.

Parameters

$type
The event type.

Returns

boolean
true if the event can be skipped, false otherwise.
public array
# get_hooks( string $type )

Returns the event hooks attached to the specified event type.

Returns the event hooks attached to the specified event type.

Parameters

$type
The event type.

Returns

array
public callable
# resolve_original_hook( mixed $hook )

Resolves original hook.

Resolves original hook.

Parameters

$hook

Returns

callable

Properties summary

protected array $hooks

Event hooks by type.

Event hooks by type.

# []
protected array $consolidated_hooks

Event hooks by class and type.

Event hooks by class and type.

# []
protected SplObjectStorage $original_hooks
# []
protected array $skippable

Skippable events.

Skippable events.

# []
ICanBoogie/Event master API documentation generated by ApiGen