src/Menu/MenuModulesInterpreter.php
protected function normalizeConfiguredPresence($configured)
    {
        if ($configured instanceof MenuPresenceInterface) {
            $configured->setChildren($this->normalizeConfiguredPresence($configured->children()));
            $this->markExplicitKeysForMenuPresence($configured);
            return [ $configured ];
        }

        if ( ! is_array($configured)) {
            throw new UnexpectedValueException('Menu presence definition must be an array');
        }

        // Normalize if top layer is a presence definition, instead of an array of presences
        if ($this->isArrayPresenceDefinition($configured)) {
            $configured = [ $configured ];
        }

        foreach ($configured as &$value) {

            if ($value instanceof MenuPresenceInterface) {
                $value->setChildren($this->normalizeConfiguredPresence($value->children()));
                $this->markExplicitKeysForMenuPresence($value);
                continue;
            }

            if (false === $value) {
                $value = [ 'mode' => MenuPresenceMode::DELETE ];
            }

            if ( ! is_array($value)) {
                throw new UnexpectedValueException('Menu presence definition must be an array');
            }

            // Set the keys that were explicitly defined, to enable specific overrides only
            $keys = array_keys($value);

            if (array_key_exists('children', $value)) {
                $value['children'] = $this->normalizeConfiguredPresence($value['children']);
            }

            $value = new MenuPresence($value);
            $value->setExplicitKeys($keys);
        }

        unset ($value);

        return $configured;
    }
protected function normalizeConfiguredPresence($configured)
    {
        if ($configured instanceof MenuPresenceInterface) {
            $configured->setChildren($this->normalizeConfiguredPresence($configured->children()));
            $this->markExplicitKeysForMenuPresence($configured);
            return [ $configured ];
        }

        if ( ! is_array($configured)) {
            throw new UnexpectedValueException('Menu presence definition must be an array');
        }

        // Normalize if top layer is a presence definition, instead of an array of presences
        if ($this->isArrayPresenceDefinition($configured)) {
            $configured = [ $configured ];
        }

        foreach ($configured as &$value) {

            if ($value instanceof MenuPresenceInterface) {
                $value->setChildren($this->normalizeConfiguredPresence($value->children()));
                $this->markExplicitKeysForMenuPresence($value);
                continue;
            }

            if (false === $value) {
                $value = [ 'mode' => MenuPresenceMode::DELETE ];
            }

            if ( ! is_array($value)) {
                throw new UnexpectedValueException('Menu presence definition must be an array');
            }

            // Set the keys that were explicitly defined, to enable specific overrides only
            $keys = array_keys($value);

            if (array_key_exists('children', $value)) {
                $value['children'] = $this->normalizeConfiguredPresence($value['children']);
            }

            $value = new MenuPresence($value);
            $value->setExplicitKeys($keys);
        }

        unset ($value);

        return $configured;
    }
protected function normalizeConfiguredPresence ( $ configured ) { if ( $ configured instanceof MenuPresenceInterface ) { $ configured -> setChildren ( $ this -> normalizeConfiguredPresence ( $ configured -> children ( ) ) ) ; $ this -> markExplicitKeysForMenuPresence ( $ configured ) ; return [ $ configured ] ; } if ( ! is_array ( $ configured ) ) { throw new UnexpectedValueException ( 'Menu presence definition must be an array' ) ; } // Normalize if top layer is a presence definition, instead of an array of presences if ( $ this -> isArrayPresenceDefinition ( $ configured ) ) { $ configured = [ $ configured ] ; } foreach ( $ configured as & $ value ) { if ( $ value instanceof MenuPresenceInterface ) { $ value -> setChildren ( $ this -> normalizeConfiguredPresence ( $ value -> children ( ) ) ) ; $ this -> markExplicitKeysForMenuPresence ( $ value ) ; continue ; } if ( false === $ value ) { $ value = [ 'mode' => MenuPresenceMode :: DELETE ] ; } if ( ! is_array ( $ value ) ) { throw new UnexpectedValueException ( 'Menu presence definition must be an array' ) ; } // Set the keys that were explicitly defined, to enable specific overrides only $ keys = array_keys ( $ value ) ; if ( array_key_exists ( 'children' , $ value ) ) { $ value [ 'children' ] = $ this -> normalizeConfiguredPresence ( $ value [ 'children' ] ) ; } $ value = new MenuPresence ( $ value ) ; $ value -> setExplicitKeys ( $ keys ) ; } unset ( $ value ) ; return $ configured ; }
Normalizes configured menu presence definitions.

@param mixed $configured
@return false|MenuPresenceInterface[]
Normalizes configured menu presence definitions .