Execute the Controller resulting in its action processed. The actual
processing is delegated to the doExecute() method.
@param $method The name of the method to execute, will be passed to doExecute() (optional)
558325
public function execute($method=null) {
    $isDebugEnabled = $this->logger->isDebugEnabled();
    if ($isDebugEnabled) {
      $this->logger->debug('Executing: '.get_class($this).($method ? '::'.$method: ''));
      $this->logger->debug('Request: '.$this->request);
    }

    // validate controller data
    $validationFailed = false;
    if (!$this->validate()) {
      $validationFailed = true;
    }

    // execute controller logic
    if (!$validationFailed) {
      try {
        $this->doExecute($method);
        $this->endTransaction(true);
      }
      catch (\Exception $ex) {
        if ($ex instanceof ApplicationException) {
          $error = $ex->getError();
          $this->response->addError($error);
          $this->response->setStatus($error->getStatusCode());
        }
        else {
          $this->getLogger()->error($ex);
          $error = ApplicationError::fromException($ex);
          $this->response->addError($error);
          $this->response->setStatus($error->getStatusCode());
        }
        $this->endTransaction(false);
      }
    }

    // return the last error
    $errors = array_merge($this->request->getErrors(), $this->response->getErrors());
    if (sizeof($errors) > 0) {
      $error = array_pop($errors);
      $this->response->setValue('errorCode', $error->getCode());
      $this->response->setValue('errorMessage', $error->getMessage());
      $this->response->setValue('errorData', $error->getData());
      $this->response->setStatus($error->getStatusCode());
    }

    // log errors
    for ($i=0,$count=sizeof($errors); $i<$count; $i++) {
      $error = $errors[$i];
      $message = $error->__toString();
      switch ($error->getLevel()) {
        case ApplicationError::LEVEL_WARNING:
          $this->logger->warn($message);
          break;
        default:
          $this->logger->error($message);
      }
    }

    if ($isDebugEnabled) {
      $this->logger->debug('Response: '.$this->response);
    }
  }
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);
        }
    }
653809
private function checkMethodExists($method)
    {
        if (! $this->controllerClass->hasMethod($method)) {
            throw new MissingControllerMethodException(
                sprintf(
                    "Method %s::%s() is not defined in controller.",
                    $this->controllerClass->getShortName(),
                    $method
                )
            );
        }
    }
837657
protected function fork_me($method) {
        $this->wait_for_signal = true;
        $pid = pcntl_fork();
        switch ($pid) {
            case 0:
                $this->isparent = false;
                $this->parent_pid = $this->pid;
                $this->pid = getmypid();
                $this->$method();
                break;
            case -1:
                $this->log("Failed to fork");
                $this->stop_work = true;
                break;
            default:
                $this->log("Helper forked with pid $pid", GearmanManager::LOG_LEVEL_PROC_INFO);
                $this->helper_pid = $pid;
                while ($this->wait_for_signal && !$this->stop_work) {
                    usleep(5000);
                    pcntl_waitpid($pid, $status, WNOHANG);

                    if (pcntl_wifexited($status) && $status) {
                         $this->log("Helper child exited with non-zero exit code $status.");
                         exit(1);
                    }

                }
                break;
        }
    }
390014
protected function tryRunMethod($controller, $method)
    {
        if ($method === "options") {
            $classMethods = get_class_methods($controller);
            $classMethodsResult = ["options"];
            foreach ($classMethods as $val) {
                if (!in_array($val, array("__construct", "__distruct"))) {
                    $classMethodsResult[] = $val;
                }
            }
            $acceptMethods = strtoupper(implode(",", $classMethodsResult));
            $response = new Response("", Response::HTTP_OK);
            $response->headers->set("Allow", $acceptMethods);
            $response->headers->set("access-control-allow-methods", $acceptMethods);
            $response->send();
        } else {
            try {
                return $controller->$method();
            } catch (\RuntimeException $e) {
                throw new \Exception($e);
            }
        }
    }
642229
public function setMethod($method)
    {
        $valid_methods = array(self::METHOD_POST, self::METHOD_GET);

        if (!in_array($method, $valid_methods)) {
            throw new SwatException("‘{$method}’ is not a valid form method.");
        }

        $this->method = $method;
    }
379377
public function process_behavior($behavior, $method) {
        $behavior = Inflector::camelize($behavior);
        $model = $this->Model;

        if ($model->Behaviors->loaded($behavior) && $model->hasMethod($method)) {
            $model->Behaviors->{$behavior}->{$method}($model);

            $this->AdminToolbar->logAction(ActionLog::PROCESS, $model, '', __d('admin', 'Triggered %s.%s() process', array($behavior, $method)));
            $this->AdminToolbar->setFlashMessage(__d('admin', 'Processed %s.%s() for %s', array($behavior, $method, mb_strtolower($model->pluralName))));

        } else {
            $this->AdminToolbar->setFlashMessage(__d('admin', '%s does not allow this process', $model->singularName), 'is-error');
        }

        $this->redirect($this->referer());
    }
1141974
private function callControllerMethod(Controller $controller, $method)
    {
        return App::call([$controller, $method], ParameterBag::getParameters());
    }
435100
public function setMethod($method) {
        $methods = array(
            COMPLETION_AGGREGATION_ALL,
            COMPLETION_AGGREGATION_ANY,
        );

        if (in_array($method, $methods)) {
            $this->method = $method;
        } else {
            $this->method = COMPLETION_AGGREGATION_ALL;
        }
    }
867776
private function execute()
	{
		if ($this->currentRoute == null) {
			$this->router->getRoute('error_page')->setAction('_notFound');
			$this->toRoute('error_page');
			return;
		}
		$controllerName = $this->currentRoute->getController();
		if ($controllerName == '') {
			if ($this->currentRoute->getParams() != null && array_key_exists('controller', $this->currentRoute->getParams()))
				$controllerName = $this->currentRoute->getParams()['controller'];
			elseif ($this->currentRoute->getDefault() != null)
				$controllerName = $this->currentRoute->getDefault()->getController();
			else {
				throw new \Exception($this->translator->translate("The requested url has a bad route configuration!"));
			}
		}

		if (array_key_exists($controllerName, $this->invokable))
			$controllerName = $this->invokable[$controllerName];
		elseif (strpos($controllerName, 'decoy\base') === false)
			throw new \Exception('The requested Controller: \'' . $controllerName . '\' is not registered!');
		$c = new $controllerName($this);
		if ($c->getResult() && !in_array($c->identifier, $this->disableRender) && $this->enableRender) {
			echo $this->response->output($c);
		}
	}
807917
public function callAction($method, array $parameters = [])
    {
        $isAjax = app()->make('request')->ajax();

        $method = $this->checkAjaxMethod($method, $isAjax);
        $parameters = $this->checkParametersResolving($method, $parameters);

        return parent::callAction($method, $parameters);
    }
1168857
public function triggerMethod($method) {
		$result = null;
		// handling actual method
		if (!empty($this->wrapper_methods[$method])) {
			foreach ($this->wrapper_methods[$method] as $k => $v) {
				$result = call_user_func_array($v, [& $this]);
			}
		}
		return $result;
	}
481394
protected function doExecuteActions($method, array $actionManagers)
    {
        $actions = array('post' => array(), 'notExecuted' => array());
        $this->executeFailedActions($method);
        if (0 !== count($actionManagers)){
            $actions = $this->execute($method, $actionManagers);
            if(!empty($actions['notExecuted'])) $this->writeFailedActions('.' . $method, $actions['notExecuted']);
        }

        return $actions;
    }
535339
public static function execute($controller, $request) {   
        switch($request->method()) { 
            case 'POST':
                $data = $controller->store($request->bodyRequest());
                KernelHttp::makeResponse('201', $data);
                break;
            case 'PUT':
                $data = $controller->update($request->bodyRequest());
                KernelHttp::makeResponse('200', $data);
                break;
            case 'DELETE':
                $controller->destroy($request->getInteractionsRequest());
                KernelHttp::makeResponse('200');
                break;
            default: 
                $request->getRequiredParameter() ? $data = $controller->show($request->getInteractionsRequest()) : $data = $controller->index($request->getInteractionsRequest()); 
                KernelHttp::makeResponse('200', $data);
                break;
        } 
    }
1022934
private function assertMethodExists(string $method): void
    {
        if (!method_exists($this, $method)) {
            throw new MethodDoesNotExistException(
                sprintf("Specified method \"%s\" does not exist", $method)
            );
        }
    }
1032824
public function setPaymentMethod($method)
    {
        try {
            if ($method instanceof PagSeguroDirectPaymentMethods) {
                $this->paymentMethod = $method;
            } else {
                $this->paymentMethod = new PagSeguroDirectPaymentMethods($method);
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
1083348
private function addMethod(string $method): void
    {
        if (!HttpMethod::isValid($method)) {
            throw new \InvalidArgumentException("Invalid HTTP request method '$method'");
        }

        $this->methods[] = $method;
    }