Redaxscript\Hook::collect PHP Method

collect() public static method

collect from module hook
Since: 3.0.0
public static collect ( string $event = null, array $parameterArray = [] ) : array
$event string name of the module event
$parameterArray array parameter of the module hook
return array
    public static function collect($event = null, $parameterArray = [])
    {
        $outputArray = [];
        /* process modules */
        foreach (self::$_moduleArray as $module) {
            $object = self::$_namespace . '\\' . $module . '\\' . $module;
            self::$_eventArray[$event][$module] = false;
            /* method exists */
            if (method_exists($object, $event)) {
                self::$_eventArray[$event][$module] = true;
                $outputArray = array_merge($outputArray, call_user_func_array([$object, $event], $parameterArray));
            }
        }
        return $outputArray;
    }

Usage Example

示例#1
0
 /**
  * testCollectInvalid
  *
  * @since 3.0.0
  */
 public function testCollectInvalid()
 {
     /* setup */
     Hook::construct($this->_registry);
     Hook::init();
     /* actual */
     $actual = Hook::collect('invalidMethod');
     /* compare */
     $this->assertEmpty($actual);
 }