2017 © Pedro Peláez
 

library hooks-trait

Trait providing methods for creating hooks.

image

dgifford/hooks-trait

Trait providing methods for creating hooks.

  • Thursday, March 9, 2017
  • by dgifford
  • Repository
  • 0 Watchers
  • 0 Stars
  • 50 Installations
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Hooks Trait

Adds the methods required to use hooks in a class, similar to how functions can be hooked into Wordpress., (*1)

Usage

Add a use statement at the start of the class to include the trait., (*2)

class Foo
{
    Use dgifford\Traits\HooksTrait;
}

The doHook method adds a hook into the class. This method requires a name for the hook and a variable that the hook will act on., (*3)

$value = $this->doHook('my_hook_name', $value );

Additional arguments can be provided if hooked in functions require them., (*4)

$value = $this->doHook('my_hook_name', $value, $arguments );

Callbacks can then be hooked into the class with the addHook method, which accepts the hook name and a callable, such as a closure., (*5)

$foo->addHook( 'my_hook_name', function( $value, $arguments ) { return $value + 1; } );

The Versions

09/03 2017

dev-master

9999999-dev

Trait providing methods for creating hooks.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.5

 

php trait events hooks

09/03 2017

v0.4

0.4.0.0

Trait providing methods for creating hooks.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.5

 

php trait events hooks

09/03 2017

v0.3

0.3.0.0

Trait providing methods for creating hooks.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.5

 

php trait events hooks

27/01 2017

v0.2

0.2.0.0

Trait providing methods for creating hooks.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.5

 

php trait events hooks

27/01 2017

v0.1

0.1.0.0

Trait providing methods for creating hooks.

  Sources   Download

GPL-3.0

The Requires

  • php >=5.5

 

php trait events hooks