Execute action hook.

@param string $action → action hook to execute

@uses \Eliasis\Complement\Traits\ComplementAction::setAction()
@uses \Eliasis\Complement\Traits\ComplementHandler::getOption()

@return bool
353618
public function doAction($action)
    {
        $controller = $this->getOption('hooks-controller');
        $instance = $this->getControllerInstance($controller);

        if (is_object($instance) && method_exists($instance, $action)) {
            $response = call_user_func([$instance, $action]);
        }

        $this->setAction('');

        return isset($response);
    }
491559
protected function action($action)
    {
        $action = in_array($action, $this->actions) ? $action : null;
        $action = array_key_exists($action, $this->aliases) ? $this->aliases[$action] : $action;

        return $action;
    }
998090
public function hasAction($action)
    {
        if ($action == 'index') {
            return true;
        }

        // Don't allow access to any non-public methods (inspect instance plus all extensions)
        $insts = array_merge([$this], (array) $this->getExtensionInstances());
        foreach ($insts as $inst) {
            if (!method_exists($inst, $action)) {
                continue;
            }
            $r = new ReflectionClass(get_class($inst));
            $m = $r->getMethod($action);
            if (!$m || !$m->isPublic()) {
                return false;
            }
        }

        $action  = strtolower($action);
        $actions = $this->allowedActions();

        // Check if the action is defined in the allowed actions of any ancestry class
        // as either a key or value. Note that if the action is numeric, then keys are not
        // searched for actions to prevent actual array keys being recognised as actions.
        if (is_array($actions)) {
            $isKey   = !is_numeric($action) && array_key_exists($action, $actions);
            $isValue = in_array($action, $actions, true);
            if ($isKey || $isValue) {
                return true;
            }
        }

        $actionsWithoutExtra = $this->config()->get('allowed_actions', true);
        if (!is_array($actions) || !$actionsWithoutExtra) {
            if (!in_array(strtolower($action), ['run', 'doinit']) && method_exists($this, $action)) {
                return true;
            }
        }

        return false;
    }
770136
public function doAction($hook)
    {
        $hook = (string) $hook;
        if (empty($this->hooks[$hook])) {
            return; // No hooks.
        }
        $hook_actions = $this->hooks[$hook];
        $args         = func_get_args();
        ksort($hook_actions);

        foreach ($hook_actions as $_hook_action) {
            foreach ($_hook_action as $_action) {
                if (!isset($_action['function'], $_action['accepted_args'])) {
                    continue; // Not a valid filter in this case.
                }
                call_user_func_array($_action['function'], array_slice($args, 1, $_action['accepted_args']));
            }
        }
        unset($_hook_action, $_action); // Housekeeping.
    }
936285
protected function executeCliAction(Config\Action $action) : void
    {
        // since the cli has no straight way to communicate back to php
        // cli hooks have to handle sync stuff by them self
        // so no 'beforeAction' or 'afterAction' is called here
        $runner = new Action\Cli();
        $runner->execute($this->io, $action, $this->arguments);
    }
1148725
public function setAction($action) {
        if (empty($action)) {
            throw new \Exception("Action cannot be empty", 0, null); //todo: create error code
        } else if (!is_string($action)) {
            throw new \Exception("Action must be a string", 0, null); //todo: create error code
        } else {
            $this->action = $action;
        }
    }
1277118
protected function runAction($action)
    {
        $dir = getcwd();
        chdir($this->getVendorDir());
        foreach ($this->managers as $m) {
            if ($m->hasDependencies()) {
                $m->runAction($action);
            }
        }
        chdir($dir);
    }
140299
public function hasAction($action) {
    if (!parent::hasAction($action)) {
      if (
        ($this->hasMethod($action.'GET')) || ($this->hasMethod($action.'POST')) || ($this->hasMethod($action.'DELETE')) || ($this->hasMethod($action.'PUT')) || ($this->hasMethod($action.'PATCH'))
      ) {
        return true;
      }
    }
    return parent::hasAction($action);
  }
923326
public function handle(string $action = null)
    {
        if (!$action)
        {
            $action = $this->request()->getAttribute($this->attribute);
        }

        if ($action === null)
        {
            throw new Path('Action `' . $this->attribute . '` name not found!');
        }

        if (!method_exists($this, $action))
        {
            throw new Runtime('Action `' . $action . '` not found');
        }

        $data = $this->$action(...$this->arguments());

        if (is_object($data) && $data instanceof Dispatcher)
        {
            return $data;
        }

        if (is_string($data) && class_exists($data))
        {
            return new $data($this->factory, $this, $this->cookies);
        }

        return $this->processing($data);
    }
7650
public function execute($actions)
	{
		foreach ($actions as $func => $args)
		{
			if ( ! $this->$func($args))
				return FALSE;
		}

		return TRUE;
	}
738516
protected function actionReferencesController($action)
    {
        if ($action instanceof Closure) {
            return false;
        }

        return is_string($action) || is_string(array_get($action, 'uses'));
    }
875572
protected function _runFunction($action)
    {
        $controller = $this->_current['controller'];

        $path = $controller . '.' . $action . '.function';

        $function = Hash::get(self::$_data, $path);

        $this->_selected['action'] = $action;

        if ($function) {
            $function($this, $this->Controller);
        }
    }
1318316
public function setAction($action) {
        $this->setVariable(self::ACTION, $this->assembleAssignmentString(self::DATA_HREF, $action));
        $this->setEventType(self::CLICK_EVENT);
        $this->addClass(self::AJAX_ELEMENT_CLASS);
        if(!$this->getId()) {
            $this->setId("button_".floor(rand(0, 1000)));
        }
    }
1053818
public function callAction ($action = FALSE)
	{
		
		// Set the request type
		
		$this->setRequestType ();
		
		// Set arguments
		
		$this->setArguments ();
		
		// Set the return type
		
		$this->setReturnType ();
		
		// Call action
		
		$this->Action ($action);
		
	}
325982
protected function executeOnError($action)
    {
        $action .= 'OnError';
        if ($this->isCallable($this, $action)) {
            $event_name = $this->getModule()->getName().'.'.$this->getName().'.'.$action;
            $result = $this->getEventManager()->dispatchBefore($event_name, $this);

            if ($result !== false) {
                $result = $this->{$action}();
            }

            if ($result !== false) {
                $result = $this->getEventManager()->dispatchAfter($event_name, $this);
            }

            $result = ($result !== false) ? true : $result;
            return $result;
        }
        
        return null;
    }
370170
protected function _execute($action, $params = array())
    {
        $methodName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $action))));
        $args = array();

        try {
            $method = new ReflectionMethod($this, $methodName);
            if (!$method->isPublic()) {
                return false;
            }
            
            // building method parameters using request params
            foreach ($method->getParameters() as $param) {
                if (array_key_exists($param->getName(), $params)) {
                    $args[] = $params[$param->getName()];
                } else if (!$param->isOptional()) {
                    throw new AtomikException("Missing parameter '" . $param->getName() . "' in '" .
                        get_class($this) . "::$methodName()'");
                } else {
                    $args[] = $param->getDefaultValue();
                }
            }
            
        } catch (ReflectionException $e) {
            // do not stop if __call() exist, so it allows us to trap method calls
            if (!method_exists($this, '__call')) {
                return false;
            }
        }
        
        $className = substr(get_class($this), 0, -10);
        $className = trim(substr($className, strlen(trim(Plugin::$config['namespace'], '\\'))), '\\');
        $view = trim(str_replace('\\', '/', strtolower($className)) . "/$action", '/');
        $this->_setView($view);

        return call_user_func_array(array($this, $methodName), $args);
    }
897840
public function setAction($action)
	{
		if (!in_array($action, self::$validActions))
		{
			// @codeCoverageIgnoreStart
			throw new \LogicException('Action has to be one of the following: %s', implode(', ', self::$validActions));
			// @codeCoverageIgnoreEnd
		}
		$this->action = $action;

		return $this;
	}