parameters:
    dizda.cloudbackup.google_drive.timeout: 100

services:
    dizda.cloudbackup.manager.database:
        class: Dizda\CloudBackupBundle\Manager\DatabaseManager
        arguments:
          - '@logger'

    dizda.cloudbackup.manager.client:
        class: Dizda\CloudBackupBundle\Manager\ClientManager
        arguments:
          - '@logger'

    dizda.local_filesystem:
        class: Symfony\Component\Filesystem\Filesystem

    dizda.cloudbackup.client.cloudapp:
        class: Dizda\CloudBackupBundle\Client\CloudAppClient
        arguments:
            - '%dizda_cloud_backup.cloud_storages%'
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.dropbox:
        class: Dizda\CloudBackupBundle\Client\DropboxClient
        arguments:
            - '%dizda_cloud_backup.cloud_storages%'
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.local:
        class: Dizda\CloudBackupBundle\Client\LocalClient
        arguments:
            - '%dizda_cloud_backup.cloud_storages%'
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.dropbox_sdk:
        class: Dizda\CloudBackupBundle\Client\DropboxSdkClient
        arguments:
            - '%dizda_cloud_backup.cloud_storages%'
            - '%dizda_cloud_backup.restore_folder%'
            - '@dizda.local_filesystem'
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.google_drive:
        class: Dizda\CloudBackupBundle\Client\GoogleDriveClient
        public: false
        arguments: [~, ~, ~, '%dizda.cloudbackup.google_drive.timeout%']
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.gaufrette:
        class: Dizda\CloudBackupBundle\Client\GaufretteClient
        arguments:
            - '%dizda_cloud_backup.restore_folder%'
            - '@dizda.local_filesystem'
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.client.flysystem:
        class: Dizda\CloudBackupBundle\Client\FlysystemClient
        tags:
            -  { name: dizda.cloudbackup.client }

    dizda.cloudbackup.database.mongodb:
        class: Dizda\CloudBackupBundle\Database\MongoDB
        arguments:
            - '%dizda_cloud_backup.databases%'
            - '%dizda_cloud_backup.output_folder%'
        calls:
            - [ setTimeout, [ '%dizda_cloud_backup.timeout%' ] ]
        tags:
            -  { name: dizda.cloudbackup.database }

    dizda.cloudbackup.database.mysql:
        class: Dizda\CloudBackupBundle\Database\MySQL
        arguments:
            - '%dizda_cloud_backup.databases%'
            - '%dizda_cloud_backup.output_folder%'
            - '%dizda_cloud_backup.restore_folder%'
        calls:
            - [ setTimeout, [ '%dizda_cloud_backup.timeout%' ] ]
        tags:
            -  { name: dizda.cloudbackup.database }

    dizda.cloudbackup.database.postgresql:
        class: Dizda\CloudBackupBundle\Database\PostgreSQL
        arguments:
            - '%dizda_cloud_backup.databases%'
            - '%dizda_cloud_backup.output_folder%'
        calls:
            - [ setTimeout, [ '%dizda_cloud_backup.timeout%' ] ]
        tags:
            -  { name: dizda.cloudbackup.database }

    dizda.cloudbackup.processor.tar:
        class: Dizda\CloudBackupBundle\Processor\TarProcessor
        tags:
            -  { name: dizda.cloudbackup.processor }

    dizda.cloudbackup.processor.zip:
        class: Dizda\CloudBackupBundle\Processor\ZipProcessor
        tags:
            -  { name: dizda.cloudbackup.processor }

    dizda.cloudbackup.processor.7z:
        class: Dizda\CloudBackupBundle\Processor\SevenZipProcessor
        tags:
            -  { name: dizda.cloudbackup.processor }

    dizda.cloudbackup.splitter.zip:
        class: Dizda\CloudBackupBundle\Splitter\ZipSplitSplitter
        arguments: [~]

    # Managers
    dizda.cloudbackup.manager.backup:
        class: Dizda\CloudBackupBundle\Manager\BackupManager
        arguments:
            - '@logger'
            - '@dizda.cloudbackup.manager.database'
            - '@dizda.cloudbackup.manager.client'
            - '@dizda.cloudbackup.manager.processor'
            - '@event_dispatcher'

    dizda.cloudbackup.manager.restore:
        class: Dizda\CloudBackupBundle\Manager\RestoreManager
        arguments:
            - '@dizda.cloudbackup.manager.database'
            - '@dizda.cloudbackup.manager.client'
            - '@dizda.cloudbackup.manager.processor'
            - '@event_dispatcher'
            - '%dizda_cloud_backup.restore_folder%'
            - '@dizda.cloudbackup.filesystem'
            - '%dizda_cloud_backup.restore%'

    dizda.cloudbackup.manager.processor:
        class: Dizda\CloudBackupBundle\Manager\ProcessorManager
        arguments:
            - '%dizda_cloud_backup.root_folder%'
            - '%dizda_cloud_backup.output_folder%'
            - '%dizda_cloud_backup.output_file_prefix%'
            - '%dizda_cloud_backup.processor%'
            - '%dizda_cloud_backup.folders%'
            - '%dizda_cloud_backup.restore_folder%'

    dizda.cloudbackup.filesystem:
        class: Symfony\Component\Filesystem\Filesystem

    dizda.cloudbackup.listener.log_restore_completed:
        class: Dizda\CloudBackupBundle\Listener\LogRestoreCompletedListener
        arguments:
            - '@logger'
        tags:
            - { name: kernel.event_listener, event: dizda.cloudbackup.restore_completed, method: whenRestoreIsCompleted }

    dizda.cloudbackup.listener.log_restore_failed:
        class: Dizda\CloudBackupBundle\Listener\LogRestoreFailedListener
        arguments:
            - '@logger'
        tags:
            - { name: kernel.event_listener, event: dizda.cloudbackup.restore_failed, method: whenRestoreIsFailed }

    dizda.cloudbackup.listener.clean_restore_workspace:
        class: Dizda\CloudBackupBundle\Listener\CleanRestoreWorkspaceListener
        arguments:
            - '%dizda_cloud_backup.restore_folder%'
            - '@dizda.cloudbackup.filesystem'
        tags:
            - { name: kernel.event_listener, event: dizda.cloudbackup.restore_completed, method: whenRestoreIsCompleted }
            - { name: kernel.event_listener, event: dizda.cloudbackup.restore_failed, method: whenRestoreIsFailed }

    dizda.cloudbackup.command.restore:
        class: Dizda\CloudBackupBundle\Command\RestoreCommand
        arguments:
            - '%dizda_cloud_backup.restore%'
            - '@dizda.cloudbackup.manager.restore'
        tags:
            - { name: console.command }
