/** * Matches if the currently-selected preset in the passed $dimensionName is one of $presets. * * 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. * * @param string $dimensionName * @param string|array $presets * @return 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); }