src/DependencyInjection/SonataPageExtension.php
public function configureTemplates(ContainerBuilder $container, array $config)
    {
        $templateManager = $container->getDefinition('sonata.page.template_manager');

        // add all templates to manager
        $definitions = [];
        foreach ($config['templates'] as $code => $info) {
            $definition = new Definition(Template::class, [
                $info['name'],
                $info['path'],
                $info['containers'],
            ]);

            $definition->setPublic(false);
            $definitions[$code] = $definition;
        }

        $templateManager->addMethodCall('setAll', [$definitions]);

        // set default template
        $templateManager->addMethodCall('setDefaultTemplateCode', [$config['default_template']]);
    }
public function configureTemplates(ContainerBuilder $container, array $config)
    {
        $templateManager = $container->getDefinition('sonata.page.template_manager');

        // add all templates to manager
        $definitions = [];
        foreach ($config['templates'] as $code => $info) {
            $definition = new Definition(Template::class, [
                $info['name'],
                $info['path'],
                $info['containers'],
            ]);

            $definition->setPublic(false);
            $definitions[$code] = $definition;
        }

        $templateManager->addMethodCall('setAll', [$definitions]);

        // set default template
        $templateManager->addMethodCall('setDefaultTemplateCode', [$config['default_template']]);
    }
public function configureTemplates ( ContainerBuilder $ container , array $ config ) { $ templateManager = $ container -> getDefinition ( 'sonata.page.template_manager' ) ; // add all templates to manager $ definitions = [ ] ; foreach ( $ config [ 'templates' ] as $ code => $ info ) { $ definition = new Definition ( Template :: class , [ $ info [ 'name' ] , $ info [ 'path' ] , $ info [ 'containers' ] , ] ) ; $ definition -> setPublic ( false ) ; $ definitions [ $ code ] = $ definition ; } $ templateManager -> addMethodCall ( 'setAll' , [ $ definitions ] ) ; // set default template $ templateManager -> addMethodCall ( 'setDefaultTemplateCode' , [ $ config [ 'default_template' ] ] ) ; }
Configure the page templates.

@param ContainerBuilder $container Container builder
@param array            $config    Array of configuration
Configure the page templates .