ICanBoogie/Event v1.3.3
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Event

Classes

  • Event
  • EventHook
  • Events

Class Events

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

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

Methods summary

public static mixed
# __callstatic( string $name, array $arguments )

Calls the callback of a patchable function.

Calls the callback of a patchable function.

Parameters

$name
Name of the function.
$arguments
Arguments.

Returns

mixed
public static callable
# patch( string $name, callable $callback )

Patches a patchable function.

Patches a patchable function.

Parameters

$name
Name of the function.
$callback
Callback.

Returns

callable
Previous callable.

Throws

RuntimeException
is attempt to patch an undefined function.
public
# __construct( array $hooks = [] )
public
# getIterator( )

Returns an iterator for event hooks.

Returns an iterator for event hooks.

Implementation of

IteratorAggregate::getIterator()
public
# configure( array $config )

Adds events from a configuration.

Adds events from a configuration.

Parameters

$config
protected
# revoke_traces( )
public ICanBoogie\EventHook
# attach( string $name, 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\SaveOperation $target) {

    // …

});

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

Parameters

$name
Event type or closure.
$hook
The event hook, or nothing if $name is a closure.

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 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( mixed $name, mixed $hook = null )

Attach an event hook that is detached once used.

Attach an event hook that is detached once used.

Parameters

$name
$hook

Returns

ICanBoogie\EventHook

See

ICanBoogie\Events::attach()
public
# batch_attach( array $definitions )
public
# detach( string $name, callable $hook )

Detaches an event hook.

Detaches an event hook.

Parameters

$name
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 $name )

Marks an event as skippable.

Marks an event as skippable.

Parameters

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

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

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

Parameters

$name
The event name.

Returns

boolean
true if the event can be skipped, false otherwise.
public
# used( $type, $hook )

Declare an event hook as used by an event type, if the hook has been attached using ICanBoogie\Events::once() it is removed.

Declare an event hook as used by an event type, if the hook has been attached using ICanBoogie\Events::once() it is removed.

Parameters

$type
$hook
public array
# get_hooks( string $name )

Returns the event hooks attached to the specified event name.

Returns the event hooks attached to the specified event name.

If the class of the event's target is provided, event hooks are filtered according to the class and its hierarchy.

Parameters

$name
The event name.

Returns

array

Properties summary

protected array[string]array $hooks

Event collection.

Event collection.

# []
protected array[string]array $consolidated_hooks

Event hooks consolidated by class and type.

Event hooks consolidated by class and type.

# []
protected array[string]bool $skippable

Lists of skippable events.

Lists of skippable events.

# []
ICanBoogie/Event v1.3.3 API documentation generated by ApiGen