Run a user-defined hook.

@param string|array $hook
@param string       $dir

@return bool
163321
protected function runHook($hook, $dir)
    {
        $code = $this->shellHelper->executeSimple(
            implode("\n", (array) $hook),
            $dir
        );
        if ($code !== 0) {
            $this->output->writeln("<comment>The hook failed with the exit code: $code</comment>");
            return false;
        }

        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>');
        }
    }
344206
def run(self, target, payload, instance=None, hook_id=None, **kwargs):
        
        response = requests.post(
            url=target,
            data=json.dumps(payload, cls=DjangoJSONEncoder),
            headers={'Content-Type': 'application/json'}
        )

        if response.status_code == 410 and hook_id:
            HookModel = get_hook_model()
            hook = HookModel.object.get(id=hook_id)
            hook.delete()
259782
public static void addShutdownHook(Runnable hook) {
		Runtime.getRuntime().addShutdownHook((hook instanceof Thread) ? (Thread) hook : new Thread(hook));
	}
945714
public function runHooks($name, AbstractContext $context, $reverse = false)
    {
        $parent = $this->getParent();
        $hooks = $this->hooks[$name];

        if ($reverse) { 
            foreach (array_reverse($hooks) as $hook) {
                $hook->run($context); 
            }
            if ($parent) {
                $parent->runHooks($name, $context, $reverse);
            }
        } else {
            if ($parent) {
                $parent->runHooks($name, $context, $reverse);
            }
            foreach ($hooks as $hook) {
                $hook->run($context); 
            }
        } 
    }
1316226
def _run_hooks(self):
        """"""
        for hook in self.hooks:
            getattr(self, hook)(self._state)
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;
    }
974433
function runHooks(hooks, args, callback) {
    console.log('*** git-hooks.js runHooks', hooks, args);
    if (!hooks.length) {
        callback(0);
        return;
    }
    try {
        var hook = spawnHook(hooks.shift(), args);
        hook.on('close', function (code) {
            if (code === 0) {
                runHooks(hooks, args, callback);
            } else {
                callback(code);
            }
        });
    } catch (e) {
        callback(1, e);
    }
}
437526
public static function hasAction($hook = '', callable $callback = null, $priority = null)
    {
        return static::hasHook('action', $hook, $callback, $priority);
    }
1268774
def call_hook(self, hook, *args, **kwargs):
        
        for function in self.hooks[hook]:
            function.__call__(*args, **kwargs)
693105
def execute_hook(self, event_name):
        """"""
        hook = self.settings.hooks.get_string('{!s}'.format(event_name))
        if hook is not None and hook != "":
            hook = hook.split()
            try:
                subprocess.Popen(hook)
            except OSError as oserr:
                if oserr.errno == 8:
                    log.error("Hook execution failed! Check shebang at first line of %s!", hook)
                    log.debug(traceback.format_exc())
                else:
                    log.error(str(oserr))
            except Exception as e:
                log.error("hook execution failed! %s", e)
                log.debug(traceback.format_exc())
            else:
                log.debug("hook on event %s has been executed", event_name)
80102
public function call_hook($sWhich = '')
    {
        if (!isset($this->aCustomHooks[$sWhich])) {
            return parent::call_hook($sWhich);
        }

        if (isset($this->aCustomHooks[$sWhich][0]) && is_array($this->aCustomHooks[$sWhich][0])) {
            foreach ($this->aCustomHooks[$sWhich] as $aCustomHook) {
                $this->runCustomHook($aCustomHook);
            }
            return true;
        } else {
            $this->runCustomHook($this->aCustomHooks[$sWhich]);
            return true;
        }

        return parent::call_hook($sWhich);
    }
655293
function executeHooks(data, allHooks, checkHooks, creationMode) {
    var hooksToCall = creationMode ? allHooks : checkHooks;
    if (hooksToCall) {
        callHooks(data, hooksToCall);
    }
}
190317
def run_hook(self, hook, *args, **kwargs):
        
        for plugin in self.raw_plugins:
            if hasattr(plugin, hook):
                self.logger.debug('Calling hook {0} in plugin {1}'.format(hook, plugin.__name__))
                getattr(plugin, hook)(*args, **kwargs)
1076803
public function with($hook)
    {
        if (!in_array($hook, PluginInterface::VALID_HOOKS)) {
            throw new InvalidArgumentException("The `{$hook}` hook is not a known plugin hook.");
        }
        foreach ($this as $plugin) {
            if ($plugin->isEnabled($hook)) {
                yield $plugin;
            }
        }
    }
761405
public function addHook(Hook $hook)
    {
        if (isset($this->hooks[$hook->name]) === false) {
            $this->logger->debug(
                "Adding definition for hook '{$hook->name}' for the first time."
            );
            $this->hooks[$hook->name] = [];
        }

        $this->hooks[$hook->name][] = $hook->definition;
    }
861338
public function runHook($name, $vendor, array $assets = [])
    {
        if (!isset($this->hooks[$name]) || !is_callable($this->hooks[$name])) {
            return null;
        }

        return call_user_func($this->hooks[$name], $this, $vendor, $assets);
    }