Neos\Flow\Mvc\ViewConfigurationManager::getViewConfiguration PHP Метод

getViewConfiguration() публичный Метод

Possible options are currently the viewObjectName to specify a different class that will be used to create the view and an array of options that will be set on the view object.
public getViewConfiguration ( ActionRequest $request ) : array
$request ActionRequest
Результат array
    public function getViewConfiguration(ActionRequest $request)
    {
        $cacheIdentifier = $this->createCacheIdentifier($request);
        $viewConfiguration = $this->cache->get($cacheIdentifier);
        if ($viewConfiguration === false) {
            $configurations = $this->configurationManager->getConfiguration('Views');
            $requestMatcher = new RequestMatcher($request);
            $context = new Context($requestMatcher);
            $viewConfiguration = [];
            $highestWeight = -1;
            foreach ($configurations as $order => $configuration) {
                $requestMatcher->resetWeight();
                if (!isset($configuration['requestFilter'])) {
                    $weight = $order;
                } else {
                    $result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
                    if ($result === false) {
                        continue;
                    }
                    $weight = $requestMatcher->getWeight() + $order;
                }
                if ($weight > $highestWeight) {
                    $viewConfiguration = $configuration;
                    $highestWeight = $weight;
                }
            }
            $this->cache->set($cacheIdentifier, $viewConfiguration);
        }
        return $viewConfiguration;
    }

Usage Example

 /**
  * @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);
 }
All Usage Examples Of Neos\Flow\Mvc\ViewConfigurationManager::getViewConfiguration