<?xml version="1.0" encoding="UTF-8" ?>

<config xmlns="http://thelia.net/schema/dic/config"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">

    <parameters>
        <parameter key="router.request_context.class">Symfony\Component\Routing\RequestContext</parameter>
        <parameter key="router.null_generator.class">Thelia\Routing\NullUrlGenerator</parameter>
        <parameter key="router.dynamicRouter.class">Symfony\Cmf\Component\Routing\DynamicRouter</parameter>
        <parameter key="router.chainRouter.class">Symfony\Cmf\Component\Routing\ChainRouter</parameter>
        <parameter key="router.class">Symfony\Component\Routing\Router</parameter>
        <parameter key="router.xmlFileName">routing.xml</parameter>
    </parameters>

    <services>
        <service id="thelia.listener.view" class="Thelia\Core\EventListener\ViewListener">
            <tag name="kernel.event_subscriber"/>
            <argument type="service" id="service_container"/>
        </service>

        <service id="controller.default" class="Thelia\Controller\DefaultController"/>

        <service id="thelia.admin.base_controller" class="Thelia\Admin\Controller\BaseAdminController" scope="request">
       		<argument type="service" id="thelia.parser"/>
        </service>


        <service id="request.context" class="%router.request_context.class%" />


        <service id="router.fileLocator" class="Symfony\Component\Config\FileLocator">
            <argument>%thelia.core_dir%/Config/Resources/routing</argument>
        </service>

        <service id="router.xmlLoader" class="Symfony\Component\Routing\Loader\XmlFileLoader">
            <argument type="service" id="router.fileLocator"/>
        </service>

        <service id="router.module.fileLocator" class="Symfony\Component\Config\FileLocator">
            <argument>%thelia.module_dir%</argument>
        </service>

        <service id="router.module.xmlLoader" class="Symfony\Component\Routing\Loader\XmlFileLoader">
            <argument type="service" id="router.module.fileLocator"/>
        </service>

        <service id="router.admin" class="%router.class%">
            <argument type="service" id="router.xmlLoader"/>
            <argument>admin.xml</argument>
            <argument type="collection">
                <argument key="cache_dir">%kernel.cache_dir%</argument>
                <argument key="debug">%kernel.debug%</argument>
            </argument>
            <argument type="service" id="request.context"/>
            <tag name="router.register" priority="0"/>
        </service>

        <service id="router.front" class="%router.class%">
            <argument type="service" id="router.xmlLoader"/>
            <argument>front.xml</argument>
            <argument type="collection">
                <argument key="cache_dir">%kernel.cache_dir%</argument>
                <argument key="debug">%kernel.debug%</argument>
            </argument>
            <argument type="service" id="request.context"/>
            <tag name="router.register" priority="128"/>
        </service>

        <service id="router.rewrite" class="Thelia\Core\Routing\RewritingRouter">
            <tag name="router.register" priority="255"/>
        </service>

        <service id="router.chainRequest" class="%router.chainRouter.class%">
            <call method="setContext">
                <argument type="service" id="request.context"/>
            </call>
        </service>

        <service id="listener.router" class="Symfony\Component\HttpKernel\EventListener\RouterListener">
            <tag name="kernel.event_subscriber"/>
            <argument type="service" id="router.chainRequest"/>
        </service>
    </services>

</config>
