services:
  _instanceof:
    Contao\CoreBundle\Framework\FrameworkAwareInterface:
      calls:
      - ["setFramework", ["@contao.framework"]]

    Symfony\Component\DependencyInjection\ContainerAwareInterface:
      calls:
      - ["setContainer", ["@service_container"]]


  # GraphAPI
  mvo_contao_facebook.graph_api.reader_factory:
    class: Mvo\ContaoFacebookImport\GraphApi\GraphApiReaderFactory
    arguments:
    - '@doctrine'
    - '@logger'

  mvo_contao_facebook.graph_api.access_token_generator:
    class: Mvo\ContaoFacebookImport\GraphApi\AccessTokenGenerator


  # image scraping
  mvo_contao_facebook.image.scraper:
    class: Mvo\ContaoFacebookImport\Image\Scraper
    arguments:
    - '@contao.image.image_factory'

  mvo_contao_facebook.image.scraper_agent:
    class: Mvo\ContaoFacebookImport\Image\ScraperAgent
    arguments:
    - '@doctrine'
    - '@mvo_contao_facebook.image.scraper'
    - '@mvo_contao_facebook.graph_api.reader_factory'
    - '@logger'


  # synchronization
  mvo_contao_facebook.synchronization.scheduler:
    class: Mvo\ContaoFacebookImport\Synchronization\Scheduler
    arguments:
    - '@doctrine'
    - '@mvo_contao_facebook.image.scraper_agent'
    - '@mvo_contao_facebook.synchronization.post_synchronizer'
    - '@mvo_contao_facebook.synchronization.event_synchronizer'
    - '@logger'
    public: true

  mvo_contao_facebook.synchronization.post_synchronizer:
    class: Mvo\ContaoFacebookImport\Synchronization\PostSynchronizer
    arguments:
    - '@doctrine'
    - '@mvo_contao_facebook.graph_api.reader_factory'

  mvo_contao_facebook.synchronization.event_synchronizer:
    class: Mvo\ContaoFacebookImport\Synchronization\EventSynchronizer
    arguments:
    - '@doctrine'
    - '@mvo_contao_facebook.graph_api.reader_factory'

  mvo_contao_facebook.listener.contao_cron_listener:
    class: Mvo\ContaoFacebookImport\EventListener\ContaoCronListener
    arguments:
    - '@mvo_contao_facebook.synchronization.scheduler'
    tags:
    - { name: 'contao.cronjob', interval: 'minutely'}

  # data container
  mvo_contao_facebook.datacontainer.facebook_node:
    class: Mvo\ContaoFacebookImport\DataContainer\FacebookNode
    arguments:
    - '@doctrine'
    - '@mvo_contao_facebook.synchronization.scheduler'
    - '@mvo_contao_facebook.graph_api.access_token_generator'
    public: true

  mvo_contao_facebook.datacontainer.facebook_element:
    class: Mvo\ContaoFacebookImport\DataContainer\FacebookElement
    arguments:
    - '@doctrine'
    public: true

  # migrations
  mvo_contao_facebook.listener.database_update:
    class: Mvo\ContaoFacebookImport\EventListener\DatabaseUpdateListener
    arguments:
    - '@database_connection'
    tags:
    - { name: 'contao.hook', hook: 'sqlCompileCommands', method: 'onCompileSqlCommands'}

  # backend assets
  mvo_contao_facebook.listener.backend_assets:
    class: Mvo\ContaoFacebookImport\EventListener\BackendAssetsListener
    arguments:
    - '@contao.routing.scope_matcher'
    tags:
    - { name: 'kernel.event_listener', event: 'kernel.request'}
