# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: 'en'
    uploads_directory: '%kernel.project_dir%/public/uploads'
    env(SHUTTERSTOCK_API_TOKEN): ''
    env(SHUTTERSTOCK_SUBSCRIPTION_ID): ''
    env(CLIENT_URL): ''
    env(EMAIL_HOST): ''
    env(EMAIL_USERNAME): ''
    env(EMAIL_PASSWORD): ''
    env(JWT_SECRET_KEY): ''
    env(JWT_PUBLIC_KEY): ''
    env(JWT_PASSPHRASE): ''
    env(SEMRUSH_API_KEY): ''
    semrush_api_key: '%env(SEMRUSH_API_KEY)%'
    moz_access_id: '%env(MOZ_ACCESS_ID)%'
    moz_secret: '%env(MOZ_SECRET)%'
    moz_expires: 300
    shutterstock_api_token: '%env(SHUTTERSTOCK_API_TOKEN)%'
    shutterstock_subscription_id: '%env(SHUTTERSTOCK_SUBSCRIPTION_ID)%'
    client_url: '%env(CLIENT_URL)%'
    mercure_url:  '%env(MERCURE_URL)%'
    mercure_jwt_secret:  '%env(MERCURE_JWT_SECRET)%'
    majestic_url: '%env(MAJESTIC_URL)%'
    majestic_api_key: '%env(MAJESTIC_API_KEY)%'
    copyscape_user: '%env(COPYSCAPE_USER)%'
    copyscape_key: '%env(COPYSCAPE_KEY)%'
    google_api_key: '%env(GOOGLE_API_KEY)%'
    statuscake_api_key: '%env(STATUSCAKE_API_KEY)%'
    statuscake_username: '%env(STATUSCAKE_USERNAME)%'
services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false       # Allows optimizing the container by removing unused services; this also means
        # fetching services directly from the container via $container->get() won't work.
        # The best practice is to be explicit about your dependencies anyway.
    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    App\Service\Liform\Extension\RemoveLargeEnumsExtension:
        tags:
            - { name: liform.extension }

    App\Service\Liform\Extension\DataListExtension:
        tags:
            - { name: liform.extension }

    App\Service\Liform\Transformer\StringTransformer:
        arguments:
            $validatorGuesser: '@liform.guesser.validator'
        tags:
            - { name: liform.transformer, form_type: string }
            - { name: liform.transformer, form_type: text }
            - { name: liform.transformer, form_type: date, widget: single_text }
            - { name: liform.transformer, form_type: datetime, widget: single_text }

    League\Flysystem\MountManager: '@oneup_flysystem.mount_manager'

    App\EventListener\StatUpdaterListener:
        arguments: [ '@service_container' ]
        tags:
            - { name: doctrine.event_listener, event: postPersist }

    App\EventListener\BroadcastListener:
        tags:
            - { name: doctrine.event_listener, event: postPersist }
            - { name: doctrine.event_listener, event: postUpdate }
            - { name: doctrine.event_listener, event: preRemove }

    App\EventSubscriber\StatCheckedSubscriber:
        tags:
            - { name: kernel.event_listener, event: event.stat_checked, method: onUpdate }

    App\EventSubscriber\KeywordPositionUpdatedSubscriber:
        tags:
            - { name: kernel.event_listener, event: event.keyword_position_updated, method: onUpdate }

    App\EventSubscriber\EmailSubscriber:
        tags:
            - { name: kernel.event_listener, event: event.email_received, method: onCreate }

    App\Service\Moz\Client:
        arguments:
            - { accessId: '%moz_access_id%', secret: '%moz_secret%', expires: '%moz_expires%', adapter: '@App\Service\Moz\Adapters\Guzzle'}

    GuzzleHttp\Client: ~

    http_client:
        class: GuzzleHttp\Client

    App\Service\Moz\Adapters\Guzzle:
        calls:
            -   method: setGuzzleClient
                arguments: ['@http_client']

    App\Service\DomainAuthorityChecker:
        arguments: ['@App\Service\Moz\Client']

    App\Service\StatsProcessor:
        arguments:
            0: '@event_dispatcher'

    App\Service\Domain\StatService:
        public: true

    App\Service\CampaignService:
        public: true

    App\Service\NegotiationService:
        public: true

    App\Service\DashboardService:
        public: true

    App\Service\ClientContactService:
        public: true

    App\Service\ContentVersionService:
        public: true

    App\Service\Campaign\LandingPageService:
        public: true

    App\Service\UserService:
        public: true
        calls:
            -   method: setUserFactory
                arguments: ['@App\Service\User\Factory']
            -   method: setTaskService
                arguments: ['@App\Service\Campaign\Tasklist\TaskService']

    App\Service\User\Factory:
        public: true

    App\Service\Campaign\Tasklist\Task\ActivityService:
        public: true

    App\Service\Campaign\Tasklist\TaskService:
        public: true

    campaign_listener:
        class: App\EntityListener\CampaignListener
        tags:
            - { name: doctrine.orm.entity_listener }

    App\Integrations\Shutterstock\Client:
        arguments:
            - { apiKey: '%shutterstock_api_token%', adapter: '@App\Integrations\Shutterstock\Adapters\Guzzle'}

    App\Integrations\Semrush\Client:
        arguments:
            - { apiKey: '%semrush_api_key%', adapter: '@App\Integrations\Semrush\Adapters\Guzzle'}

    App\Integrations\Semrush\Adapters\Guzzle:
        calls:
            -   method: setGuzzleClient
                arguments: ['@http_client']

    App\Integrations\Shutterstock\Adapters\Guzzle:
        calls:
            -   method: setGuzzleClient
                arguments: ['@http_client']

    App\EntityListener\SemrushCampaignListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\LandingPageCampaignListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\SemrushKeywordListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\NegotiationListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\RemoveProspectFromResearchListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\NegotiationMessageListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\DashboardListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\ClientContactListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\DomainListener:
        arguments: ['@http_client']
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\LinkListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\ContentListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\TokenGenerator:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\PasswordTokenListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\UserListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\ResearchListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\ContentVersionListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\StatListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\ReportListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\KeywordCheckListener:
        tags:
            -
                name: doctrine.orm.entity_listener
                event: postPersist
                entity: App\Entity\Campaign\Keyword\Check

    App\EntityListener\TaskListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\CommentTaskListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\EntityListener\TimelogListener:
        tags:
            - { name: doctrine.orm.entity_listener }

    App\Command\CrmLinkCheckCommand:
        arguments: ['@http_client']

    App\Factory\MailFactory:
        arguments: ['%client_url%']

    App\Service\MercureBroadcasterService:
        arguments: ['%mercure_url%', '%mercure_jwt_secret%']

    App\Service\BroadcasterInterface: '@App\Service\MercureBroadcasterService'

    GGGGino\WordBundle\Factory:
        alias: 'phpword'

    App\Integrations\Majestic\GuzzleReportHandler:
        arguments: ['@http_client', '%majestic_url%', '%majestic_api_key%']

    App\Integrations\Copyscape\GuzzleHandler:
        arguments: ['@http_client', '%copyscape_user%', '%copyscape_key%']

    App\Integrations\Majestic\ReportHandler: '@App\Integrations\Majestic\GuzzleReportHandler'

    App\Integrations\Google\PageSpeed\GuzzleHandler:
        arguments: ['@http_client', '%google_api_key%']

    App\Integrations\StatusCake\GuzzleHandler:
        arguments: ['%statuscake_username%', '%statuscake_api_key%']

    App\Integrations\MozApi\HttpClientFactory: ~

    App\Integrations\MozApi\Client:
        arguments: ['@App\Integrations\MozApi\HttpClientFactory', '%moz_access_id%', '%moz_secret%']
