Neos\Neos\Domain\Service\ConfigurationContentDimensionPresetSource::findPresetByUriSegment PHP Method

findPresetByUriSegment() public method

public findPresetByUriSegment ( $dimensionName, $uriSegment )
    public function findPresetByUriSegment($dimensionName, $uriSegment)
    {
        if (isset($this->configuration[$dimensionName])) {
            foreach ($this->configuration[$dimensionName]['presets'] as $presetIdentifier => $presetConfiguration) {
                if (isset($presetConfiguration['uriSegment']) && $presetConfiguration['uriSegment'] === $uriSegment) {
                    $presetConfiguration['identifier'] = $presetIdentifier;
                    return $presetConfiguration;
                }
            }
        }
        return null;
    }

Usage Example

 /**
  * @test
  */
 public function findPresetByUriSegmentWithoutExistingUriSegmentReturnsNull()
 {
     $source = new ConfigurationContentDimensionPresetSource();
     $source->setConfiguration($this->validConfiguration);
     $preset = $source->findPresetByUriSegment('language', 'english');
     $this->assertNull($preset);
 }
ConfigurationContentDimensionPresetSource