执行插件

@param string $hook 插件钩子名称
@param array $params 参数

@return mixed
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;
    }
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 );
	}
749504
public static function run( $query, $params = array(), $handler = null ) 
	{
		return Handler::create( $handler )->run( $query, $params );
	}
712033
private function parseHooks(array $hooks)
    {
        $list = [];

        foreach ($hooks as $func) {
            if (isset($func['name'])) {
                $list[] = NamedJsFunction::createFromArray($func);

                continue;
            }

            $list[] = ErlangFunction::createFromArray($func);
        }

        return $list;
    }
1047185
private function _exec($params) {
        $params['key'] = $this->_config['api_key'];
        $params = json_encode($params);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mandrill-PHP/1.0.52');
        curl_setopt($ch, CURLOPT_POST, true);
        if (!ini_get('safe_mode') && !ini_get('open_basedir')){
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        }
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_TIMEOUT, 600);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send.json');
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        curl_setopt($ch, CURLOPT_VERBOSE, false);

        $response_body = curl_exec($ch);

        if(curl_error($ch)) {
            throw new Exception("API call to messages/send failed: " . curl_error($ch));
        }
        $result = json_decode($response_body, true);
        if($result === null) throw new Exception('We were unable to decode the JSON response from the Mandrill API: ' . $response_body);

        return $result;
    }
209644
protected function getHookedTasks($hook, array $arguments)
    {
        $tasks = $this->config->getContextually('strategies.'.$hook);
        if (!is_callable($tasks)) {
            return;
        }

        // Cancel if no tasks to execute
        $tasks = (array) $tasks(...$arguments);
        if (empty($tasks)) {
            return;
        }

        // Run commands
        return $tasks;
    }
162804
public function _execute(array $params = null)
    {
        try {
            if ($params !== null) {
                return $this->_stmt->execute($params);
            } else {
                return $this->_stmt->execute();
            }
        } catch (PDOException $e) {
            // require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
        }
    }
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)
10345
function hook_code($hook_short_name, $parameters_string) {
    $parameters = explode(', ', $parameters_string);
    $parameters_doc_lines = array();
    foreach ($parameters as $parameter) {
      $parameters_doc_lines[] = " * @param $parameter\n" .
                                " *   TODO: document this parameter.";
    }
    if (!empty($parameters_doc_lines)) {
      $parameters_doc = " *\n" . implode("\n", $parameters_doc_lines);
    }

    return <<<EOT
/**
 * TODO: write summary line.
 *
 * TODO: longer description.
$parameters_doc
 *
 * @return
 *   TODO: Document return value if there is one.
 */
function hook_$hook_short_name($parameters_string) {
  // TODO: write sample code.
}

EOT;
  }
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;
            }
        }
    }
261912
public static function urlHandler($hook, $type, $url, $params) {

		$entity = elgg_extract('entity', $params);
		/* @var ElggEntity $entity */

		if ($entity instanceof Comment) {
			$container = $entity->getContainerEntity();
			if ($container instanceof Comment) {
				return $container->getURL();
			}
			return elgg_normalize_url(implode('/', array(
						'stream',
						'comments',
						$entity->container_guid,
						$entity->guid,
					))) . "#elgg-object-$entity->guid";
		} else if ($entity instanceof RiverObject) {
			return elgg_normalize_url(implode('/', array(
				'stream',
				'view',
				$entity->guid
			)));
		}

		return $url;
	}
512049
private function createRpbCommitHook(array $hook)
    {
        $func = new RpbCommitHook();

        if (isset($hook['name'])) {
            $func->setName($hook['name']);

            return $func;
        }

        $func->setModfun($this->createRpbModFun($hook));

        return $func;
    }
831083
public function run($hook, $args = null)
    {
        if (is_array($args)) {
            $this->doActionRefArray($hook, $args);
        } else {
            $this->doAction($hook, $args);
        }

        return $this;
    }
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;
    }
919669
public function execute(array $params = []): Promise
    {
        $this->lastUsedAt = \time();

        return call(function () use ($params) {
            $statement = yield from $this->pop();
            \assert($statement instanceof Statement);

            try {
                $statement = yield $this->prepare($statement);
                \assert($statement instanceof Statement);
                $result = yield $statement->execute($params);
            } catch (\Throwable $exception) {
                $this->push($statement);
                throw $exception;
            }

            if ($result instanceof ResultSet) {
                $result = $this->createResultSet($result, function () use ($statement) {
                    $this->push($statement);
                });
            } else {
                $this->push($statement);
            }

            return $result;
        });
    }
1189203
protected function trigger($event, $params = array())
	{
		if (isset($this->yurunEvents[$event]))
		{
			$args = func_get_args();
			array_shift($args);
			foreach ($this->yurunEvents[$event] as $key => $item)
			{
				if(true === $item['once'])
				{
					unset($this->yurunEvents[$event][$key]);
				}
				if(true === call_user_func_array($item['callback'], $args))
				{
					// 事件返回true时不继续执行其余事件
					return true;
				}
			}
			return false;
		}
		return true;
	}
237307
private function _runHooks($hooks)
    {
        extract($this->_exports);
        
        foreach ($hooks as $__hook) {
            if (is_string($__hook)) {
                eval($__hook);
            } elseif (is_callable($__hook)) {
                call_user_func($__hook, $this, get_defined_vars());
            } else {
                throw new \RuntimeException(sprintf('Hooks must be closures or strings of PHP code. Got [%s].', gettype($__hook)));
            }
            
            // hooks may set locals
            extract($this->_exports);
        }
        
        return get_defined_vars();
    }