Trigger a chained hook
- The first callback to return a non-null value
will be returned

@param  string     $name    the hook name
@param  mixed      $hookArg (Optional) Argument for hooked functions
@return mixed|void
193680
public function applyChain($name, $hookArg = null)
    {
        $hooks = $this->app->getHooks();

        if (!isset($hooks[$name])) {
            $hooks[$name] = array(array());
        }
        if (!empty($hooks[$name])) {
            // Sort by priority, low to high, if there's more than one priority
            if (count($hooks[$name]) > 1) {
                ksort($hooks[$name]);
            }
            foreach ($hooks[$name] as $priority) {
                if (!empty($priority)) {
                    foreach ($priority as $callable) {
                        $value = call_user_func($callable, $hookArg);
                        if ($value !== null) {
                            return $value;
                        }
                    }
                }
            }
        }
    }
135416
public static function trigger($name, $args) {
        if (array_key_exists($name, static::$events)) {
            $infos = static::$events[ $name ];
            if ($infos) {
                foreach ($infos as $info) {
                    $module = Ioc::get($info[ 'class' ]);
                    if ($info[ 'action' ]) {
                        static::doAction($module, $info[ 'action' ], $args);
                    }
                }
            }
        }
    }
449458
public static function call($hookName, $args = array(), $alternativePath = NULL) {
        $hookImplementer = self::hasImplementer($hookName);

        if (!empty($hookImplementer)) {
            $implementerClass = '\\Hooks\\' . $hookImplementer;
            $implementer = new $implementerClass();
            $implementer->$hookName($args);
        } else {
            $defaultImplementer = self::hasDefaultImplementer($hookName, $alternativePath);
           
            if ($defaultImplementer) {
                return $defaultImplementer::$hookName($args);
            } else {
                throw new \Exception(_message(ExceptionMessages::UNDECLARED_HOOK_NAME, $hookName));
            }
        }
    }
605011
private function parse_method_name( $name ){
		if ( preg_match( '|^(_?[^_]+_)(.*)$|', $name, $matches ) ) {
			$hook_type = trim( $matches[1], '_' ); //Methods prefixed with _ are always hooked
			$hook_name = $matches[2];

			if ( ! in_array( $hook_type , array( 'theme', 'action', 'filter', 'shortcode' ) ) ) {
				return false;
			}

			return compact( 'hook_type', 'hook_name' );
		}

		return false;
	}
1019469
public function getHook(string $name): Hook
  {
    # Find hook in list
    foreach ($this->hooks as $hook)
    {
      if (\strcasecmp($name,$hook->getName()==0)) {
        return $hook;
      }
    }

    return null;
  }
1221830
public static function call($name, $arguments = []) {
		if (self::exists($name)) {
			$application = Application::get();
			$classname = 'Hook_' . ucfirst($application->name);
			call_user_func_array([$classname, $name], $arguments);
		} else {
			throw new \Exception('Hook is not defined');
		}
	}
418706
def register(self, name: str):
        ''''''
        if name in self._callbacks:
            raise ValueError('Hook already registered')

        self._callbacks[name] = None

        if self._event_dispatcher is not None:
            self._event_dispatcher.register(name)
1341215
public static function trigger($name, $data = [], $target = null, $paramClass = EventParam::class)
    {
        static::getInstance()->__trigger($name, $data, $target, $paramClass);
    }
309302
public function triggerSubEvent($name, $event, $args = [])
    {
        return $this->getDispatcher($name)->triggerEvent($event, $args);
    }
1083135
public static function runHook($name, array $params = [ ])
    {
        static::ensureHookPoint($name);

        foreach (static::$hooks[ $name ] as $handler) {
            if ($handler instanceof \Closure) {

                call_user_func_array($handler, $params);
            } elseif (class_exists($handler)) {
                $instance = app()->make($handler);

                call_user_func_array([ $instance, 'handle' ], $params);
            }
        }
    }
101041
public function handler($name, Args $args)
    {
        if (
            !$this->checkLevel($args->get('level')) ||
            !$this->checkSource($args->get('source'))
        ) {
            return;
        }

        switch ($name) {
            /*
            case ':log:':
                $this->log($args);
                break; // case 'log'

            */
            case ':onAddHandler:':
                $args->set('message', sprintf(
                    "Adding handler %s, %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    ),
                    $args->get('added', false)
                        ? "successfully" :
                        "failed (duplicate handler)"
                ));
                break; // case ':onAddHandler:'

            case ':onEventStart:':
                $args->set('message', sprintf(
                    "{ '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventStart:'

            case ':onHandlerFound:':
                $args->set('message', sprintf(
                    "Handler %s found",
                    $this->handlerToString($args->get('handler'))
                ));
                break; // case ':onAddHandler:'

            case ':onEventEnd:':
                $args->set('message', sprintf(
                    "} '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventEnd:'

            case ':onDropHandlers:':
                $args->set('message', sprintf(
                    "Dropping handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onDisableHandler:':
                $args->set('message', sprintf(
                    "Disabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onEnableHandler:':
                $args->set('message', sprintf(
                    "Enabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'
        }
        $this->log($args);
    }
1302518
public function hook($name)
    {
        if (!$this->downloaded($name)) {
            throw new Exceptions\HookNotFoundException("Hook [{$name}] not found.");
        }

        if (!$this->installed($name)) {
            throw new Exceptions\HookNotInstalledException("Hook [{$name}] not installed.");
        }

        return $this->hooks[$name];
    }
732508
protected function callHooks($name)
    {
        $hooks = Arr::get($this->hooks, $name, []);

        foreach ($hooks as $func) {
            if (!$func instanceof Closure) {
                continue;
            }

            $response = call_user_func($func, $this);

            if ($response instanceof Response) {
                return $response;
            }
        }
    }
1304410
def run_hook(name, *args)
      return if @hooks[name].blank?

      @hooks[name].each do |hook|
        args.any? ? hook.call(*args) : hook.call
      end
    end
1180083
private function do_hook() {

		$args = func_get_args();
		if ( empty( $args ) ) {
			return false;
		}
		$name = array_shift( $args );

		return pods_do_hook( "api", $name, $args, $this );
	}
885026
public function triggerEvent($name, array $data = [])
    {
        try {
            /** @var EventInterface $event */
            $event = $this->createEventObject($name, $data);
        } catch (\InvalidArgumentException $exception) {
            return $this;
        }

        foreach ($this->options['events'][$name]['listeners'] as $eventListener) {
            if ($event->isPropagationStopped()) {
                $this->loggerInstance->makeLogEvent($name, $eventListener, self::EVENT_STATUS_BREAK);
                break;
            }

            $this->executeListener($eventListener, $event, $name);
        }

        return $this;
    }
654745
public function fireDB($name)
    {
        $args = func_get_args();
        array_shift($args);

        if (!isset($this->hooks[$name])) {
            //$this->hooks[$name] = array(array());
            return $args[0];
        }
        if (!empty($this->hooks[$name])) {
            // Sort by priority, low to high, if there's more than one priority
            if (count($this->hooks[$name]) > 1) {
                ksort($this->hooks[$name]);
            }

            $output = [];

            foreach ($this->hooks[$name] as $priority) {
                if (!empty($priority)) {
                    foreach ($priority as $callable) {
                        $output[] = call_user_func_array($callable, $args);
                    }
                }
            }

            return $output[0];
        }
    }