services:
    rawafed.cache:
        class: Doctrine\Common\Cache\ApcCache

    rawafed.string_utils:
        class: Rawafed\CommonsBundle\Service\StringUtils

    commons.user_agent:
        class: Rawafed\CommonsBundle\Service\UserAgent
        arguments: [@request_stack]

    rawafed.image_manipulator:
        class: Rawafed\CommonsBundle\Service\ImageManipulator

    metatag_manager:
        class: Rawafed\CommonsBundle\Service\MetaTagManager
        arguments: [@?opensky.runtime_config]

    linktags_manager:
        class: Rawafed\CommonsBundle\Service\LinkTagsManager

    rawafed.locale_listener:
        class: Rawafed\CommonsBundle\Service\LocaleListener
        arguments: [@doctrine.orm.entity_manager]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

    rawafed.scheduler_listener:
        class: Rawafed\CommonsBundle\Service\SchedulerListener
        arguments: ["@doctrine.orm.entity_manager", "%content_management.scheduled_publishing%"]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

    rawafed.views_count_listener:
        class: Rawafed\CommonsBundle\Service\ViewsCountListener
        arguments: [@annotation_reader, @doctrine.orm.entity_manager]
        tags:
            - { name: kernel.event_listener, event: kernel.controller, priority: -128, method: onKernelController }

    rawafed.commons.translatable_listener:
        class: Rawafed\CommonsBundle\DoctrineExtensions\TranslatableListener
        tags:
            - { name: doctrine.event_subscriber }

    rawafed.form.type.html:
        class: Rawafed\CommonsBundle\Form\Type\HtmlType
        tags:
            - { name: form.type, alias: html }

    rawafed.form.type.remote_file:
        class: Rawafed\CommonsBundle\Form\Type\RemoteFileType
        tags:
            - { name: form.type, alias: remote_file }

    rawafed.twig_utils:
        class: Rawafed\CommonsBundle\Twig\TwigUtils
        arguments: ["@service_container", "@translator", "@rawafed.string_utils", "@rawafed.image_manipulator", "@rawafed.emotions_service"]
        tags:
            - { name: twig.extension }

    rawafed.head_tags:
        class: Rawafed\CommonsBundle\Twig\HeadTagsExtension
        arguments: [@metatag_manager, @linktags_manager]
        tags:
            - { name: twig.extension }

    rawafed.twig.route_localization:
        class: Rawafed\CommonsBundle\Twig\RouteLocalizationExtension
        tags:
            - { name: twig.extension }
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
        arguments: [@router]

    gedmo.listener.softdeleteable:
        class: Gedmo\SoftDeleteable\SoftDeleteableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ @annotation_reader ] ]

    # general paginator move from admin bundle
    rawafed.commons.grid_paginator:
        class: Rawafed\CommonsBundle\Service\GridPaginator
        arguments: ["@service_container"]

    rawafed.form.type.enum_sex:
        class: Rawafed\CommonsBundle\Form\Type\EnumSexType
        tags:
            - { name: form.type, alias: EnumSex }


    ### advanced generic paramater convertor
    ### the symfony2 internaly paramConverter has an error while it is encloded in symfony2 documentation
    ### but i think it might be handled later
    rawafed.commons.advanced_param_converter:
        class: Rawafed\CommonsBundle\ParamConverter\AdvancedParamConverter
        arguments: [@service_container]
        tags:
            - { name: request.param_converter, converter: AdvancedConverter, priority: "10" }

    rawafed.emotions_service:
        class: Rawafed\CommonsBundle\Service\EmotionsService
        arguments: ["@service_container"]


    ## handling the runtime exceptions on ajax request
    rawafed.common_bundle.kernel_exception:
        class: Rawafed\CommonsBundle\Service\ExceptionListener
        tags:
            - { name: kernel.event_listener, event: kernel.exception, method: onKernelException }
        arguments: [%kernel.environment%, @translator]


    ## yml files parser with import, locate other resources
    rawafed.commons_bundle.yml_kernel_parser:
        class: Rawafed\CommonsBundle\Util\YmlKernelParser
        arguments: [ @kernel ]

    ## add form type entity_hidden (use form type 'entity' and generate hidden field)
    rawafed.form.type.entity_hidden:
       class: Rawafed\CommonsBundle\Form\Type\EntityHiddenType
       arguments: ["@doctrine.orm.entity_manager"]
       tags:
       - { name: form.type, alias: entity_hidden }