parameters:
  webprofiler.only_exceptions: false
  webprofiler.only_master_requests: false

services:

# profiler services
  logger.channel.webprofiler:
    class: Drupal\Core\Logger\LoggerChannel
    factory: logger.factory:get
    arguments: ['webprofiler']

  profiler.file_storage:
    class: Drupal\webprofiler\Profiler\FileProfilerStorage
    arguments: ['%data_collector.storage%']
    tags:
      - { name: webprofiler_storage, title: 'File storage' }

  profiler.database_storage:
    class: Drupal\webprofiler\Profiler\DatabaseProfilerStorage
    arguments: ['@database']
    tags:
      - { name: webprofiler_storage, title: 'Database storage' }

  profiler.storage_manager:
    class: Drupal\webprofiler\Profiler\ProfilerStorageManager

  profiler.storage:
    class: Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
    factory: Drupal\webprofiler\Profiler\ProfilerStorageFactory::getProfilerStorage
    arguments: ['@config.factory', '@service_container']

  profiler:
    class: Drupal\webprofiler\Profiler\Profiler
    arguments: ['@profiler.storage', '@logger.channel.webprofiler', '@config.factory']

# template manager
  template_manager:
    class: Drupal\webprofiler\Profiler\TemplateManager
    arguments: ['@profiler', '@twig', '@twig.loader', '%data_collector.templates%']

# request matcher
  webprofiler.matcher:
    class: Drupal\webprofiler\RequestMatcher\WebprofilerRequestMatcher
    arguments: ['@config.factory', '@path.matcher']

# event subscribers
  webprofiler.profiler_listener:
    class: Drupal\webprofiler\EventSubscriber\ProfilerSubscriber
    arguments: ['@profiler', '@request_stack', '@?webprofiler.matcher', '%webprofiler.only_exceptions%', '%webprofiler.only_master_requests%']
    tags:
      - { name: event_subscriber }

  webprofiler.webprofiler_event_subscriber:
      class: Drupal\webprofiler\EventSubscriber\WebprofilerEventSubscriber
      arguments: ['@current_user', '@url_generator', '@renderer']
      tags:
        - { name: event_subscriber }

# twig profiler
  twig.profile:
    class: Twig_Profiler_Profile

  twig.extension.profiler:
    class: Drupal\webprofiler\Twig\Extension\ProfilerExtension
    arguments: ['@twig.profile', '@stopwatch', '@webprofiler.ide_link_generator', '@webprofiler.class_shortener']
    tags:
      - { name: twig.extension, priority: 100 }

# datacollector services
  webprofiler.drupal:
    class: Drupal\webprofiler\DataCollector\DrupalDataCollector
    arguments: ['@redirect.destination', '@url_generator']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/drupal.html.twig', id: 'drupal', title: 'Drupal', priority: 10 }

  webprofiler.devel:
    class: Drupal\webprofiler\DataCollector\DevelDataCollector
    arguments: ['@menu.link_tree']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/devel.html.twig', id: 'devel', title: 'Devel', priority: 15 }

  webprofiler.php_config:
    class: Drupal\webprofiler\DataCollector\PhpConfigDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/php_config.html.twig', id: 'php_config', title: 'PHP Config', priority: 20 }

  webprofiler.request:
    class: Drupal\webprofiler\DataCollector\RequestDataCollector
    arguments: ['@controller_resolver']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/request.html.twig', id: 'request', title: 'Request', priority: 30 }
      - { name: event_subscriber }

  webprofiler.time:
    class: Drupal\webprofiler\DataCollector\TimeDataCollector
    arguments: [NULL, '@stopwatch']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/time.html.twig', id: 'time', title: 'Timeline', priority: 40 }

  webprofiler.performance_timing:
    class: Drupal\webprofiler\DataCollector\PerformanceTimingDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/performance_timing.html.twig', id: 'performance_timing', title: 'Performance Timing', priority: 50 }

  webprofiler.database:
    class: Drupal\webprofiler\DataCollector\DatabaseDataCollector
    arguments: ['@database', '@config.factory']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/database.html.twig', id: 'database', title: 'Database', priority: 60 }

  webprofiler.user:
    class: Drupal\webprofiler\DataCollector\UserDataCollector
    arguments: ['@current_user', '@entity.manager', '@config.factory', '@authentication_collector']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/user.html.twig', id: 'user', title: 'User', priority: 70 }

  webprofiler.forms:
    class: Drupal\webprofiler\DataCollector\FormsDataCollector
    arguments: ['@form_builder']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/forms.html.twig', id: 'forms', title: 'Forms', priority: 80 }

  webprofiler.drupal_extensions:
    class: Drupal\webprofiler\DataCollector\ExtensionDataCollector
    arguments: ['@module_handler', '@theme_handler', '@app.root']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/extensions.html.twig', id: 'drupal_extension', title: 'Extensions', priority: 90 }

  webprofiler.routing:
    class: Drupal\webprofiler\DataCollector\RoutingDataCollector
    arguments: ['@router.route_provider']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/routing.html.twig', id: 'routing', title: 'Routing', priority: 100 }

  webprofiler.cache:
    class: Drupal\webprofiler\DataCollector\CacheDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/cache.html.twig', id: 'cache', title: 'Cache', priority: 110 }

  webprofiler.assets:
    class: Drupal\webprofiler\DataCollector\AssetsDataCollector
    arguments: ['@app.root']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/assets.html.twig', id: 'assets', title: 'Assets', priority: 120}

  webprofiler.config:
    class: Drupal\webprofiler\DataCollector\ConfigDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/config.html.twig', id: 'config', title: 'Config', priority: 130 }

  webprofiler.state:
    class: Drupal\webprofiler\DataCollector\StateDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/state.html.twig', id: 'state', title: 'State', priority: 140 }

  webprofiler.events:
    class: Drupal\webprofiler\DataCollector\EventsDataCollector
    arguments: ['@event_dispatcher']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/events.html.twig', id: 'events', title: 'Events', priority: 150 }

  webprofiler.services:
    class: Drupal\webprofiler\DataCollector\ServicesDataCollector
    arguments: ['@service_container']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/services.html.twig', id: 'services', title: 'Services', priority: 160 }

  webprofiler.http:
    class: Drupal\webprofiler\DataCollector\HttpDataCollector
    arguments: ['@http_client_middleware.webprofiler']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/http.html.twig', id: 'http', title: 'Http', priority: 170 }

  webprofiler.theme:
    class: Drupal\webprofiler\DataCollector\ThemeDataCollector
    arguments: ['@theme.manager', '@theme.negotiator', '@twig.profile']
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/theme.html.twig', id: 'theme', title: 'Theme', priority: 180 }

  webprofiler.mail:
    class: Drupal\webprofiler\DataCollector\MailDataCollector
    tags:
      - { name: data_collector, template: '@webprofiler/Collector/mail.html.twig', id: 'mail', title: 'Mail', priority: 190 }

# debug services
  stopwatch:
    class: Drupal\webprofiler\Stopwatch

  webprofiler.debug.plugin.manager.mail.default:
    class: Drupal\Core\Mail\MailManager
    arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@config.factory', '@logger.factory', '@string_translation', '@renderer']

  webprofiler.debug.controller_resolver:
    class: Symfony\Component\HttpKernel\Controller\TraceableControllerResolver
    arguments: ['@controller_resolver', '@stopwatch']

  webprofiler.debug.cache_factory:
    class: Drupal\webprofiler\Cache\CacheFactoryWrapper
    public: false
    decorates: cache_factory
    arguments: ['@webprofiler.debug.cache_factory.inner', '@webprofiler.cache']
    properties:
      _serviceId: 'cache_factory'

  webprofiler.debug.asset.css.collection_renderer:
    class: Drupal\webprofiler\Asset\CssCollectionRendererWrapper
    public: false
    decorates: asset.css.collection_renderer
    arguments: ['@webprofiler.debug.asset.css.collection_renderer.inner', '@webprofiler.assets']
    properties:
      _serviceId: 'asset.css.collection_renderer'

  webprofiler.debug.asset.js.collection_renderer:
    class: Drupal\webprofiler\Asset\JsCollectionRendererWrapper
    public: false
    decorates: asset.js.collection_renderer
    arguments: ['@webprofiler.debug.asset.js.collection_renderer.inner', '@webprofiler.assets']
    properties:
      _serviceId: 'asset.js.collection_renderer'

  webprofiler.debug.entity_type.manager:
    class: Drupal\webprofiler\Entity\EntityManagerWrapper
    public: false
    decorates: entity_type.manager
    arguments: ['@webprofiler.debug.entity_type.manager.inner']
    properties:
      _serviceId: 'entity_type.manager'

  webprofiler.debug.state:
    class: Drupal\webprofiler\State\StateWrapper
    public: false
    decorates: state
    arguments: ['@webprofiler.debug.state.inner', '@webprofiler.state']
    properties:
      _serviceId: 'state'

# middleware
  http_middleware.webprofiler:
    class: Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware
    tags:
      - { name: http_middleware, priority: 350 }

  http_client_middleware.webprofiler:
    class: Drupal\webprofiler\Http\HttpClientMiddleware
    tags:
      - { name: http_client_middleware }

# parameter converter service for profile token
  webprofiler.token_converter:
    class: Drupal\webprofiler\Routing\TokenConverter
    tags:
      - { name: paramconverter }

# IDE link generator service
  webprofiler.ide_link_generator:
    class: Drupal\webprofiler\Helper\IdeLinkGenerator
    arguments: ['@config.factory']

# class shortener service
  webprofiler.class_shortener:
    class: Drupal\webprofiler\Helper\ClassShortener
