src/DependencyInjection/SonataPageExtension.php
/**
     * Configure the multi-site feature.
     *
     * @param ContainerBuilder $container Container builder
     * @param array            $config    Array of configuration
     */
Configure the multi-site feature.
@param ContainerBuilder $container Container builder
@param array            $config    Array of configuration
Configure the multi - site feature . @param ContainerBuilder $container Container builder @param array $config Array of configuration
public function configureMultisite(ContainerBuilder $container, array $config)
    {
        $multisite = $config['multisite'];
        if ('host' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host');
            $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } elseif ('host_by_locale' === $multisite) {
            $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_by_locale');
            $container->removeDefinition('sonata.page.site.selector.host');
            $container->removeDefinition('sonata.page.site.selector.host_with_path');
            $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
        } else {
            $container->setAlias('router.request_context', 'sonata.page.router.request_context');
            if ('host_with_path' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path');
                $container->removeDefinition('sonata.page.site.selector.host_with_path_by_locale');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            } elseif ('host_with_path_by_locale' === $multisite) {
                $container->setAlias('sonata.page.site.selector', 'sonata.page.site.selector.host_with_path_by_locale');
                $container->removeDefinition('sonata.page.site.selector.host_with_path');
                $container->removeDefinition('sonata.page.site.selector.host');
                $container->removeDefinition('sonata.page.site.selector.host_by_locale');
            }
        }
        if ($container->hasAlias('sonata.page.site.selector')) {
            $container->getAlias('sonata.page.site.selector')->setPublic(true);
        }
    }
public function configureMultisite ( ContainerBuilder $ container , array $ config ) { $ multisite = $ config [ 'multisite' ] ; if ( 'host' === $ multisite ) { $ container -> setAlias ( 'sonata.page.site.selector' , 'sonata.page.site.selector.host' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_by_locale' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path_by_locale' ) ; } elseif ( 'host_by_locale' === $ multisite ) { $ container -> setAlias ( 'sonata.page.site.selector' , 'sonata.page.site.selector.host_by_locale' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path_by_locale' ) ; } else { $ container -> setAlias ( 'router.request_context' , 'sonata.page.router.request_context' ) ; if ( 'host_with_path' === $ multisite ) { $ container -> setAlias ( 'sonata.page.site.selector' , 'sonata.page.site.selector.host_with_path' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path_by_locale' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_by_locale' ) ; } elseif ( 'host_with_path_by_locale' === $ multisite ) { $ container -> setAlias ( 'sonata.page.site.selector' , 'sonata.page.site.selector.host_with_path_by_locale' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_with_path' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host' ) ; $ container -> removeDefinition ( 'sonata.page.site.selector.host_by_locale' ) ; } } if ( $ container -> hasAlias ( 'sonata.page.site.selector' ) ) { $ container -> getAlias ( 'sonata.page.site.selector' ) -> setPublic ( true ) ; } }
Configure the multi-site feature.
Configure the multi - site feature .
/*
             * The multipath option required a specific router and RequestContext
             */