| 
services:
    ## default configuration for services in *this* file
    _defaults:
        # automatically injects dependencies in your services
        autowire: true
        # automatically registers your services as commands, event subscribers, etc.
        autoconfigure: true
        # this means you cannot fetch services directly from the container via $container->get()
        # if you need to do this, you can override this setting on individual services
        public: false
    ## Annotation reader service
    Doctrine\Common\Annotations\AnnotationReader:
        
    ## Listeners Interface, default is DoctrineEncryptListener but it can be overriden in the app config
    PSolutions\EncryptBundle\Listeners\DoctrineEncryptListenerInterface:
        class: '%psolutions_encrypt.listener_class%'
        arguments:
            $annotationArray: '%psolutions_encrypt.annotation_classes%'
            $isDisabled: '%psolutions_encrypt.is_disabled%'
        tags:
            - { name: doctrine.event_listener, event: 'onFlush', connection: default }
            - { name: doctrine.event_listener, event: 'postLoad', connection: default }
            - { name: doctrine.event_listener, event: 'postUpdate', connection: default }
    ## Subscriber to catch any encrypt or decrypt events thrown
    PSolutions\EncryptBundle\Listeners\EncryptEventListener:
        arguments:
            $isDisabled: '%psolutions_encrypt.is_disabled%'
        tags:
            - { name: kernel.event_listener, event: 'encrypt', connection: default }
            - { name: kernel.event_listener, event: 'decrypt', connection: default }
    ## Factory to create the encryptor/decryptor
    PSolutions\EncryptBundle\Encryptors\EncryptorFactory:
        arguments: ['@event_dispatcher']
        tags:
            - { name: monolog.logger, channel: app }
    ## The encryptor service created by the factory according to the passed method and using the encrypt_key
    PSolutions\EncryptBundle\Encryptors\EncryptorInterface:
        factory: ['@PSolutions\EncryptBundle\Encryptors\EncryptorFactory','createService']
        arguments:
            $encryptKey: '%psolutions_encrypt.encrypt_key%'
    # Encrypt Twig extension that defins the decrypt filter.
    PSolutions\EncryptBundle\Twig\EncryptExtension:
        tags: ['twig.extension']
    ## CLI command to encrypt or decrypt all fields in a database
    PSolutions\EncryptBundle\Command\EncryptDatabaseCommand:
        arguments:
            $annotationArray: '%psolutions_encrypt.annotation_classes%'
    ## CLI command to generate a 256 bit encryption key
    PSolutions\EncryptBundle\Command\GenKeyCommand:
        tags:
            -  { name: console.command }
 |