PHP Classes

PHP Hook System Manager: Register and invoke hook callback functions

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-06-16 (17 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 59 This week: 13All time: 9,733 This week: 25Up
Version License PHP version Categories
hookmgr 1.0GNU Lesser Genera...5PHP 5, Language
Description Author

This class can register and invoke hook callback functions.

It can create a hook with a given name and register one or more actions to be executed by specifying functions to be called.

The class can also invoke all registered callback functions associated to a hook specified with a given name.

  Performance   Level  
Name: Kjell-Inge Gustafsson <contact>
Classes: 13 packages by
Country: Sweden Sweden
Innovation award
Innovation award
Nominee: 4x

Details

> Class HookMgr manages PHP hooks > A hook is a (HookMgr) key for invoking callable(s)

A callable can be * simple function * anonymous function * instantiated object+method : \[ $object, 'methodName' ] * class name and static method : \[ 'namespaceClassName', 'methodName' ] * instantiated object, class with (magic) __call method : \[ $object, 'someMethod' ] * class name, class with (magic) __callStatic method : \[ 'namespaceClassName', 'someMethod' ] * instantiated object, class with (magic) __invoke method : $object

Define a hook with callable

HookMgr::addAction( $hook, $callable );

Invoke callable using hook

$result = HookMgr::apply( $hook );

Methods

* Add single hook with single callable, _syntax_only_ callable check
* ```hook``` _string_  
* ```callable``` _callable_
* Throws InvalidArgumentException
* static

  • Add single hook invoking an array of callables
  • Note, if invoked with arguments, arguments are used for all callables
  • `hook` _string_
  • `callables` _callable\[]_
  • Throws InvalidArgumentException
  • static
* Set all hooks, each for invoking single or array of callables
`actions` _array_( hook => callable(s) )
* Throws InvalidArgumentException
* static

---

  • Invoke 'hook' action(s), return (last) result
  • `hook` _string_
  • `args` _array_ opt, \[ arg1, arg2... ] * Opt arguments are used in all hook invokes * To use an argument by-reference, use `HookMgr::apply( 'hook', [ & $arg ] );`
  • Return _mixed_
  • Throws RuntimeException
  • static

* Return 
  * count of hooks
  * count of callables for hook
  * not found hook return 0
* ```hook``` _string_  
* Return bool
* static

  • `hook` _string_
  • Return bool, true if hook is set
  • static
* Return array callables for hook, not found return []
* ```hook``` _string_  
* Return _callable\[]_
* static

  • Return _array_ (string[]) hooks
  • static
* Clear (remove) all hooks with callables
* static


  • Remove single hook with callable(s)
  • `hook` _string_
  • static

* Return _string_ nice rendered hooks with callable(s)
* static

###### Sponsorship

Donation using <a href="https://paypal.me/kigkonsult?locale.x=en_US" rel="nofollow">paypal.me/kigkonsult</a> are appreciated. 
For invoice, <a href="mailto:ical@kigkonsult.se">please e-mail</a>.

###### INSTALL

composer require kigkonsult/hookmgr:dev-master


Composer, in your `composer.json`:

{

"require": {
    "kigkonsult/hookmgr": "dev-master"
}

}


Composer, acquire access

use Kigkonsult\HookMgr\HookMgr; ... include 'vendor/autoload.php';



Otherwise , download and acquire..

use Kigkonsult\HookMgr\HookMgr; ... include 'pathToSource/kigkonsult/HookMgr/autoload.php';



###### Support

For support go to [github.com HookMgr]


###### License

This project is licensed under the LGPLv3 License


[Composer]:https://getcomposer.org/
[github.com HookMgr]:https://github.com/iCalcreator/HookMgr
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetest (1 file)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENCE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file HookMgr.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Plain text file HookMgrTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:59
This week:13
All time:9,733
This week:25Up

For more information send a message to info at phpclasses dot org.