Load hooks.

@since 1.1.0

@uses \string Hook::getInstance() → get Hook instance
@uses \string Hook::addActions()  → add action hook

@link https://github.com/Josantonius/PHP-Hook
493338
private function runHooks()
    {
        if (class_exists($Hook = 'Josantonius\Hook\Hook')) {
            $Hook::getInstance(self::$id);
            if (isset($this->settings['hooks'])) {
                $Hook::addActions($this->settings['hooks']);
                unset($this->settings['hooks']);
            }
            $Hook::doAction('after-load-hooks');
        }
    }
140039
public static function run($hook, array $params = array())
    {
        // Make sure the hook index exists
        if (!isset(static::$plugins[$hook])) {
            return false;
        }

        // Run the hook
        foreach (static::$plugins[$hook] as $plugin) {
            call_user_func_array($plugin, $params);
        }
    }
1230630
public function hooks()
    {
        $this->hook->action(
            'init',
            [$this->taxonomy, 'register']
        )->dispatch();

        $this->hook->action(
            "{$this->taxonomy->getModel()->getSlug()}_add_form_fields",
            [$this->taxonomy, 'fill']
        )->dispatch();

        $this->hook->action(
            "{$this->taxonomy->getModel()->getSlug()}_edit_form_fields",
            [$this->taxonomy, 'fill']
        )->dispatch();

        $this->hook->action(
            "created_{$this->taxonomy->getModel()->getSlug()}",
            [$this->taxonomy, 'save']
        )->dispatch();

        $this->hook->action(
            "edited_{$this->taxonomy->getModel()->getSlug()}",
            [$this->taxonomy, 'save']
        )->dispatch();
    }
305389
public function registerHookProviders()
    {
        // load only the enabled hooks
        $hooks = $this->app['hooks']->hooks()->where('enabled', true);
        $loader = AliasLoader::getInstance();

        foreach ($hooks as $hook) {
            // load providers
            foreach ($hook->getProviders() as $provider) {
                $this->app->register($provider);
            }

            // set aliases
            foreach ($hook->getAliases() as $alias => $class) {
                $loader->alias($alias, $class);
            }
        }
    }
560970
public function loadRoutesFromClass($className, $hooks=[])
    {
        $cache = new CheckableCache($this->cache);

        $key = 'loadRoutesFromClass:' . md5(__CLASS__ . ':' . $className);
        $routes = $cache->get($key, $this);

        $controller = null;
        if ($routes == $this) { //not cached
            $routes = [];
            $controller = $this->controllerContainerBuilder->build($className);
            foreach ($controller->getRoutes() as $actionName => $route) {
                $routes[] = [$route->getMethod(), $route->getUri(), $actionName];
            }
            $cache->set($key, $routes, 0, new ClassModifiedChecker($className));
        }
        foreach ($routes as $route) {
            list($method, $uri, $actionName) = $route;
            $this->routes[] = [
                $method,
                $uri,
                function (Application $app, Request $request) use ($cache, $className, $actionName, $controller) {

                    $key = 'loadRoutesFromClass:route:' . md5(__CLASS__ . ':' . $className . ':' . $actionName);

                    $routeInstance = $cache->get($key, $this);
                    if ($routeInstance == $this) {
                        if (!$controller) {
                            $controller = $app->controllerContainerBuilder->build($className);
                        }
                        $routeInstance = $controller->getRoute($actionName) or
                        abort(new NotFoundHttpException("action $actionName not found"));
                        $cache->set($key, $routeInstance, 0, new ClassModifiedChecker($className));
                    }
                    return ControllerContainer::dispatch($this, $className, $actionName, $routeInstance, $request);
                },
                $hooks
            ];
        }
        $this->controllers[] = $className;
    }
1235717
function hook() {
      var comp = hook.proxy.apply(null, arguments);
      for(var i = 0;i < hooks.length;i++) {
        hooks[i].apply(comp, arguments);
      }
      return comp;
    }
798496
public function add(HookInterface ...$hooks): void
    {
        $this->hooks = array_values(
            array_unique(
                array_merge($this->hooks, $hooks),
                SORT_REGULAR
            )
        );
    }
599596
def load_hooks
      self.site_hooks = instantiate_subclasses(Octopress::Hooks::Site) || []
      self.page_hooks = instantiate_subclasses(Octopress::Hooks::Page) || []
      self.post_hooks = instantiate_subclasses(Octopress::Hooks::Post) || []
      self.doc_hooks  = instantiate_subclasses(Octopress::Hooks::Document) || []
      self.all_hooks  = instantiate_subclasses(Octopress::Hooks::All) || []
    end
808209
public function load_hooks() {
		add_action( 'admin_init', [ $this, 'remote_management_page_init' ] );
		add_action(
			'github_updater_update_settings',
			function ( $post_data ) {
				$this->save_settings( $post_data );
			}
		);
		add_filter( 'github_updater_add_admin_pages', [ $this, 'extra_admin_pages' ] );
		$this->add_settings_tabs();
	}
6676
def load_hooks(self, context):
        
        for hook in self.configuration.get('hooks', ()):
            config = hook.get('configuration', {})
            config.update(self.configuration.get('configuration', {}))

            try:
                self._load_hook(hook['name'], config, context)
            except KeyError:
                self.logger.exception('Provided hook has no name: %s.', hook)
1290557
public function getPossibleHooks() {
		static $hooks=null;
		if ($hooks === null) {
		    $hooks = array();
		    
		    // Cannot use the same logic as the core Module loading,
		    // as this forces a new include of the module.php file.
		    // This causes issue when classes are defined in this file.
		    // Cannot use Module::getActiveModules as well, as this is private.
		    $module_names = Database::prepare(
		        'SELECT module_name FROM `##module`'
		    )->fetchOneColumn();
		    
		    foreach($module_names as $module_name) {
		        $module = Module::getModuleByName($module_name);
		        
		        if($module instanceof HookSubscriberInterface){
					$subscribedhooks = $module->getSubscribedHooks();
					if(is_array($subscribedhooks)){
						foreach($subscribedhooks as $key => $value){
							if(is_int($key)) {
								$hook_item = $value;
								$priority = self::DEFAULT_PRIORITY;
							}
							else{
								$hook_item = explode('#', $key, 2);
								$priority = $value;
							}
							if($hook_item && count($hook_item) == 2){
								$hook_func = $hook_item[0];
								$hook_cont = $hook_item[1];
							}
							else{
								$hook_func = $hook_item[0];
								$hook_cont = 'all';
							}
							if(method_exists($module, $hook_func)){
								$hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority;
							}
						}
					}
		        }
			}
		}
		return $hooks;
	}
256530
def load_hooks():
    
    hooks = {}
    for entrypoint in pkg_resources.iter_entry_points(ENTRYPOINT):
        name = str(entrypoint).split('=')[0].strip()
        try:
            hook = entrypoint.load()
        except Exception as e:
            write_message('failed to load entry-point %r (error="%s")' % (name, e), 'yellow')
        else:
            hooks[name] = hook
    return hooks
1266381
public function renderHook()
    {
        $form_hook = $this->mapAuthenticationTypeFilePath('hook.php');
        if (method_exists($this->controller, 'hook') || $form_hook->exists()) {
            ob_start();
            if (method_exists($this->controller, 'hook')) {
                $this->controller->hook();
            }
            if ($form_hook->exists()) {
                $controller = $this->controller;
                extract($this->controller->getSets());
                require_once $form_hook->file;
            }
            $out = ob_get_contents();
            ob_end_clean();
            echo $out;
        }
    }
7412
public static function hook($hook, $params = [])
    {
        $hookRun = isset(self::$mountInfo[$hook]) ? self::$mountInfo[$hook] : null;
        if (!is_null($hookRun)) {
            foreach ($hookRun as $key => $val) {
                if (is_int($key)) {
                    $callBack = $val;
                } else {
                    $plugin = new $key();
                    $callBack = [$plugin, $val];
                }
                $return = call_user_func_array($callBack, array_slice(func_get_args(), 1));

                if (!is_null($return)) {
                    return $return;
                }
            }
        }
        return null;
    }
953871
public function attach($hook, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null)
    {
        $module_id = null;

        if (strpos($hook, '|') !== false) {
            list($hook, $module_id) = explode('|', $hook, 2);
        }

        $method = $this->getMethod($hook);

        if (isset($module_id)) {
            $class = $this->module->getClass($module_id);
            return $this->call($class, $method, $a, $b, $c, $d, $e);
        }

        if (empty($this->hooks[$method])) {
            return false;
        }

        foreach (array_keys($this->hooks[$method]) as $class) {
            $this->call($class, $method, $a, $b, $c, $d, $e);
        }

        return true;
    }
473759
public function writeHookFile(string $hook) : void
    {
        $hooksDir = $this->repository->getHooksDir();
        $hookFile = $hooksDir . DIRECTORY_SEPARATOR . $hook;
        $doIt     = true;

        // if hook is configured and no force option is set
        // ask the user if overwriting the hook is ok
        if ($this->needInstallConfirmation($hook)) {
            $ans  = $this->io->ask('  <comment>The \'' . $hook . '\' hook exists! Overwrite? [y,n]</comment> ', 'n');
            $doIt = IOUtil::answerToBool($ans);
        }

        if ($doIt) {
            $code = $this->getHookSourceCode($hook);
            $file = new File($hookFile);
            $file->write($code);
            chmod($hookFile, 0755);
            $this->io->write('  <info>\'' . $hook . '\' hook installed successfully</info>');
        }
    }
1109944
public function use_default_hook_listeners() {

		static $done = FALSE;
		if ( $done ) {
			return $this;
		}

		$done = TRUE;

		add_action(
			HookListenersRegistry::ACTION_REGISTER,
			function ( HookListenersRegistry $registry ) {

				$registry
					->register_listener( new HookListener\DbErrorListener() )
					->register_listener( new HookListener\FailedLoginListener() )
					->register_listener( new HookListener\HttpApiListener() )
					->register_listener( new HookListener\MailerListener() )
					->register_listener( new HookListener\QueryErrorsListener() )
					->register_listener( new HookListener\CronDebugListener() )
					->register_listener( new HookListener\WpDieHandlerListener() );
			}
		);

		return $this;
	}