Add hooks that are triggered at specific events.

@param \Decoda\Hook $hook
@param string $key
@return \Decoda\Decoda
193267
public function addHook(Hook $hook, $key = null) {
        $hook->setParser($this);

        if (!$key) {
            $key = explode('\\', get_class($hook));
            $key = str_replace('Hook', '', end($key));
        }

        $this->_hooks[$key] = $hook;

        $hook->setupFilters($this);

        ksort($this->_hooks);

        return $this;
    }
1002288
public function registerHook(string $hook)
    {
        // Build a "Hookable" instance.
        // Hookable instances must extend the "Hookable" class.
        $instance = new $hook($this);
        $hooks = (array) $instance->hook;

        if (! method_exists($instance, 'register')) {
            return;
        }

        if (! empty($hooks)) {
            $this['action']->add($hooks, [$instance, 'register'], $instance->priority);
        } else {
            $instance->register();
        }
    }
127440
protected function handleHookFailure(Hook $hook)
    {
        $this->failures[] = $hook;
        $title = $this->formatter->red($hook->getTitle());
        $leftPad = str_repeat(' ', self::TAB_SIZE * $this->depth);
        $this->console->writeLn($leftPad . $title);
    }
274720
protected function installGitHook($hook) {
    $fs = new Filesystem();
    $project_hook_directory = $this->getConfigValue('repo.root') . "/.git/hooks";
    $project_hook = $project_hook_directory . "/$hook";
    if ($this->getConfigValue('git.hooks.' . $hook)) {
      $this->say("Installing $hook git hook...");
      $hook_source = $this->getConfigValue('git.hooks.' . $hook) . "/$hook";
      $path_to_hook_source = rtrim($fs->makePathRelative($hook_source, $project_hook_directory), '/');

      $result = $this->taskFilesystemStack()
        ->mkdir($this->getConfigValue('repo.root') . '/.git/hooks')
        ->remove($project_hook)
        ->symlink($path_to_hook_source, $project_hook)
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        throw new BltException("Unable to install $hook git hook.");
      }
    }
    else {
      if (file_exists($project_hook)) {
        $this->say("Removing disabled $hook git hook...");
        $result = $this->taskFilesystemStack()
          ->remove($project_hook)
          ->stopOnFail()
          ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
          ->run();

        if (!$result->wasSuccessful()) {
          throw new BltException("Unable to remove disabled $hook git hook");
        }
      }
      else {
        $this->say("Skipping installation of $hook git hook...");
      }
    }
  }
653111
def hook(name, options={}, &block)
      hooks[name.to_s] << Hook.new(name.to_s, options, &block)
    end
782973
public function addHook($hookwhere, $hook)
    {
        if (is_array($hook)) {
            if (isset($hook['classref']) && isset($hook['method']) && isset($hook['params'])) {
                if (is_object($hook['classref']) && method_exists($hook['classref'], $hook['method'])) {
                    $this->aCustomHooks[$hookwhere][] = $hook;
                    return true;
                }
            }
        }
        return false;
    }
848323
public function Create($hook, $idempotencyKey = null)
    {
        return $this->CreateObject('hooks_create', $hook, '\MangoPay\Hook', null, null, $idempotencyKey);
    }
198267
protected function add_action( $hook, $method, $priority = 10, $arg_count = 1 ) {
		return $this->add_filter( $hook, $method, $priority, $arg_count );
	}
1256831
public function getHookConfig(string $hook) : Config\Hook
    {
        if (!Hook\Util::isValid($hook)) {
            throw new \InvalidArgumentException('Invalid hook name: ' . $hook);
        }
        return $this->hooks[$hook];
    }
1040465
public function add_theme_hooks(){
		if ( empty( $this->theme_hooks ) ) {
			return;
		}

		try {
			$hook_prefix = isset( $this->hook_prefix ) ? $this->hook_prefix : null ;

			if ( ! $hook_prefix ) {
				throw new \Exception( sprintf( 'Prefixed hooks were specified but no hook prefix was set. [hooked class: %s]', get_class( $this->hooked_class ) ) );
			}

			foreach ( $this->theme_hooks as $theme_hook ) {
				$method_parts = $this->parse_method_name( $theme_hook[0] );

				$args = array(
					$method_parts['hook_type'],
					"{$hook_prefix}_{$method_parts['hook_name']}",
					"theme_{$theme_hook[0]}",
					$theme_hook[2],
					$theme_hook[3],
				);

				call_user_func_array( array( $this, 'add_hook' ), $args );
			}
		} catch ( Exception $e ) {}
	}
1268774
def call_hook(self, hook, *args, **kwargs):
        
        for function in self.hooks[hook]:
            function.__call__(*args, **kwargs)
571056
private function addActions()
    {
        if (isset($this->complement['hooks'])) {
            Hook::getInstance(App::getCurrentID());

            return Hook::addActions($this->complement['hooks']);
        }

        return false;
    }
1127614
protected function triggerHook($hook, $image)
    {
        if (is_callable($hook)) {
            $hook($image);
        }

        // We assume that the user is passing the hook class name
        if (is_string($hook)) {
            $instance = app($hook);
            $instance->handle($image);
        }
    }
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;
    }
328277
public static function resetHook(string $hook)
    {
        if (isset(self::$hooks[$hook]))
            unset(self::$hooks[$hook]);
        if (isset(self::$counters[$hook]))
            unset(self::$counters[$hook]);
        if (isset(self::$paused[$hook]))
            unset(self::$paused[$hook]);
    }
136932
protected function handleHookFailure(Hook $hook)
    {
        $this->lineLength += 1;
        $this->failures[] = $hook;
        $failure = $this->formatter->red('F');
        $this->console->write($failure);
    }
920800
public static function getHookCommand(string $hook) : string
    {
        if (!self::isValid($hook)) {
            throw new RuntimeException(sprintf('Hook \'%s\' is not supported', $hook));
        }
        return Hooks::getValidHooks()[$hook];
    }