@@ -101,12 +101,31 @@ public function load(array $configs, ContainerBuilder $container)
101101
102102$ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ],$ container ,$ loader );
103103
104+ $ oldAssetsConfigured =false ;
105+ if (
106+ isset ($ config ['templating ' ])
107+ &&
108+ (
109+ count ($ config ['templating ' ]['packages ' ])
110+ ||
111+ count ($ config ['templating ' ]['assets_base_urls ' ]['http ' ])
112+ ||
113+ count ($ config ['templating ' ]['assets_base_urls ' ]['ssl ' ])
114+ )
115+ ) {
116+ $ oldAssetsConfigured =true ;
117+ }
118+
119+ if (isset ($ config ['assets ' ]) &&$ oldAssetsConfigured ) {
120+ throw new \LogicException ('You cannot use the old asset configuration with the new one. ' );
121+ }
122+
104123if (isset ($ config ['assets ' ])) {
105124$ this ->registerAssetsConfiguration ($ config ['assets ' ],$ container ,$ loader );
106125 }
107126
108127if (isset ($ config ['templating ' ])) {
109- $ this ->registerTemplatingConfiguration ($ config ['templating ' ],$ config ['ide ' ],$ container ,$ loader );
128+ $ this ->registerTemplatingConfiguration ($ config ['templating ' ],$ config ['ide ' ],$ container ,$ loader, $ oldAssetsConfigured );
110129 }
111130
112131$ this ->registerValidationConfiguration ($ config ['validation ' ],$ container ,$ loader );
@@ -459,10 +478,9 @@ private function registerRequestConfiguration(array $config, ContainerBuilder $c
459478 * @param ContainerBuilder $container A ContainerBuilder instance
460479 * @param XmlFileLoader $loader An XmlFileLoader instance
461480 */
462- private function registerTemplatingConfiguration (array $ config ,$ ide ,ContainerBuilder $ container ,XmlFileLoader $ loader )
481+ private function registerTemplatingConfiguration (array $ config ,$ ide ,ContainerBuilder $ container ,XmlFileLoader $ loader, $ oldAssetsConfigured )
463482 {
464483$ loader ->load ('templating.xml ' );
465- $ loader ->load ('templating_php.xml ' );
466484
467485$ links =array (
468486'textmate ' =>'txmt://open?url=file://%%f&line=%%l ' ,
@@ -472,12 +490,23 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
472490 );
473491
474492$ container ->setParameter ('templating.helper.code.file_link_format ' ,isset ($ links [$ ide ]) ?$ links [$ ide ] :$ ide );
475- $ container ->setParameter ('templating.helper.form.resources ' ,$ config ['form ' ]['resources ' ]);
476493$ container ->setParameter ('fragment.renderer.hinclude.global_template ' ,$ config ['hinclude_default_template ' ]);
477494
478- if ($ container ->getParameter ('kernel.debug ' )) {
479- $ loader ->load ('templating_debug.xml ' );
495+ if ($ oldAssetsConfigured ) {
496+ $ loader ->load ('old_assets.xml ' );
497+
498+ // create package definitions and add them to the assets helper
499+ $ defaultPackage =$ this ->createTemplatingPackageDefinition ($ container ,$ config ['assets_base_urls ' ]['http ' ],$ config ['assets_base_urls ' ]['ssl ' ],$ config ['assets_version ' ],$ config ['assets_version_format ' ]);
500+ $ container ->setDefinition ('templating.asset.default_package ' ,$ defaultPackage );
501+ $ namedPackages =array ();
502+ foreach ($ config ['packages ' ]as $ name =>$ package ) {
503+ $ namedPackage =$ this ->createTemplatingPackageDefinition ($ container ,$ package ['base_urls ' ]['http ' ],$ package ['base_urls ' ]['ssl ' ],$ package ['version ' ],$ package ['version_format ' ],$ name );
504+ $ container ->setDefinition ('templating.asset.package. ' .$ name ,$ namedPackage );
505+ $ namedPackages [$ name ] =new Reference ('templating.asset.package. ' .$ name );
506+ }
507+ }
480508
509+ if ($ container ->getParameter ('kernel.debug ' )) {
481510$ logger =new Reference ('logger ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE );
482511
483512$ container ->getDefinition ('templating.loader.cache ' )
@@ -486,25 +515,8 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
486515$ container ->getDefinition ('templating.loader.chain ' )
487516 ->addTag ('monolog.logger ' ,array ('channel ' =>'templating ' ))
488517 ->addMethodCall ('setLogger ' ,array ($ logger ));
489-
490- $ container ->setDefinition ('templating.engine.php ' ,$ container ->findDefinition ('debug.templating.engine.php ' ));
491- $ container ->setAlias ('debug.templating.engine.php ' ,'templating.engine.php ' );
492518 }
493519
494- // create package definitions and add them to the assets helper
495- $ defaultPackage =$ this ->createTemplatingPackageDefinition ($ container ,$ config ['assets_base_urls ' ]['http ' ],$ config ['assets_base_urls ' ]['ssl ' ],$ config ['assets_version ' ],$ config ['assets_version_format ' ]);
496- $ container ->setDefinition ('templating.asset.default_package ' ,$ defaultPackage );
497- $ namedPackages =array ();
498- foreach ($ config ['packages ' ]as $ name =>$ package ) {
499- $ namedPackage =$ this ->createTemplatingPackageDefinition ($ container ,$ package ['base_urls ' ]['http ' ],$ package ['base_urls ' ]['ssl ' ],$ package ['version ' ],$ package ['version_format ' ],$ name );
500- $ container ->setDefinition ('templating.asset.package. ' .$ name ,$ namedPackage );
501- $ namedPackages [$ name ] =new Reference ('templating.asset.package. ' .$ name );
502- }
503- $ container ->getDefinition ('templating.helper.assets ' )->setArguments (array (
504- new Reference ('templating.asset.default_package ' ),
505- $ namedPackages ,
506- ));
507-
508520if (!empty ($ config ['loaders ' ])) {
509521$ loaders =array_map (function ($ loader ) {return new Reference ($ loader ); },$ config ['loaders ' ]);
510522
@@ -534,14 +546,6 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
534546$ container ->findDefinition ('templating.locator ' )->getClass (),
535547 ));
536548
537- if (in_array ('php ' ,$ config ['engines ' ],true )) {
538- $ this ->addClassesToCompile (array (
539- 'Symfony \\Component \\Templating \\Storage \\FileStorage ' ,
540- 'Symfony \\Bundle \\FrameworkBundle \\Templating \\PhpEngine ' ,
541- 'Symfony \\Bundle \\FrameworkBundle \\Templating \\Loader \\FilesystemLoader ' ,
542- ));
543- }
544-
545549$ container ->setParameter ('templating.engines ' ,$ config ['engines ' ]);
546550$ engines =array_map (function ($ engine ) {return new Reference ('templating.engine. ' .$ engine ); },$ config ['engines ' ]);
547551
@@ -554,6 +558,33 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
554558 }
555559$ container ->setAlias ('templating ' ,'templating.engine.delegating ' );
556560 }
561+
562+ // configure the PHP engine if needed
563+ if (in_array ('php ' ,$ config ['engines ' ],true )) {
564+ $ loader ->load ('templating_php.xml ' );
565+
566+ $ container ->setParameter ('templating.helper.form.resources ' ,$ config ['form ' ]['resources ' ]);
567+
568+ if ($ container ->getParameter ('kernel.debug ' )) {
569+ $ loader ->load ('templating_debug.xml ' );
570+
571+ $ container ->setDefinition ('templating.engine.php ' ,$ container ->findDefinition ('debug.templating.engine.php ' ));
572+ $ container ->setAlias ('debug.templating.engine.php ' ,'templating.engine.php ' );
573+ }
574+
575+ if ($ oldAssetsConfigured ) {
576+ $ container ->getDefinition ('templating.helper.assets ' )->setArguments (array (
577+ new Reference ('templating.asset.default_package ' ),
578+ $ namedPackages ,
579+ ));
580+ }
581+
582+ $ this ->addClassesToCompile (array (
583+ 'Symfony \\Component \\Templating \\Storage \\FileStorage ' ,
584+ 'Symfony \\Bundle \\FrameworkBundle \\Templating \\PhpEngine ' ,
585+ 'Symfony \\Bundle \\FrameworkBundle \\Templating \\Loader \\FilesystemLoader ' ,
586+ ));
587+ }
557588 }
558589
559590/**
@@ -692,6 +723,7 @@ private function createPackageDefinition($basePath, array $baseUrls, $version, $
692723 }
693724
694725$ package =new DefinitionDecorator ('assets.url_package ' );
726+
695727return $ package
696728 ->setPublic (false )
697729 ->replaceArgument (1 ,$ baseUrls )