Makes actions state.

@param ActionContext $actionContext Action context and descriptor.

@return void
8588
private static function makeActionState($actionContext) {
        $arguments = array();
        $modelState = new ModelState();
        $modelState->annotations = $actionContext->getModelState()->annotations;
        $hasModel = false;
        $request = $actionContext->getHttpContext()->getRequest();

        // route
        $route = $actionContext->getRoute();
        $segments = $route->getSegments(true);

        // params of get http
        // TODO: подумать о возможности управлять этим
        $get = $request->get();

        // change case of keys
        $get = array_change_key_case($get, CASE_LOWER);

        // post
        $isPost = $request->isPost();

        // get params of action method
        $r = new \ReflectionMethod(get_class($actionContext->getController()), $actionContext->getActionName());

        $methodParams = $r->getParameters();

        // search for the necessary parameters
        foreach ($methodParams as $param) {
            $name = strtolower($param->getName());

            if (isset($route->values[$name])) {
                $modelState[$name] = new ModelStateEntry($name, $arguments[$name] = $route->values[$name]);
            }
            elseif (isset($get[$name])) {
                $modelState[$name] = new ModelStateEntry($name, $arguments[$name] = $get[$name]);
            }
            else {
                // parameter not found
                if ($isPost && !$hasModel && !isset($get[$name]) && !isset($segments[$name])) {
                    $postData = $request->post();
                    $paramTypeName = '\stdClass';
                    $post = null;

                    if (isset($postData) && isset($postData['__requestVerificationToken'])) {
                        unset($postData['__requestVerificationToken']);
                    }

                    if (method_exists($param, 'hasType') && $param->hasType()) {
                        if ($param->getType()->isBuiltin()) {
                            $arguments[$name] = ($param->isOptional() ? $param->getDefaultValue() : null);
                            continue;
                        }

                        if (($paramTypeName = $param->getClass()) !== null) {
                            $paramTypeName = $paramTypeName->getName();
                        }
                    }
                    else {
                        if (($paramTypeName = $param->getClass()) !== null) {
                            $paramTypeName = $paramTypeName->getName();
                        }
                    }

                    if (!empty($postData)) {
                        InternalHelper::arrayToObject($postData, $post, $paramTypeName);
                    }
                    
                    if (empty($post)) {
                        $contentType = $request->contentType();
            
                        if (strrpos($contentType, '/json') !== false) {
                            $requestBody = file_get_contents('php://input');
                            InternalHelper::arrayToObject(json_decode($requestBody, true), $post, $paramTypeName);
                        }
                        else {
                            // TODO...
                        }
                    }

                    // post method and model not yet received
                    if ($post == null) {
                        throw new \Exception('"' . $name . ' is required.');
                    }

                    $arguments[$name] = $post;

                    // parse post data
                    self::parseObjectToModelState($modelState, $post);

                    $hasModel = true;
                    continue;
                }

                if ($param->isOptional()) {
                    // is optional parameter, skip it
                    $arguments[$name] = $param->getDefaultValue();
                    continue;  
                }

                // required parameter
                // TODO: config
                // throw new \ErrorException('"'.$name.'" is required.');
                // at the moment, just add null to args
                // and skip for model state
                $arguments[$name] = null;
            }
        }

        InternalHelper::setPropertyValue($actionContext, 'arguments', $arguments);
        InternalHelper::setPropertyValue($actionContext, 'modelState', $modelState);
    }
222295
protected function initializeCreateAction(): void
    {
        $assetMappingConfiguration = $this->arguments->getArgument('asset')->getPropertyMappingConfiguration();
        $assetMappingConfiguration->allowProperties('title', 'resource', 'tags', 'assetCollections');
        $assetMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
        $assetMappingConfiguration->setTypeConverterOption(AssetInterfaceConverter::class, AssetInterfaceConverter::CONFIGURATION_ONE_PER_RESOURCE, true);
    }
1031811
public function execute($actionContext) {
        $response = $actionContext->getHttpContext()->getResponse();
        $response->addHeader('Content-Type', (!empty($this->contentType) ? $this->contentType : 'text/plain'));
        $response->write($this->content);
        $response->end();
    }
92552
public final function execute(ControllerContext $controllerContext): bool {
		$this->init($controllerContext);
		
		$request = $this->getRequest();
		$invokerFactory = new ActionInvokerFactory(
				$controllerContext->getCmdPath(), $controllerContext->getCmdContextPath(), $request,
				$request->getMethod(), $request->getQuery(), $request->getPostQuery(),
				$request->getAcceptRange(), $this->getN2nContext());
		$invokerFactory->setConstantValues($controllerContext->getParams());
		$interpreter = new ControllerInterpreter(new \ReflectionClass($this), $invokerFactory,
				new InterceptorFactory($controllerContext->getControllingPlan()->getN2nContext()));
		
		$this->resetCacheControl();
		
		if (!$this->intercept(...$interpreter->findControllerInterceptors())) {
			return true;
		}
		
		$catchedStatusException = null;
		
		try {
			$prepareInvokers = $interpreter->interpret(ControllerInterpreter::DETECT_PREPARE_METHOD);
			foreach ($prepareInvokers as $prepareInvoker) {
				$this->cu()->setInvokerInfo($prepareInvoker);
				if ($this->intercept(...$prepareInvoker->getInterceptors())) {
					$prepareInvoker->getInvoker()->invoke($this);
				} else {
					return true;
				}
			}
		
			$invokerInfos = $interpreter->interpret(ControllerInterpreter::DETECT_ALL & ~ ControllerInterpreter::DETECT_PREPARE_METHOD);
			if (!empty($invokerInfos)) {
				foreach ($invokerInfos as $invokerInfo) {
					$this->cu()->setInvokerInfo($invokerInfo);
					
					if (!$this->intercept(...$invokerInfo->getInterceptors())) continue;
					
					$invokerInfo->getInvoker()->invoke($this);
				}

				$this->cu()->reset(true);
				return true;
			}
		} catch (StatusException $e) {
			$catchedStatusException = $e;
		}
		
		if (empty($invokerInfos) || ($catchedStatusException !== null 
				&& $catchedStatusException->getStatus() == Response::STATUS_404_NOT_FOUND)) {
			try {
				$notFoundInvokers = $interpreter->interpret(ControllerInterpreter::DETECT_NOT_FOUND_METHOD);
				
				if (!empty($notFoundInvokers)) {
					foreach ($notFoundInvokers as $invokerInfo) {
						$this->cu()->setInvokerInfo($invokerInfo);
						
						if (!$this->intercept(...$invokerInfo->getInterceptors())) continue;
						
						$invokerInfo->getInvoker()->invoke($this);
						$catchedStatusException = null;
					}
					
					$this->cu()->reset(true);
					return true;
				}
			} catch (StatusException $e) {
				$catchedStatusException = $e;
			}
		}
		
		if ($catchedStatusException !== null) {
			$this->cu()->reset(false);
			throw $catchedStatusException;
		}
		
		$this->cu()->reset(true);
		return false;
	}
951020
private static function actionExecutedFilters($actionContext, $actionResult, $exceptionContext = null) {
        $context = new ActionExecutedContext($actionContext, $actionResult, $exceptionContext);

        $filters = $actionContext->getFilters();

        foreach ($filters as $filter) {
            $filter->actionExecuted($context);
        }

        return $context;
    }
155466
protected function initializeAction()
    {
        parent::initializeAction();
        $this->solrConnectionManager = GeneralUtility::makeInstance(ConnectionManager::class);
        $this->apacheSolrDocumentRepository = GeneralUtility::makeInstance(Repository::class);

    }
695046
protected function _actionSend(DispatcherContext $context)
    {
        //Send the response
        $context->response->send(false);

        //Terminate the response
        $this->terminate($context);
    }
349654
protected function _actionDispatch(AnCommandContext $context)
    {
        if (
            $this->getController()->getIdentifier()->name === 'session' &&
            $this->token != ''
        ) {
            $this->getController()->execute('tokenlogin', $context);
            $context->response->send();
            exit(0);
        }

        return parent::_actionDispatch($context);
    }
321187
public function buildAction($pipeline, $actionName, $actionConfiguration = [])
    {
        $triggeredByEvents = is_array($actionConfiguration) && array_key_exists("triggered_by_events", $actionConfiguration) ? $actionConfiguration["triggered_by_events"] : [];

        if (empty($triggeredByEvents)) {
            // default behavior : auto-wiring action to the same event name
            $triggeredByEvents = [$actionName];
        }

        // create the action and the action creator
        $action = new Action($actionName);
        $actionCreator = new ActionCreator($action);
        foreach ($triggeredByEvents as $triggeredByEvent) {
            $event = $pipeline->hasIncomingEvent($triggeredByEvent) ? $pipeline->getIncomingEvent($triggeredByEvent) : new Event($triggeredByEvent);
            $actionCreator->addTriggeredByEvent($event);
            $pipeline->addIncomingEvent($event);
        }
        $pipeline->addAction($action);
        $pipeline->addActionCreator($actionCreator);
    }
1006893
protected function _actionSend(DispatcherContext $context)
    {
        $request  = $this->getRequest();
        $response = $this->getResponse();

        //Add an Allow header to the response
        if($response->getStatusCode() === HttpResponse::METHOD_NOT_ALLOWED)
        {
            try {
                $this->_actionOptions($context);
            }
            catch (Exception $e) {}
        }

        return parent::_actionSend($context);
    }
441458
public function setCurrentAction($action): void
    {
        if (!$action instanceof Action) {
            $action = $this->getAction($action);
        }
        $this->currentAction = $action;
    }
70135
public function doAction($action,$params){
        if(method_exists($this,$action)){
            $this->$action($params);
        }
        else{
            $this->ActionNotFound($action,$params);
        }
    }
344054
public function handleAction($action, $actionParams)
    {
        $this->setView($action);
        $response = parent::handleAction($action, $actionParams);

        if ($response instanceof Response) {
            return $response;
        }

        if (is_string($response)) {
            $this->controllerView->content = $response;
        } elseif (isset($this->view)) {
            $this->controllerView->content = $this->view->render();
        }

        $this->response->setContent($this->controllerView->render());

        return $this->response;
    }
903766
public function doAction($actionName)
    {
        if (isset($this->actions[$actionName]))
            return call_user_func_array(array($this, $this->actions[$actionName]), array());
    }
384184
protected function _actionDispatch(DispatcherContext $context)
    {
        $controller = $this->getController();

        if(!$controller instanceof ControllerViewable && !$controller instanceof ControllerModellable)
        {
            $action = strtolower($context->request->query->get('_action', 'alpha'));

            //Throw exception if no action could be determined from the request
            if(!$action) {
                throw new ControllerExceptionRequestInvalid('Action not found');
            }

            $controller->execute($action, $controller->getContext($context));
        }
        else $this->execute(strtolower($context->request->getMethod()), $context);

        //Set the result in the response
        if($context->result && !$context->response->isRedirect())
        {
            $result = $context->result;

            if ($result instanceof ObjectConfigFormat) {
                $context->response->setContentType($result->getMediaType());
            }

            if (is_string($result) || (is_object($result) && method_exists($result, '__toString'))) {
                $context->response->setContent($result);
            }
        }

        //Send the response
        if (!$this->isForwarded()) {
            $this->send($context);
        }
    }
897643
protected function _actionEnable($context)
    {
        $context->response->status = AnHttpResponse::RESET_CONTENT;
        $this->getItem()->enable();

        return;
    }
1272309
def context(self):
        
        parent = _ACTION_CONTEXT.set(self)
        try:
            yield self
        finally:
            _ACTION_CONTEXT.reset(parent)