<?php

declare(strict_types=1);

namespace Drupal\native_observability_otel\PluginManager;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;

/**
 * Manages Native Observability exporter plugins.
 */
final class ExporterManager extends DefaultPluginManager {

  /**
   * Constructs a new ExporterManager instance.
   *
   * @param \Traversable $namespaces
   *   The root paths keyed by namespace.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   The cache backend.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   */
  public function __construct(
    \Traversable $namespaces,
    CacheBackendInterface $cache_backend,
    ModuleHandlerInterface $module_handler,
  ) {
    parent::__construct(
      'Plugin/NativeObservabilityExporter',
      $namespaces,
      $module_handler,
      'Drupal\native_observability_otel\Plugin\NativeObservabilityExporter\ExporterInterface',
      'Drupal\native_observability_otel\Annotation\NativeObservabilityExporter',
    );

    $this->alterInfo('native_observability_exporter_info');
    $this->setCacheBackend($cache_backend, 'native_observability_otel_exporter_plugins');
  }

}
