Check if a hook needs updating.

@param \Platformsh\Client\Model\Integration $integration
@param array                                $hook
@param array                                $payload

@return bool
960073
private function hookNeedsUpdate(Integration $integration, array $hook, array $payload)
    {
        if ($integration->type === 'bitbucket') {
            foreach ($payload as $item => $value) {
                if (!isset($hook[$item])) {
                    return true;
                }
                if ($item === 'events') {
                    sort($value);
                    sort($hook[$item]);
                    if ($value !== $hook[$item]) {
                        return true;
                    }
                }
                if ($hook[$item] !== $value) {
                    return true;
                }
            }

            return false;
        }

        return $this->arraysDiffer($hook, $payload);
    }
1262756
public final static function action( $hook, $action, $priority = null, $accepted_args = null ) {
		$priority      = $priority ?? self::PRIORITY;
		$accepted_args = $accepted_args ?? self::ACCEPTED_ARGS;
		add_action( $hook, $action, (int) $priority, (int) $accepted_args );
	}
353082
public function addHook(HookFactory $hook): void
	{
		$hook->init();
		$this->hooks[$hook->name] = $hook;
	}
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;
    }
231223
public static function hasFilter($hook = '', callable $callback = null, $priority = null)
    {
        return static::hasHook('filter', $hook, $callback, $priority);
    }
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;
    }
798496
public function add(HookInterface ...$hooks): void
    {
        $this->hooks = array_values(
            array_unique(
                array_merge($this->hooks, $hooks),
                SORT_REGULAR
            )
        );
    }
473980
public function trigger($event, &$payload = null)
    {
        // Disallow calling a trigger on global hooks
        if ($event === '*') {
            return $this;
        }

        // Get all global hooks
        $globalHooks = [];
        if (isset($this->hooks['*']) && count($this->hooks['*']) > 0) {
            $globalHooks = $this->hooks['*'];
        }

        // Check if the event exists and has callables to run
        if (!isset($this->hooks[$event]) || count($this->hooks[$event]) === 0) {
            // There are no specific hooks, but maybe there's global hooks?
            if (count($globalHooks) === 0) {
                // There is nothing to do here
                return $this;
            }
            $hooks = $globalHooks;
        } else {
            $hooks = $this->hooks[$event];
            $hooks = array_merge($hooks, $globalHooks);
        }

        // All good, let's call those callables
        foreach ($hooks as $callable) {
            $callable($event, $payload);
        }
        return $this;
    }
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;
    }
223658
public static function unsubscribe(string $hook, int $hook_reference)
    {
        $parts = explode(".", $hook);
        if (count($parts) < 2)
            throw new InvalidArgumentException("Hook name must consist of at least two parts");

        if (!isset(self::$hooks[$hook]))
            throw new InvalidArgumentException("Hook was not set");

        foreach (self::$hooks[$hook] as $idx => $hook_data)
        {
            if ($hook_data['ref'] === $hook_reference)
            {
                unset(self::$hooks[$hook][$idx]);
                return true;
            }
        }
        return false;
    }
1309854
public function exec_hook($hook, $args = array())
    {
        if (!is_array($args)) {
            $args = array('arg' => $args);
        }

        // TODO: avoid recursion by checking in_array($hook, $this->exec_stack) ?

        $args += array('abort' => false);
        array_push($this->exec_stack, $hook);

        // Use for loop here, so handlers added in the hook will be executed too
        if (!empty($this->handlers[$hook])) {
            for ($i = 0; $i < count($this->handlers[$hook]); $i++) {
                $ret = call_user_func($this->handlers[$hook][$i], $args);
                if ($ret && is_array($ret)) {
                    $args = $ret + $args;
                }

                if ($args['break']) {
                    break;
                }
            }
        }

        array_pop($this->exec_stack);
        return $args;
    }
843884
public function trigger(Payload $payload) {
		$enabled = (boolean) (TRUE === isset($this->settings[self::OPTION_ENABLED]) ? $this->settings[self::OPTION_ENABLED] : TRUE);
		$matchesBranch = TRUE === isset($this->settings[self::OPTION_BRANCH]) ? 'refs/heads/' . $this->settings[self::OPTION_BRANCH] === $payload->getRef() : TRUE;
		return $enabled && $matchesBranch;
	}
580002
function addHook(hooks, hook) {
    hooks.push(hook)
    return function () {
      var i = hooks.indexOf(hook)
      if (i >= 0) return hooks.splice(i, 1)
    }
  }
312799
public function addHookTo($zone, $hook, Array $args=array()){
		if(!isset($this->content[$zone])){
			$this->content[$zone] = array();
		}
		//allow just a string reference to a method on this skin object
		if (!is_array($hook) && method_exists($this, $hook)) {
			$hook = array($this, $hook);
		}
		if (!is_callable($hook, false, $callbable_name)) {
			throw new \Exception('Invalid skin content hook for zone:'.$zone.' (Hook callback was: '.$callbable_name.')');
		}
		$this->content[$zone][] = array('type'=>'hook', 'hook'=>$hook, 'arguments'=>$args);
	}
543449
public function remove($hook, $callback = null, $priority = 10)
    {
        // If $callback is null, it means we have chained the methods to
        // the action/filter instance. If the instance has no callback, return false.
        if (is_null($callback)) {
            if (! $callback = $this->getCallback($hook)) {
                return false;
            }

            list($callback, $priority, $accepted_args) = $callback;

            // Unset the hook.
            unset($this->hooks[$hook]);
        }

        $this->removeAction($hook, $callback, $priority);

        return $this;
    }
1262116
public function isWebsocketPushPayload($payload): bool
    {
        if (! is_array($payload)) {
            return false;
        }

        return $this->isServerWebsocket
            && ($payload['action'] ?? null) === Websocket::PUSH_ACTION
            && array_key_exists('data', $payload);
    }
1195125
protected function seedHook(Hook $hook)
    {
        $folders = (array) $hook->getComposerHookKey('seeders', []);
        $basePath = $hook->getPath().'/';

        $this->runSeeders($folders, $basePath);
    }