Neos\ContentRepository\Security\Authorization\Privilege\Node\NodePrivilegeContext::isInDimensionPreset PHP Метод

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

Example: isInDimensionPreset('language', 'de') checks whether the currently-selected language preset (in the Neos backend) is "de". Implementation Note: We deliberately work on the Dimension Preset Name, and not on the dimension values itself; as the preset is user-visible and the actual dimension-values for a preset are just implementation details.
public isInDimensionPreset ( string $dimensionName, string | array $presets ) : boolean
$dimensionName string
$presets string | array
Результат boolean
    public function isInDimensionPreset($dimensionName, $presets)
    {
        if ($this->node === null) {
            return true;
        }
        $dimensionValues = $this->node->getContext()->getDimensions();
        if (!isset($dimensionValues[$dimensionName])) {
            return false;
        }
        $preset = $this->contentDimensionPresetSource->findPresetByDimensionValues($dimensionName, $dimensionValues[$dimensionName]);
        if ($preset === null) {
            return false;
        }
        $presetIdentifier = $preset['identifier'];
        if (!is_array($presets)) {
            $presets = array($presets);
        }
        return in_array($presetIdentifier, $presets);
    }