diff --git a/core/lib/Thelia/Config/Resources/routing.xml b/core/lib/Thelia/Config/Resources/routing.xml index 3c887ebe5..1a6ab0752 100755 --- a/core/lib/Thelia/Config/Resources/routing.xml +++ b/core/lib/Thelia/Config/Resources/routing.xml @@ -13,11 +13,6 @@ routing.xml - - - - - @@ -35,30 +30,40 @@ - %kernel.cache_dir% + %thelia.core_dir%/Config/Resources/routing - + + - %router.xmlFileName% + admin.xml %kernel.cache_dir% %kernel.debug% + + + + + + front.xml + + %kernel.cache_dir% + %kernel.debug% + + + - - - diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php index 0aad541a5..9c8b8fedf 100755 --- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php +++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php @@ -59,6 +59,7 @@ class TheliaBundle extends Bundle $container ->addCompilerPass(new RegisterListenersPass()) ->addCompilerPass(new RegisterParserPluginPass()) + ->addCompilerPass(new RegisterRouterPass()) ; } diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/CollectionXmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRouterPass.php similarity index 59% rename from core/lib/Thelia/Core/DependencyInjection/Loader/CollectionXmlFileLoader.php rename to core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRouterPass.php index 4ae318e9b..40cfc043c 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/CollectionXmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRouterPass.php @@ -20,49 +20,43 @@ /* along with this program. If not, see . */ /* */ /*************************************************************************************/ -namespace Thelia\Core\DependencyInjection\Loader; +namespace Thelia\Core\DependencyInjection\Compiler; -class CollectionXmlFileLoader { +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Reference; - protected $files = array(); - protected $cacheDir; - protected $outputName; +class RegisterRouterPass implements CompilerPassInterface +{ - public function __construct($cacheDir, $outputName, array $files = array()) + /** + * You can modify the container here before it is dumped to PHP code. + * + * @param ContainerBuilder $container + * + * @api + */ + public function process(ContainerBuilder $container) { - $this->cacheDir = $cacheDir; - $this->outputName = $outputName; - $this->files = $files; - } - - public function addFile($file) - { - $this->files[] = $file; - } - - public function process() - { - $pattern = ''; - - $outputPattern = << - - - %s - -EOF; - $imports = array(); - foreach ($this->files as $file) { - $imports[] = sprintf($pattern, $file); + try { + $chainRouter = $container->getDefinition("router.chainRequest"); + } catch(InvalidArgumentException $e) { + return; } + foreach ($container->findTaggedServiceIds("router.register") as $id => $attributes) { + $priority = isset($attributes[0]["priority"]) ? $attributes[0]["priority"] : 0; + $router = $container->getDefinition($id); - $output = sprintf($outputPattern, implode($imports)); - file_put_contents($this->cacheDir .'/'. $this->outputName, $output); + $router->addMethodCall("setOption", array("matcher_cache_class", $container::camelize("ProjectUrlMatcher".$id))); + $chainRouter->addMethodCall("add", array(new Reference($id), $priority)); + + + + } } - } \ No newline at end of file diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index c76362b80..a95e7d668 100755 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -65,8 +65,6 @@ class XmlFileLoader extends FileLoader $this->parseForms($xml); - $this->parseRouting($xml); - $this->parseDefinitions($xml, $path); } @@ -168,30 +166,6 @@ class XmlFileLoader extends FileLoader $this->container->setParameter("Thelia.parser.filters", $filterConfig); } - /** - * parse routing properties - * - * @param SimpleXMLElement $xml - */ - protected function parseRouting(SimpleXMLElement $xml) - { - if (false === $routing = $xml->xpath("//config:routing/config:file")) { - return; - } - - try { - $routingConfig = $this->container->getParameter("thelia.routing.files"); - } catch (ParameterNotFoundException $e) { - $routingConfig = array(); - } - - foreach ($routing as $file) { - $routingConfig[] = $file->getAttributeAsPhp("path"); - } - - $this->container->setParameter("thelia.routing.files", $routingConfig); - } - /** * parse BaseParams property * diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 1832bdfe1..238c0df3b 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -150,14 +150,6 @@ class Thelia extends Kernel $this->loadConfiguration($container); $container->customCompile(); - $collectionFileLoader = new CollectionXmlFileLoader( - $container->getParameter("kernel.cache_dir"), - $container->getParameter("router.xmlFileName"), - $container->getParameter("thelia.routing.files") - ); - - $collectionFileLoader->process(); - return $container; }