services:
    _defaults:
        autowire: true
        autoconfigure: true

    Chill\MainBundle\Notification\:
        resource: ../../Notification/
        autoconfigure: true
        autowire: true

    Chill\MainBundle\Notification\Mailer:
        arguments:
            $routeParameters: '%chill_main.notifications%'

    Chill\MainBundle\Notification\NotificationHandlerManager:
        arguments:
            $handlers: !tagged_iterator chill_main.notification_handler

    Chill\MainBundle\Notification\Counter\NotificationByUserCounter:
        autoconfigure: true
        autowire: true
        tags:
            -
                name: 'doctrine.orm.entity_listener'
                event: 'preFlush'
                entity: 'Chill\MainBundle\Entity\Notification'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'onPreFlushNotification'

            -
                name: 'doctrine.orm.entity_listener'
                event: 'postUpdate'
                entity: 'Chill\MainBundle\Entity\NotificationComment'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'onEditNotificationComment'
            -
                name: 'doctrine.orm.entity_listener'
                event: 'postPersist'
                entity: 'Chill\MainBundle\Entity\NotificationComment'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'onPersistNotificationComment'

    Chill\MainBundle\Notification\Email\NotificationMailer:
        autowire: true
        autoconfigure: true
        tags:
            -
                name: 'doctrine.orm.entity_listener'
                event: 'postPersist'
                entity: 'Chill\MainBundle\Entity\Notification'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'postPersistNotification'

            -
                name: 'doctrine.orm.entity_listener'
                event: 'postUpdate'
                entity: 'Chill\MainBundle\Entity\Notification'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'postUpdateNotification'

            -
                name: 'doctrine.orm.entity_listener'
                event: 'postPersist'
                entity: 'Chill\MainBundle\Entity\NotificationComment'
                # set the 'lazy' option to TRUE to only instantiate listeners when they are used
                lazy: true
                method: 'postPersistComment'
