Exemplo n.º 1
0
 /**
  * @test
  */
 public function ifNoTypoScriptViewIsFoundThenFallbackViewIsExecuted()
 {
     $view = $this->buildView('Foo\\Bar\\Controller\\TestController', 'nonExisting');
     $this->mockFallbackView->expects($this->once())->method('render')->will($this->returnValue('FallbackView called'));
     $this->mockFallbackView->expects($this->once())->method('setControllerContext')->with($this->mockControllerContext);
     $this->assertEquals('FallbackView called', $view->render());
 }
Exemplo n.º 2
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
  */
 protected function callActionMethod()
 {
     $preparedArguments = [];
     foreach ($this->arguments as $argument) {
         $preparedArguments[] = $argument->getValue();
     }
     $validationResult = $this->arguments->getValidationResults();
     if (!$validationResult->hasErrors()) {
         $actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
     } else {
         $actionIgnoredArguments = static::getActionIgnoredValidationArguments($this->objectManager);
         if (isset($actionIgnoredArguments[$this->actionMethodName])) {
             $ignoredArguments = $actionIgnoredArguments[$this->actionMethodName];
         } else {
             $ignoredArguments = [];
         }
         // if there exists more errors than in ignoreValidationAnnotations => call error method
         // else => call action method
         $shouldCallActionMethod = true;
         /** @var Result $subValidationResult */
         foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
             if (!$subValidationResult->hasErrors()) {
                 continue;
             }
             if (isset($ignoredArguments[$argumentName]) && $subValidationResult->getErrors(TargetNotFoundError::class) === []) {
                 continue;
             }
             $shouldCallActionMethod = false;
             break;
         }
         if ($shouldCallActionMethod) {
             $actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
         } else {
             $actionResult = call_user_func([$this, $this->errorMethodName]);
         }
     }
     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);
     }
 }
 /**
  * @param ViewInterface $view
  * @return void
  */
 public function initializeView(ViewInterface $view)
 {
     $view->assign('asyncThumbnails', $this->asyncThumbnails);
 }
 /**
  * @param ViewInterface $view
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     /** @var TemplateView $view */
     $view->setOption('templateRootPathPattern', '@packageResourcesPath/Private/');
     parent::initializeView($view);
 }
 /**
  * Initialize and render the fallback view
  *
  * @return string
  */
 public function renderFallbackView()
 {
     $this->fallbackView->setControllerContext($this->controllerContext);
     $this->fallbackView->assignMultiple($this->variables);
     return $this->fallbackView->render();
 }
 /**
  * @param ViewInterface $view
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     $view->assign('moduleConfiguration', $this->moduleConfiguration);
 }
 /**
  * Set common variables on the view
  *
  * @param ViewInterface $view
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     $view->assignMultiple(array('view' => $this->browserState->get('view'), 'sortBy' => $this->browserState->get('sortBy'), 'sortDirection' => $this->browserState->get('sortDirection'), 'filter' => $this->browserState->get('filter'), 'activeTag' => $this->browserState->get('activeTag'), 'activeAssetCollection' => $this->browserState->get('activeAssetCollection')));
 }