src/Configuration/MenuConfigPass.php
private function normalizeMenuConfig(array $menuConfig, array $backendConfig, $parentItemIndex = -1)
    {
        // if the backend doesn't define the menu configuration: create a default
        // menu configuration to display all its entities
        if (empty($menuConfig)) {
            foreach ($backendConfig['entities'] as $entityName => $entityConfig) {
                $menuConfig[] = ['entity' => $entityName, 'label' => $entityConfig['label']];
            }
        }

        // replaces the short config syntax:
        //   design.menu: ['Product', 'User']
        // by the expanded config syntax:
        //   design.menu: [{ entity: 'Product' }, { entity: 'User' }]
        foreach ($menuConfig as $i => $itemConfig) {
            if (\is_string($itemConfig)) {
                $itemConfig = ['entity' => $itemConfig];
            }

            $menuConfig[$i] = $itemConfig;
        }

        foreach ($menuConfig as $i => $itemConfig) {
            // normalize icon configuration
            if (!\array_key_exists('icon', $itemConfig)) {
                $itemConfig['icon'] = ($parentItemIndex > -1) ? '' : 'fa-folder-open';
            } elseif (empty($itemConfig['icon'])) {
                $itemConfig['icon'] = null;
            } else {
                $itemConfig['icon'] = 'fa-'.$itemConfig['icon'];
            }

            // normalize css_class configuration
            if (!\array_key_exists('css_class', $itemConfig)) {
                $itemConfig['css_class'] = '';
            }

            // normalize submenu configuration (only for main menu items)
            if (-1 === $parentItemIndex && !isset($itemConfig['children'])) {
                $itemConfig['children'] = [];
            }

            // normalize 'default' option, which sets the menu item used as the backend index
            if (!\array_key_exists('default', $itemConfig)) {
                $itemConfig['default'] = false;
            } else {
                $itemConfig['default'] = (bool) $itemConfig['default'];
            }

            // normalize 'target' option, which allows to open menu items in different windows or tabs
            if (!\array_key_exists('target', $itemConfig)) {
                $itemConfig['target'] = false;
            } else {
                $itemConfig['target'] = (string) $itemConfig['target'];
            }

            // normalize 'rel' option, which adds html5 rel attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types)
            if (!\array_key_exists('rel', $itemConfig)) {
                $itemConfig['rel'] = \array_key_exists('url', $itemConfig) ? 'noreferrer' : false;
            } else {
                $itemConfig['rel'] = (string) $itemConfig['rel'];
            }

            $menuConfig[$i] = $itemConfig;
        }

        return $menuConfig;
    }
private function normalizeMenuConfig(array $menuConfig, array $backendConfig, $parentItemIndex = -1)
    {
        // if the backend doesn't define the menu configuration: create a default
        // menu configuration to display all its entities
        if (empty($menuConfig)) {
            foreach ($backendConfig['entities'] as $entityName => $entityConfig) {
                $menuConfig[] = ['entity' => $entityName, 'label' => $entityConfig['label']];
            }
        }

        // replaces the short config syntax:
        //   design.menu: ['Product', 'User']
        // by the expanded config syntax:
        //   design.menu: [{ entity: 'Product' }, { entity: 'User' }]
        foreach ($menuConfig as $i => $itemConfig) {
            if (\is_string($itemConfig)) {
                $itemConfig = ['entity' => $itemConfig];
            }

            $menuConfig[$i] = $itemConfig;
        }

        foreach ($menuConfig as $i => $itemConfig) {
            // normalize icon configuration
            if (!\array_key_exists('icon', $itemConfig)) {
                $itemConfig['icon'] = ($parentItemIndex > -1) ? '' : 'fa-folder-open';
            } elseif (empty($itemConfig['icon'])) {
                $itemConfig['icon'] = null;
            } else {
                $itemConfig['icon'] = 'fa-'.$itemConfig['icon'];
            }

            // normalize css_class configuration
            if (!\array_key_exists('css_class', $itemConfig)) {
                $itemConfig['css_class'] = '';
            }

            // normalize submenu configuration (only for main menu items)
            if (-1 === $parentItemIndex && !isset($itemConfig['children'])) {
                $itemConfig['children'] = [];
            }

            // normalize 'default' option, which sets the menu item used as the backend index
            if (!\array_key_exists('default', $itemConfig)) {
                $itemConfig['default'] = false;
            } else {
                $itemConfig['default'] = (bool) $itemConfig['default'];
            }

            // normalize 'target' option, which allows to open menu items in different windows or tabs
            if (!\array_key_exists('target', $itemConfig)) {
                $itemConfig['target'] = false;
            } else {
                $itemConfig['target'] = (string) $itemConfig['target'];
            }

            // normalize 'rel' option, which adds html5 rel attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types)
            if (!\array_key_exists('rel', $itemConfig)) {
                $itemConfig['rel'] = \array_key_exists('url', $itemConfig) ? 'noreferrer' : false;
            } else {
                $itemConfig['rel'] = (string) $itemConfig['rel'];
            }

            $menuConfig[$i] = $itemConfig;
        }

        return $menuConfig;
    }
Normalizes the different shortcut notations of the menu config to simplify
further processing.

@param array $menuConfig
@param array $backendConfig
@param int   $parentItemIndex The index of the parent item for this menu item (allows to treat submenus differently)

@return array