This classes compiles all configurations matching the provided request out of the Views.yaml into one view configuration used by the ActionController to setup up the view.
 /**
  * @test
  */
 public function getViewConfigurationUsedFilterConfigurationWithHigherWeight()
 {
     $matchingConfigurationOne = ['requestFilter' => 'isPackage("Neos.Flow")', 'options' => 'a value'];
     $matchingConfigurationTwo = ['requestFilter' => 'isPackage("Neos.Flow") && isFormat("html")', 'options' => 'a value with higher weight'];
     $notMatchingConfiguration = ['requestFilter' => 'isPackage("Vendor.Package")', 'options' => 'another value'];
     $viewConfigurations = [$notMatchingConfiguration, $matchingConfigurationOne, $matchingConfigurationTwo];
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with('Views')->will($this->returnValue($viewConfigurations));
     $calculatedConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->mockActionRequest);
     $this->assertEquals($calculatedConfiguration, $matchingConfigurationTwo);
 }
示例#2
0
 /**
  * Prepares a view for the current action and stores it in $this->view.
  * By default, this method tries to locate a view with a name matching
  * the current action.
  *
  * @return ViewInterface the resolved view
  * @throws ViewNotFoundException if no view can be resolved
  */
 protected function resolveView()
 {
     $viewsConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->request);
     $viewObjectName = $this->defaultViewImplementation;
     if (!empty($this->defaultViewObjectName)) {
         $viewObjectName = $this->defaultViewObjectName;
     }
     $viewObjectName = $this->resolveViewObjectName() ?: $viewObjectName;
     if (isset($viewsConfiguration['viewObjectName'])) {
         $viewObjectName = $viewsConfiguration['viewObjectName'];
     }
     if (!is_a($viewObjectName, ViewInterface::class, true)) {
         throw new ViewNotFoundException(sprintf('View class has to implement ViewInterface but "%s" in action "%s" of controller "%s" does not.', $viewObjectName, $this->request->getControllerActionName(), get_class($this)), 1355153188);
     }
     $viewOptions = isset($viewsConfiguration['options']) ? $viewsConfiguration['options'] : [];
     $view = $viewObjectName::createWithOptions($viewOptions);
     return $view;
 }