MetaModels\DcGeneral\Events\Table\InputScreens\Subscriber::buildPaletteRestrictions PHP Method

buildPaletteRestrictions() public method

Build the data definition palettes.
public buildPaletteRestrictions ( ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent The event.
return void
    public function buildPaletteRestrictions(BuildDataDefinitionEvent $event)
    {
        if ($event->getContainer()->getName() !== 'tl_metamodel_dcasetting') {
            return;
        }
        $palettes = $event->getContainer()->getPalettesDefinition();
        $legend = null;
        foreach ($palettes->getPalettes() as $palette) {
            $condition = new PropertyValueCondition('dcatype', 'attribute');
            $legend = $this->getLegend('functions', $palette, $legend);
            $property = $this->getProperty('readonly', $legend);
            $this->addCondition($property, $condition);
            $legend = $this->getLegend('title', $palette, $legend);
            $property = $this->getProperty('attr_id', $legend);
            $this->addCondition($property, $condition);
            $condition = new PropertyValueCondition('dcatype', 'legend');
            $legend = $this->getLegend('title', $palette);
            $property = $this->getProperty('legendtitle', $legend);
            $this->addCondition($property, $condition);
            $property = $this->getProperty('legendhide', $legend);
            $this->addCondition($property, $condition);
            if (!isset($GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['metasubselectpalettes']['attr_id'])) {
                continue;
            }
            foreach ((array) $GLOBALS['TL_DCA']['tl_metamodel_dcasetting']['metasubselectpalettes']['attr_id'] as $typeName => $paletteInfo) {
                foreach ($paletteInfo as $legendName => $properties) {
                    foreach ($properties as $propertyName) {
                        $condition = new InputScreenAttributeIs($typeName);
                        $legend = $this->getLegend($legendName, $palette);
                        $property = $this->getProperty($propertyName, $legend);
                        $this->addCondition($property, $condition);
                    }
                }
            }
        }
    }