src/Contao/Dca/Palette/LegacyPalettesParser.php
public function parsePalettes(
        array $palettes,
        array $subPaletteProperties = [],
        array $selectorFieldNames = [],
        PaletteCollectionInterface $collection = null
    ) {
        if (!$collection) {
            $collection = new PaletteCollection();
        }

        if (isset($palettes['__selector__'])) {
            $selectorFieldNames = \array_merge($selectorFieldNames, $palettes['__selector__']);
            $selectorFieldNames = \array_unique($selectorFieldNames);
            unset($palettes['__selector__']);
        }

        foreach ($palettes as $selector => $fields) {
            // Fields list must be a string.
            if (!\is_string($fields)) {
                continue;
            }

            if ($collection->hasPaletteByName($selector)) {
                $palette = $collection->getPaletteByName($selector);
                $this->parsePalette(
                    $selector,
                    $fields,
                    $subPaletteProperties,
                    $selectorFieldNames,
                    $palette
                );

                continue;
            }

            $palette = $this->parsePalette(
                $selector,
                $fields,
                $subPaletteProperties,
                $selectorFieldNames
            );
            $collection->addPalette($palette);
        }

        return $collection;
    }
public function parsePalettes(
        array $palettes,
        array $subPaletteProperties = [],
        array $selectorFieldNames = [],
        PaletteCollectionInterface $collection = null
    ) {
        if (!$collection) {
            $collection = new PaletteCollection();
        }

        if (isset($palettes['__selector__'])) {
            $selectorFieldNames = \array_merge($selectorFieldNames, $palettes['__selector__']);
            $selectorFieldNames = \array_unique($selectorFieldNames);
            unset($palettes['__selector__']);
        }

        foreach ($palettes as $selector => $fields) {
            // Fields list must be a string.
            if (!\is_string($fields)) {
                continue;
            }

            if ($collection->hasPaletteByName($selector)) {
                $palette = $collection->getPaletteByName($selector);
                $this->parsePalette(
                    $selector,
                    $fields,
                    $subPaletteProperties,
                    $selectorFieldNames,
                    $palette
                );

                continue;
            }

            $palette = $this->parsePalette(
                $selector,
                $fields,
                $subPaletteProperties,
                $selectorFieldNames
            );
            $collection->addPalette($palette);
        }

        return $collection;
    }
public function parsePalettes ( array $ palettes , array $ subPaletteProperties = [ ] , array $ selectorFieldNames = [ ] , PaletteCollectionInterface $ collection = null ) { if ( ! $ collection ) { $ collection = new PaletteCollection ( ) ; } if ( isset ( $ palettes [ '__selector__' ] ) ) { $ selectorFieldNames = \ array_merge ( $ selectorFieldNames , $ palettes [ '__selector__' ] ) ; $ selectorFieldNames = \ array_unique ( $ selectorFieldNames ) ; unset ( $ palettes [ '__selector__' ] ) ; } foreach ( $ palettes as $ selector => $ fields ) { // Fields list must be a string. if ( ! \ is_string ( $ fields ) ) { continue ; } if ( $ collection -> hasPaletteByName ( $ selector ) ) { $ palette = $ collection -> getPaletteByName ( $ selector ) ; $ this -> parsePalette ( $ selector , $ fields , $ subPaletteProperties , $ selectorFieldNames , $ palette ) ; continue ; } $ palette = $ this -> parsePalette ( $ selector , $ fields , $ subPaletteProperties , $ selectorFieldNames ) ; $ collection -> addPalette ( $ palette ) ; } return $ collection ; }
Parse the given palettes.

@param array(string => string)    $palettes             The array of palettes, e.g.
<code>array('default' => '{title_legend},title')</code>.
@param array(string => string)    $subPaletteProperties Mapped array from subpalette [optional].
@param array                      $selectorFieldNames   List of names of the properties to be used as selector
[optional].
@param PaletteCollectionInterface $collection           The palette collection to populate [optional].

@return PaletteCollectionInterface
Parse the given palettes .