core-bundle/src/DataContainer/PaletteManipulator.php
public function addField($name, $parent, string $position = self::POSITION_AFTER, $fallback = null, $fallbackPosition = self::POSITION_APPEND): self
    {
        $this->validatePosition($position);

        if (self::POSITION_BEFORE === $fallbackPosition || self::POSITION_AFTER === $fallbackPosition) {
            throw new PalettePositionException('Fallback legend position can only be PREPEND or APPEND');
        }

        $this->fields[] = [
            'fields' => (array) $name,
            'parents' => (array) $parent,
            'position' => $position,
            'fallback' => is_scalar($fallback) ? [$fallback] : $fallback,
            'fallbackPosition' => $fallbackPosition,
        ];

        return $this;
    }
public function addField($name, $parent, string $position = self::POSITION_AFTER, $fallback = null, $fallbackPosition = self::POSITION_APPEND): self
    {
        $this->validatePosition($position);

        if (self::POSITION_BEFORE === $fallbackPosition || self::POSITION_AFTER === $fallbackPosition) {
            throw new PalettePositionException('Fallback legend position can only be PREPEND or APPEND');
        }

        $this->fields[] = [
            'fields' => (array) $name,
            'parents' => (array) $parent,
            'position' => $position,
            'fallback' => is_scalar($fallback) ? [$fallback] : $fallback,
            'fallbackPosition' => $fallbackPosition,
        ];

        return $this;
    }
public function addField ( $ name , $ parent , string $ position = self :: POSITION_AFTER , $ fallback = null , $ fallbackPosition = self :: POSITION_APPEND ) : self { $ this -> validatePosition ( $ position ) ; if ( self :: POSITION_BEFORE === $ fallbackPosition || self :: POSITION_AFTER === $ fallbackPosition ) { throw new PalettePositionException ( 'Fallback legend position can only be PREPEND or APPEND' ) ; } $ this -> fields [ ] = [ 'fields' => ( array ) $ name , 'parents' => ( array ) $ parent , 'position' => $ position , 'fallback' => is_scalar ( $ fallback ) ? [ $ fallback ] : $ fallback , 'fallbackPosition' => $ fallbackPosition , ] ; return $ this ; }
If $position is PREPEND or APPEND, pass a legend as parent; otherwise pass a field name.

@param string|array               $name
@param string|array               $parent
@param string|array|\Closure|null $fallback
@param string                     $fallbackPosition

@throws PalettePositionException
If $position is PREPEND or APPEND pass a legend as parent ; otherwise pass a field name .