
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

    # Subscriber Interface, default is DoctrineEncryptSubscriber but it can be overriden in the app config
    Ideev\EncryptBundle\Subscribers\DoctrineEncryptSubscriberInterface:
        class: '%ideev_encrypt.subscriber_class%'
        arguments:
            $annotationArray: '%ideev_encrypt.annotation_classes%'
            $isDisabled: '%ideev_encrypt.is_disabled%'
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    # Subscriber to catch any encrypt or decrypt events thrown
    Ideev\EncryptBundle\Subscribers\EncryptEventSubscriber:
        arguments:
            $isDisabled: '%ideev_encrypt.is_disabled%'
        tags:
            - { name: kernel.event_subscriber, connection: default }

    # Factory to create the encryptor/decryptor
    Ideev\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
    Ideev\EncryptBundle\Encryptors\EncryptorInterface:
        factory: ['@Ideev\EncryptBundle\Encryptors\EncryptorFactory','createService']
        arguments:
            $encryptKey: '%ideev_encrypt.encrypt_key%'

    # Encrypt Twig extension that defins the decrypt filter.
    Ideev\EncryptBundle\Twig\EncryptExtension:
        tags: ['twig.extension']

    # CLI command to encrypt or decrypt all fields in a database
    Ideev\EncryptBundle\Command\EncryptDatabaseCommand:
        arguments:
            $annotationArray: '%ideev_encrypt.annotation_classes%'

    # CLI command to generate a 256 bit encryption key
    Ideev\EncryptBundle\Command\GenKeyCommand:
        tags:
            -  { name: console.command }
