services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false

  TYPO3\CMS\ContentBlocks\:
    resource: '../Classes/*'

  TYPO3\CMS\ContentBlocks\UserFunction\:
    resource: '../Classes/UserFunction/*'
    public: true

  TYPO3\CMS\ContentBlocks\Cache\InitializeContentBlockCache:
    public: true

  TYPO3\CMS\ContentBlocks\DataHandler\ClearBackendPreviewCaches:
    public: true

# @todo change to BeforeTcaOverridesEvent for v13
  TYPO3\CMS\ContentBlocks\Generator\TcaGenerator:
    public: true
#    tags:
#      - name: event.listener
#        identifier: 'content-blocks-tca'
#        event: TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent

  TYPO3\CMS\ContentBlocks\Generator\SqlGenerator:
    public: true
    tags:
      - name: event.listener
        identifier: 'content-blocks-sql'
        event: TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent

  TYPO3\CMS\ContentBlocks\Backend\Preview\PreviewRenderer:
    public: true
    arguments:
      $cache: '@cache.content_blocks_preview'

  TYPO3\CMS\ContentBlocks\Backend\Preview\PageLayout:
    arguments:
      $cache: '@cache.content_blocks_preview'
    tags:
      - name: 'event.listener'
        identifier: 'content-blocks-page-preview'
        event: 'TYPO3\CMS\Backend\Controller\Event\ModifyPageLayoutContentEvent'

  TYPO3\CMS\ContentBlocks\DataProcessing\ContentBlocksDataProcessor:
    autoconfigure: false
    public: true
    tags:
      - { name: 'data.processor', identifier: 'content-blocks' }

  cache.content_blocks_yaml:
    class: TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
    factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
    arguments: ['content_blocks_yaml']
    lazy: true
    public: true

  cache.content_blocks_object:
    class: TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
    factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
    arguments: ['content_blocks_object']
    lazy: true
    public: true

  cache.content_blocks_code:
    class: TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
    factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
    arguments: ['content_blocks_code']
    public: true

  cache.content_blocks_preview:
    class: TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
    factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
    arguments: ['content_blocks_preview']
    public: true

  TYPO3\CMS\ContentBlocks\Basics\BasicsLoader:
    arguments:
      $cache: '@cache.content_blocks_yaml'

  TYPO3\CMS\ContentBlocks\Basics\BasicsRegistry:
    factory:
      - '@TYPO3\CMS\ContentBlocks\Basics\BasicsLoader'
      - 'load'
    # Set to "shared: false" so that lazy cache can be properly warmed up.
    # todo Better use core caches?
    shared: false

  TYPO3\CMS\ContentBlocks\Loader\ContentBlockLoader:
    arguments:
      $cache: '@cache.content_blocks_yaml'

  TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry:
    public: true
    factory:
      - '@TYPO3\CMS\ContentBlocks\Loader\ContentBlockLoader'
      - 'load'
    # Set to "shared: false" so that lazy cache can be properly warmed up.
    # todo Better use core caches?
    shared: false

  TYPO3\CMS\ContentBlocks\Definition\Factory\TableDefinitionCollectionFactory:
    arguments:
      $cache: '@cache.content_blocks_object'

  TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection:
    public: true
    # Set to "shared: false" so that lazy cache can be properly warmed up.
    # todo Better use core caches?
    shared: false
    factory:
      - '@TYPO3\CMS\ContentBlocks\Definition\Factory\TableDefinitionCollectionFactory'
      - 'create'
    arguments:
     - '@TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry'
     - '@TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry'
     - '@TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory'

  TYPO3\CMS\ContentBlocks\Registry\AutomaticLanguageKeysRegistry:
    factory:
      - '@TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection'
      - 'getAutomaticLanguageKeysRegistry'

  TYPO3\CMS\ContentBlocks\Registry\LanguageFileRegistry:
    factory:
      - '@TYPO3\CMS\ContentBlocks\Registry\LanguageFileRegistryFactory'
      - 'create'

  TYPO3\CMS\ContentBlocks\Command\CreateContentBlockCommand:
    tags:
      - name: 'console.command'
        command: 'content-blocks:create'
        description: 'Create a Content Block'
        schedulable: false
      - name: 'console.command'
        command: 'make:content-block'
        schedulable: false

  TYPO3\CMS\ContentBlocks\Command\ListContentBlocksCommand:
    tags:
      - name: 'console.command'
        command: 'content-blocks:list'
        description: 'List available Content Blocks'
        schedulable: false

  TYPO3\CMS\ContentBlocks\Command\GenerateLanguageFileCommand:
    tags:
      - name: 'console.command'
        command: 'content-blocks:language:generate'
        description: 'Update Labels.xlf for the given Content Block'
        schedulable: false
