예제 #1
0
 /**
  * Calls the specified action method and passes the arguments.
  *
  * If the action returns a string, it is appended to the content in the
  * response object. If the action doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  * @api
  */
 protected function callActionMethod()
 {
     if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) {
         // enabled since Extbase 1.4.0.
         $preparedArguments = array();
         foreach ($this->arguments as $argument) {
             $preparedArguments[] = $argument->getValue();
         }
         $validationResult = $this->arguments->getValidationResults();
         if (!$validationResult->hasErrors()) {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         } else {
             $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
             $ignoreValidationAnnotations = array();
             if (isset($methodTagsValues['ignorevalidation'])) {
                 $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation'];
             }
             // if there exist errors which are not ignored with @ignorevalidation => call error method
             // else => call action method
             $shouldCallActionMethod = TRUE;
             foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
                 if (!$subValidationResult->hasErrors()) {
                     continue;
                 }
                 if (array_search('$' . $argumentName, $ignoreValidationAnnotations) !== FALSE) {
                     continue;
                 }
                 $shouldCallActionMethod = FALSE;
                 break;
             }
             if ($shouldCallActionMethod) {
                 $this->emitBeforeCallActionMethodSignal($preparedArguments);
                 $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
             } else {
                 $actionResult = call_user_func(array($this, $this->errorMethodName));
             }
         }
     } else {
         // @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1
         $preparedArguments = array();
         foreach ($this->arguments as $argument) {
             $preparedArguments[] = $argument->getValue();
         }
         if ($this->argumentsMappingResults->hasErrors()) {
             $actionResult = call_user_func(array($this, $this->errorMethodName));
         } else {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         }
     }
     if ($actionResult === NULL && $this->view instanceof ViewInterface) {
         $this->response->appendContent($this->view->render());
     } elseif (is_string($actionResult) && strlen($actionResult) > 0) {
         $this->response->appendContent($actionResult);
     } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
         $this->response->appendContent((string) $actionResult);
     }
 }
예제 #2
0
 /**
  * Renders the content preview of a content element.
  *
  * The initial item content is passed as a reference like in the core's
  * PageLayoutViewDrawItemHookInterface. The implementation has to modify
  * the content.
  *
  * @param PageLayoutView $parentObject Calling parent object
  * @param string $itemContent Item content
  * @param array $row Record row of tt_content
  *
  * @return void
  */
 public function renderContent(PageLayoutView &$parentObject, &$itemContent, array &$row)
 {
     $this->view->assign('section', 'itemContent');
     $this->view->assign('uid', $row['uid']);
     $this->view->assign('code', $row['bodytext']);
     $this->view->assign('label', $row['subheader']);
     $itemContent .= $this->view->render();
 }
 /**
  * Renders the content preview of a content element.
  *
  * The initial item content is passed as a reference like in the core's
  * PageLayoutViewDrawItemHookInterface. The implementation has to modify
  * the content.
  *
  * @param PageLayoutView $parentObject Calling parent object
  * @param string $itemContent Item content
  * @param array $row Record row of tt_content
  *
  * @return void
  */
 public function renderContent(PageLayoutView &$parentObject, &$itemContent, array &$row)
 {
     $this->view->assign('section', 'itemContent');
     $pageType = Type::fromString($this->getFlexformValue($row['pi_flexform'], 'settings.pageType'));
     $offset = (int) $this->getFlexformValue($row['pi_flexform'], 'settings.offset');
     $limit = (int) $this->getFlexformValue($row['pi_flexform'], 'settings.limit');
     $this->view->assign('typeLabelReference', $this->getPageTypeLabelReference($pageType));
     $this->view->assign('offset', $offset);
     $this->view->assign('limit', $limit);
     $pages = $this->pageRepository->findLastUpdated($pageType, $offset - 1, $limit);
     $this->view->assign('pages', $pages);
     $itemContent .= $this->view->render();
 }
예제 #4
0
 /**
  * Calls the specified action method and passes the arguments.
  *
  * If the action returns a string, it is appended to the content in the
  * response object. If the action doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  * @api
  */
 protected function callActionMethod()
 {
     $preparedArguments = array();
     /** @var \TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument */
     foreach ($this->arguments as $argument) {
         $preparedArguments[] = $argument->getValue();
     }
     $validationResult = $this->arguments->getValidationResults();
     if (!$validationResult->hasErrors()) {
         $this->emitBeforeCallActionMethodSignal($preparedArguments);
         $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
     } else {
         $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
         $ignoreValidationAnnotations = array();
         if (isset($methodTagsValues['ignorevalidation'])) {
             $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation'];
         }
         // if there exist errors which are not ignored with @ignorevalidation => call error method
         // else => call action method
         $shouldCallActionMethod = true;
         foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
             if (!$subValidationResult->hasErrors()) {
                 continue;
             }
             if (array_search('$' . $argumentName, $ignoreValidationAnnotations) !== false) {
                 continue;
             }
             $shouldCallActionMethod = false;
             break;
         }
         if ($shouldCallActionMethod) {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         } else {
             $actionResult = call_user_func(array($this, $this->errorMethodName));
         }
     }
     if ($actionResult === null && $this->view instanceof ViewInterface) {
         $this->response->appendContent($this->view->render());
     } elseif (is_string($actionResult) && $actionResult !== '') {
         $this->response->appendContent($actionResult);
     } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
         $this->response->appendContent((string) $actionResult);
     }
 }
예제 #5
0
 /**
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @throws \Exception
  * @return string
  */
 protected function renderView(ViewInterface $view)
 {
     try {
         $content = $view->render();
     } catch (\Exception $error) {
         if (!$this->arguments['graceful']) {
             throw $error;
         }
         $content = $error->getMessage() . ' (' . $error->getCode() . ')';
     }
     return $content;
 }