class ConfigurationContentDimensionPresetSource implements ContentDimensionPresetSourceInterface (View source)

A Dimension Preset Source that gets presets from settings

Everything is configured in Settings.yaml in path "Neos.ContentRepository.contentDimensions".

Properties

protected array $configuration

Dimension presets configuration indexed by dimension name, see ContentDimensionPresetSourceInterface

Methods

array
getAllPresets()

Get the full presets configuration as an array

array
getDefaultPreset(string $dimensionName)

Get the default preset of a dimension

array
findPresetByDimensionValues(string $dimensionName, array $dimensionValues)

Find a dimension preset by dimension values

array
getAllowedDimensionPresetsAccordingToPreselection(string $dimensionName, array $preselectedDimensionPresets)

Returns a list of presets of the specified dimension which are allowed in combination with the given presets of other dimensions.

bool
isPresetCombinationAllowedByConstraints(array $dimensionsNamesAndPresetIdentifiers)

Checks if the given combination of presets is allowed, according to possibly defined constraints in the content dimension configuration.

bool
isPresetAllowedByConstraints(string $dimensionName, string $presetIdentifier, array $constraints)

Checks if the given preset of the specified dimension is allowed according to the given constraints

void
setConfiguration(array $configuration)

No description

array
findPresetsByTargetValues(array $targetValues)

Finds for each configured dimension the best matching preset based on given target value for that dimension.

array
comparePresetsForTargetValue(array $possibleBetterPreset, array $targetValues, array $currentBestPreset = null)

Compares the given $possibleBetterPreset to the $targetValues (based on the position of the contained values) and returns either $possibleBetterPreset or the $currentBestPreset, depending on the result.

Details

array getAllPresets()

Get the full presets configuration as an array

Example:

'language': defaultPreset: 'all' label: 'Language' icon: 'icon-language' presets: 'all': label: 'All languages' values: ['mul_ZZ'] uriSegment: 'intl' 'de_DE': label: 'Deutsch (Deutschland)' values: ['de_DE', 'de_ZZ', 'mul_ZZ'] uriSegment: 'deutsch'

Return Value

array

Presets configuration, indexed by dimension identifier

array getDefaultPreset(string $dimensionName)

Get the default preset of a dimension

Parameters

string $dimensionName

The dimension name where the default preset should be returned

Return Value

array

The preset configuration, including the identifier as key "identifier"

array findPresetByDimensionValues(string $dimensionName, array $dimensionValues)

Find a dimension preset by dimension values

Parameters

string $dimensionName
array $dimensionValues

Return Value

array

The preset configuration, including the identifier as key "identifier" or NULL if none was found

array getAllowedDimensionPresetsAccordingToPreselection(string $dimensionName, array $preselectedDimensionPresets)

Returns a list of presets of the specified dimension which are allowed in combination with the given presets of other dimensions.

Parameters

string $dimensionName

Name of the dimension to return presets for

array $preselectedDimensionPresets

An array of dimension name and preset identifier specifying the presets which are already selected

Return Value

array

An array of presets only for the dimension specified in $dimensionName. Structure is: array($dimensionName => array('presets' => array(...))

bool isPresetCombinationAllowedByConstraints(array $dimensionsNamesAndPresetIdentifiers)

Checks if the given combination of presets is allowed, according to possibly defined constraints in the content dimension configuration.

Parameters

array $dimensionsNamesAndPresetIdentifiers

Preset pairs, for example array('language' => 'de', 'country' => 'GER', 'persona' => 'clueless')

Return Value

bool

protected bool isPresetAllowedByConstraints(string $dimensionName, string $presetIdentifier, array $constraints)

Checks if the given preset of the specified dimension is allowed according to the given constraints

Parameters

string $dimensionName

Name of the dimension the preset belongs to

string $presetIdentifier

Identifier of the preset to check

array $constraints

Constraints to use for the check

Return Value

bool

void setConfiguration(array $configuration)

No description

Parameters

array $configuration

Return Value

void

Exceptions

Exception

array findPresetsByTargetValues(array $targetValues)

Finds for each configured dimension the best matching preset based on given target value for that dimension.

The $targetValues array should have the dimension as key and the target value (single value) as value.

Parameters

array $targetValues

Return Value

array

protected array comparePresetsForTargetValue(array $possibleBetterPreset, array $targetValues, array $currentBestPreset = null)

Compares the given $possibleBetterPreset to the $targetValues (based on the position of the contained values) and returns either $possibleBetterPreset or the $currentBestPreset, depending on the result.

Parameters

array $possibleBetterPreset
array $targetValues
array $currentBestPreset

Return Value

array