Define hook.

@param null|mixed $args
@return void
174872
public function listen($args = null)
    {
        if ('action' === $this->getModel()->getType()) {
            return do_action($this->getModel()->getIdentifier(), $args);
        }

        return apply_filters($this->getModel()->getIdentifier(), $args);
    }
864418
public function evaluateArgs(array $args) : void
    {
        array_shift($args);

        if (count($args) < 2) {
            $this->out->red("Not enough arguments: expects 2, got ".(count($args) - 1).".");
            return;
        }

        $this->setName($args[0]);
        $this->setLocation($args[1]);
        if (isset($args[2])) {
            $this->additionalArgs(array_slice($args, 2, count($args)));
        }

        return;
    }
1240341
public function update( array $args ) {

		switch ( current_filter() ) {
			case 'phpmailer_init' :
				return $this->on_mailer_init( $args );
			case 'wp_mail_failed' :
				return $this->on_mail_failed( $args );
		}

		return new NullLog();
	}
1367330
protected function setupArguments($args) {
    $this->upload_path = (isset($args['base_dir']) ? $args['base_dir'] : $this->public_path . $this->upload_uri);
    $this->class = (isset($args['class']) ? $args['class'] : NULL);
    $this->alt = isset($args['alt']) ? $args['alt'] : $this->parseAlt();
    $this->title = isset($args['title']) ? $args['title'] : $this->parseTitle();
  }
198093
public function fill($args)
    {
        foreach (get_object_vars($this) as $key => $value) {
            foreach ($args as $argKey => $argValue) {
                if ($key == $argKey || $key == $argKey . "Name") {
                    $this->$key = $argValue;
                }
            }
        }
    }
657278
public function run(array $args = null)
    {
        global $argv;

        if (isset($argv[1]) && $argv[1] == 'autocomplete' && !isset($argv[2])) {
            $this->setBanner(
                function () {
                    return 0;
                }
            );
            $this->setFooter(
                function () {
                    return 0;
                }
            );
        }

        return parent::run($args);
    }
624969
public function applyHook($name, $hookArg = null)
    {
        if (!isset($this->hooks[$name])) {
            $this->hooks[$name] = array(array());
        }
        if (!empty($this->hooks[$name])) {
            // Sort by priority, low to high, if there's more than one priority
            if (count($this->hooks[$name]) > 1) {
                ksort($this->hooks[$name]);
            }
            foreach ($this->hooks[$name] as $priority) {
                if (!empty($priority)) {
                    foreach ($priority as $callable) {
                        call_user_func($callable, $hookArg);
                    }
                }
            }
        }
    }
974742
public function call($args = [])
    {
        if (count($args) == 0 || empty($args[2]))
            throw new NoticeException('Command "'.$this->key.'": Expecting an object to create (model|view|controller).');

        $object = explode(':', $args[2]);

        switch ($object[0]) {
            case 'view':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": View key name is missing.');
                $this->createView($object[1], $args);
                break;
            case 'controller':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Controller definition is missing.');
                $controller = explode('@', $object[1]);
                $this->createController($controller[0], $args);
                // Create method
                if (count($controller) > 1)
                    $this->createControllerMethod($controller[0], $controller[1]);
                break;
            case 'model':
            case 'postmodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1]);
                // Add type
                if (isset($args[3]))
                    $this->createModelProperty($object[1], 'type', $args[3]);
                break;
            case 'optionmodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'OptionModel');
                // Add id
                $this->createModelProperty($object[1], 'id', isset($args[3]) ? $args[3] : uniqid());
                break;
            case 'usermodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'UserModel');
                break;
            case 'categorymodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'CategoryModel');
                break;
        }
    }
703071
public function addError(...$args) {
        $args = func_get_args();
        if(func_num_args()>2){
            foreach ($args as $error) {
                array_push($this->errors, $error);
            }
        } else {
            if(func_get_args()==1) {
                $this->errors[] = $args[0];
            } else {
                $this->errors[$args[0]] = $args[1];
            }
        }
    }
246469
public function addArguments($arguments = [])
    {
        if (null !== $arguments) {
            foreach ($arguments as $argument) {
                $this->setArgument($argument);
            }
        }
    }
1268774
def call_hook(self, hook, *args, **kwargs):
        
        for function in self.hooks[hook]:
            function.__call__(*args, **kwargs)
449458
public static function call($hookName, $args = array(), $alternativePath = NULL) {
        $hookImplementer = self::hasImplementer($hookName);

        if (!empty($hookImplementer)) {
            $implementerClass = '\\Hooks\\' . $hookImplementer;
            $implementer = new $implementerClass();
            $implementer->$hookName($args);
        } else {
            $defaultImplementer = self::hasDefaultImplementer($hookName, $alternativePath);
           
            if ($defaultImplementer) {
                return $defaultImplementer::$hookName($args);
            } else {
                throw new \Exception(_message(ExceptionMessages::UNDECLARED_HOOK_NAME, $hookName));
            }
        }
    }
714700
public function handle(array $args = [])
    {
        // remove source file name from argv
        $source = array_shift($args);

        /** @var ConsoleEvent $applicationEvent */
        $applicationEvent = $this->getApplicationEvent();
        $applicationEvent->setName(self::EVENT_REQUEST_RECEIVED);
        $applicationEvent->setSourceFile($source);
        $applicationEvent->setArguments($args);
        $this->emit($applicationEvent);

        // init dispatcher
        $dispatcher = new Dispatcher($this->commands, $this->container);

        $middlewareRunner = new MiddlewareRunner($this->getMiddlewares());

        $middlewareRunner->run([$applicationEvent->getArguments()], function ($args) use ($applicationEvent, $dispatcher) {
            // dispatch command with args from cli
            $dispatcher->dispatch($args);
        });
    }
45076
public function handleAdd(Args $args)
    {
        $flags = $args->isOptionSet('force')
            ? DiscoveryManager::OVERRIDE | DiscoveryManager::IGNORE_TYPE_NOT_FOUND
                | DiscoveryManager::IGNORE_TYPE_NOT_ENABLED
            : 0;

        $bindingParams = array();
        $artifact = $args->getArgument('artifact');

        $this->parseParams($args, $bindingParams);

        if (false !== strpos($artifact, '\\') || $args->isOptionSet('class')) {
            $binding = new ClassBinding(
                $artifact,
                $args->getArgument('type'),
                $bindingParams
            );
        } else {
            $binding = new ResourceBinding(
                Path::makeAbsolute($artifact, $this->currentPath),
                $args->getArgument('type'),
                $bindingParams,
                $args->getOption('language')
            );
        }

        $this->discoveryManager->addRootBindingDescriptor(new BindingDescriptor($binding), $flags);

        return 0;
    }
696209
public function call($hookId = '', $args = null)
    {
        if(!$this->enabled || !isset($this->hooks[$hookId])) {
            return false;
        }

        // 执行钩子列表中的钩子
        foreach ($this->hooks[$hookId] as $hook) {
            $this->callDetail($hook, $args);
        }
        
        return true;
    }
1220580
public function prependArg($arg)
    {
        Assertion::string($arg);
        $this->args = $this->args->prepend($arg);
    }
1305549
public function handle(array $args)
    {
        $this->filter->add('themosis_admin_global', function ($data) use ($args) {
            if (! isset($data['metabox'])) {
                $data['metabox'] = [$this->id];
            } elseif (isset($data['metabox'])) {
                $data['metabox'][] = $this->id;
            }

            /*
             * Provides WP_Post data.
             */
            $data['post'] = $args['post'];

            return $data;
        });
    }