<?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="esi.class">Symfony\Component\HttpKernel\HttpCache\Esi</parameter>
        <parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
        <parameter key="fragment.renderer.esi.class">Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer</parameter>
        <parameter key="fragment.renderer.inline.class">Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer</parameter>
    </parameters>

    <services>

        <!--  URL maganement -->
        <service id="thelia.url.manager" class="Thelia\Tools\URL">
            <argument type="service" id="service_container" />
        </service>

        <service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
            <argument type="service" id="service_container" />
        </service>

        <service id="esi" class="%esi.class%" />

        <service id="esi_listener" class="%esi_listener.class%">
            <tag name="kernel.event_subscriber" />
            <argument type="service" id="esi" on-invalid="ignore" />
        </service>
        <service id="fragment.renderer.inline" class="%fragment.renderer.inline.class%">
            <argument type="service" id="http_kernel" />
        </service>

        <service id="fragment.renderer.esi" class="%fragment.renderer.esi.class%">
            <argument type="service" id="esi" />
            <argument type="service" id="fragment.renderer.inline" />
        </service>

        <!-- Tax engine -->

        <service id="thelia.taxEngine" class="Thelia\TaxEngine\TaxEngine" scope="request">
            <argument type="service" id="request" />
        </service>

		<!--
		A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
		thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
		We use it here to inject the service container in the admin base controller.
		-->
        <service id="controller_resolver" class="Thelia\Core\Controller\ControllerResolver">
        	<argument type="service" id="service_container"/>
        </service>

		<!--  Translation and internationalisation -->

		<service id="thelia.translator" class="Thelia\Core\Translation\Translator">
			<argument type="service" id="service_container"/>
		</service>

		<!-- Security context for front and back office -->

		<service id="thelia.securityContext" class="Thelia\Core\Security\SecurityContext" scope="request">
            <argument type="service" id="request" />
		</service>

		<!--  Parser context -->

        <service id="thelia.parser.context" class="Thelia\Core\Template\ParserContext" scope="request">
        	<argument type="service" id="request" />
        </service>

		<!-- Parser configuration -->

        <service id="thelia.parser" class="Thelia\Core\Template\Smarty\SmartyParser" scope="request">
            <argument type="service" id="request" />
            <argument type="service" id="event_dispatcher"/>
            <argument type="service" id="thelia.parser.context"/>
            <argument >%kernel.environment%</argument>
            <argument >%kernel.debug%</argument>
        </service>

        <service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">
            <argument type="service" id="event_dispatcher" />
            <argument type="service" id="service_container" />
            <argument type="service" id="controller_resolver" />
        </service>

        <service id="request" scope="request" synthetic="true" />

        <service id="service_container" synthetic="true" />

        <service id="kernel" synthetic="true" />


        <service id="mailer" class="Thelia\Mailer\MailerFactory">
            <argument type="service" id="event_dispatcher"/>
        </service>

        <service id="response.listener" class="Thelia\Core\EventListener\ResponseListener">
            <tag name="kernel.event_subscriber"/>
        </service>
    </services>

</config>
