private static function render($actionContext) {
        $controller = $actionContext->getController();

        // annotation and validation
        $modelState = $actionContext->getModelState();
        self::annotateAndValidateModel($modelState);

        // filters
        $actionExecutingContext = self::actionExecutingFilters($actionContext);

        if (($actionResult = $actionExecutingContext->getResult()) === null) {
            try {
                // execute action
                $actionResult = self::executeAction($actionContext);
                // filters
                $actionExecutedContext = self::actionExecutedFilters($actionContext, $actionResult);
                // set result
                $actionResult = $actionExecutedContext->getResult();
            }
            catch (\Exception $ex) {
                // set status code
                $actionContext->getHttpContext()->getResponse()->setStatusCode(500);
                // add the error to the modelState
                $modelState->addError('.', $ex);
                // filters
                $exceptionContext = self::exceptionFilters($actionContext, $ex);
                if (($actionResult = $exceptionContext->getResult()) === null) {
                    if ($exceptionContext->getExceptionHandled()) {
                        // executed filters
                        $actionExecutedContext = self::actionExecutedFilters($actionContext, $actionResult, $exceptionContext);
                        // set result
                        $actionResult = $actionExecutedContext->getResult();
                    }
                    else {
                        $actionResult = new ExceptionResult($ex);
                    }
                }
            }
        }

        if (isset($actionResult)) {
            // transformation of known types
            if (is_callable($actionResult)) {
                $actionResult = $actionResult();
            }

            if (is_scalar($actionResult)) {
                $actionResult = new ContentResult($actionResult, 'text/plain');
            }
            if ((($resultType = gettype($actionResult)) === 'object' || $resultType === 'array') && !$actionResult instanceof ActionResult) {
                $actionResult = new JsonResult($actionResult);
            }

            // make result
            if ($actionResult instanceof ViewResult || $actionResult instanceof ExceptionResult) {
                // create view data
                $viewData = $modelState->getKeyValuePair();
                $controllerViewData = InternalHelper::getPropertyValueOfParentClass($controller, 'viewData');

                if (!empty($controllerViewData)) {
                    $viewData = array_unique(array_merge($viewData, $controllerViewData), \SORT_STRING);
                }

                // create view
                $viewContext = InternalHelper::makeViewContext(
                    (!empty($actionResult->viewFile) ? $actionResult->viewFile : PHPMVC_CURRENT_VIEW_PATH),
                    $actionContext,
                    $actionResult,
                    null,
                    $viewData,
                    null,
                    null,
                    null
                );

                // get content
                $result = InternalHelper::getTopLevelViewContext($viewContext)->content;

                // render
                $response = $actionContext->getHttpContext()->getResponse();
                $response->write($result);
                $response->end();
            }
            elseif ($actionResult instanceof ActionResult) {
                // execute result with action context
                $actionResult->execute($actionContext);
            }
        }
    }
private static function render($actionContext) {
        $controller = $actionContext->getController();

        // annotation and validation
        $modelState = $actionContext->getModelState();
        self::annotateAndValidateModel($modelState);

        // filters
        $actionExecutingContext = self::actionExecutingFilters($actionContext);

        if (($actionResult = $actionExecutingContext->getResult()) === null) {
            try {
                // execute action
                $actionResult = self::executeAction($actionContext);
                // filters
                $actionExecutedContext = self::actionExecutedFilters($actionContext, $actionResult);
                // set result
                $actionResult = $actionExecutedContext->getResult();
            }
            catch (\Exception $ex) {
                // set status code
                $actionContext->getHttpContext()->getResponse()->setStatusCode(500);
                // add the error to the modelState
                $modelState->addError('.', $ex);
                // filters
                $exceptionContext = self::exceptionFilters($actionContext, $ex);
                if (($actionResult = $exceptionContext->getResult()) === null) {
                    if ($exceptionContext->getExceptionHandled()) {
                        // executed filters
                        $actionExecutedContext = self::actionExecutedFilters($actionContext, $actionResult, $exceptionContext);
                        // set result
                        $actionResult = $actionExecutedContext->getResult();
                    }
                    else {
                        $actionResult = new ExceptionResult($ex);
                    }
                }
            }
        }

        if (isset($actionResult)) {
            // transformation of known types
            if (is_callable($actionResult)) {
                $actionResult = $actionResult();
            }

            if (is_scalar($actionResult)) {
                $actionResult = new ContentResult($actionResult, 'text/plain');
            }
            if ((($resultType = gettype($actionResult)) === 'object' || $resultType === 'array') && !$actionResult instanceof ActionResult) {
                $actionResult = new JsonResult($actionResult);
            }

            // make result
            if ($actionResult instanceof ViewResult || $actionResult instanceof ExceptionResult) {
                // create view data
                $viewData = $modelState->getKeyValuePair();
                $controllerViewData = InternalHelper::getPropertyValueOfParentClass($controller, 'viewData');

                if (!empty($controllerViewData)) {
                    $viewData = array_unique(array_merge($viewData, $controllerViewData), \SORT_STRING);
                }

                // create view
                $viewContext = InternalHelper::makeViewContext(
                    (!empty($actionResult->viewFile) ? $actionResult->viewFile : PHPMVC_CURRENT_VIEW_PATH),
                    $actionContext,
                    $actionResult,
                    null,
                    $viewData,
                    null,
                    null,
                    null
                );

                // get content
                $result = InternalHelper::getTopLevelViewContext($viewContext)->content;

                // render
                $response = $actionContext->getHttpContext()->getResponse();
                $response->write($result);
                $response->end();
            }
            elseif ($actionResult instanceof ActionResult) {
                // execute result with action context
                $actionResult->execute($actionContext);
            }
        }
    }
private static function render ( $ actionContext ) { $ controller = $ actionContext -> getController ( ) ; // annotation and validation $ modelState = $ actionContext -> getModelState ( ) ; self :: annotateAndValidateModel ( $ modelState ) ; // filters $ actionExecutingContext = self :: actionExecutingFilters ( $ actionContext ) ; if ( ( $ actionResult = $ actionExecutingContext -> getResult ( ) ) === null ) { try { // execute action $ actionResult = self :: executeAction ( $ actionContext ) ; // filters $ actionExecutedContext = self :: actionExecutedFilters ( $ actionContext , $ actionResult ) ; // set result $ actionResult = $ actionExecutedContext -> getResult ( ) ; } catch ( \ Exception $ ex ) { // set status code $ actionContext -> getHttpContext ( ) -> getResponse ( ) -> setStatusCode ( 500 ) ; // add the error to the modelState $ modelState -> addError ( '.' , $ ex ) ; // filters $ exceptionContext = self :: exceptionFilters ( $ actionContext , $ ex ) ; if ( ( $ actionResult = $ exceptionContext -> getResult ( ) ) === null ) { if ( $ exceptionContext -> getExceptionHandled ( ) ) { // executed filters $ actionExecutedContext = self :: actionExecutedFilters ( $ actionContext , $ actionResult , $ exceptionContext ) ; // set result $ actionResult = $ actionExecutedContext -> getResult ( ) ; } else { $ actionResult = new ExceptionResult ( $ ex ) ; } } } } if ( isset ( $ actionResult ) ) { // transformation of known types if ( is_callable ( $ actionResult ) ) { $ actionResult = $ actionResult ( ) ; } if ( is_scalar ( $ actionResult ) ) { $ actionResult = new ContentResult ( $ actionResult , 'text/plain' ) ; } if ( ( ( $ resultType = gettype ( $ actionResult ) ) === 'object' || $ resultType === 'array' ) && ! $ actionResult instanceof ActionResult ) { $ actionResult = new JsonResult ( $ actionResult ) ; } // make result if ( $ actionResult instanceof ViewResult || $ actionResult instanceof ExceptionResult ) { // create view data $ viewData = $ modelState -> getKeyValuePair ( ) ; $ controllerViewData = InternalHelper :: getPropertyValueOfParentClass ( $ controller , 'viewData' ) ; if ( ! empty ( $ controllerViewData ) ) { $ viewData = array_unique ( array_merge ( $ viewData , $ controllerViewData ) , \ SORT_STRING ) ; } // create view $ viewContext = InternalHelper :: makeViewContext ( ( ! empty ( $ actionResult -> viewFile ) ? $ actionResult -> viewFile : PHPMVC_CURRENT_VIEW_PATH ) , $ actionContext , $ actionResult , null , $ viewData , null , null , null ) ; // get content $ result = InternalHelper :: getTopLevelViewContext ( $ viewContext ) -> content ; // render $ response = $ actionContext -> getHttpContext ( ) -> getResponse ( ) ; $ response -> write ( $ result ) ; $ response -> end ( ) ; } elseif ( $ actionResult instanceof ActionResult ) { // execute result with action context $ actionResult -> execute ( $ actionContext ) ; } } }
Generates and renders the final result.

@param ActionContext $actionContext The action context.

@return void
Generates and renders the final result .