"Fossies" - the Fresh Open Source Software Archive

Member "fogproject-1.5.9/packages/web/lib/fog/hookmanager.class.php" (13 Sep 2020, 2321 Bytes) of package /linux/misc/fogproject-1.5.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "hookmanager.class.php": 1.5.8_vs_1.5.9.

    1 <?php
    2 /**
    3  * HookManager handles registering and loading
    4  * events and hooks.
    5  *
    6  * PHP version 5
    7  *
    8  * @category HookManager
    9  * @package  FOGProject
   10  * @author   Tom Elliott <tommygunsster@gmail.com>
   11  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   12  * @link     https://fogproject.org
   13  */
   14 /**
   15  * HookManager handles registering and loading
   16  * events and hooks.
   17  *
   18  * @category HookManager
   19  * @package  FOGProject
   20  * @author   Tom Elliott <tommygunsster@gmail.com>
   21  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   22  * @link     https://fogproject.org
   23  */
   24 class HookManager extends EventManager
   25 {
   26     /**
   27      * Log level if needed.
   28      *
   29      * @var int
   30      */
   31     public $logLevel = 0;
   32     /**
   33      * Data to store and use.
   34      *
   35      * @var mixed
   36      */
   37     public $data;
   38     /**
   39      * Events to work off.
   40      *
   41      * @var array
   42      */
   43     public $events = array();
   44     /**
   45      * Processes the system for customizable elements.
   46      *
   47      * @param string $event     the event to process
   48      * @param array  $arguments the arguments to pass
   49      *
   50      * @return void
   51      */
   52     public function processEvent($event, $arguments = array())
   53     {
   54         $exists = self::getClass('HookEventManager')->exists(
   55             $event,
   56             '',
   57             'name'
   58         );
   59         if (!$exists) {
   60             self::getClass('HookEvent')
   61                 ->set('name', $event)
   62                 ->save();
   63         }
   64         if (!isset($this->data[$event])) {
   65             return;
   66         }
   67         foreach ((array) $this->data[$event] as &$function) {
   68             $active = false;
   69             $className = get_class($function[0]);
   70             $refClass = new ReflectionClass($className);
   71             $filename = $refClass->getFileName();
   72             if (!method_exists($function[0], $function[1])) {
   73                 continue;
   74             }
   75             if (stripos($filename, 'plugins') !== false) {
   76                 $function[0]->active = true;
   77             }
   78             $active = $function[0]->active;
   79             if (!$active) {
   80                 continue;
   81             }
   82             $mergedArr = self::fastmerge(
   83                 array('event' => $event),
   84                 $arguments
   85             );
   86             $function[0]->{$function[1]}($mergedArr);
   87             unset($function);
   88         }
   89     }
   90 }