You are here

ProdCheckCategoryPluginManager.php in Production check & Production monitor 8

File

src/Plugin/ProdCheckCategoryPluginManager.php
View source
<?php

namespace Drupal\prod_check\Plugin;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Core\Plugin\Discovery\YamlDiscovery;
use Drupal\Core\Plugin\Factory\ContainerFactory;

/**
 * Defines a prod check categories plugin manager to deal with categories.
 */
class ProdCheckCategoryPluginManager extends DefaultPluginManager {

  /**
   * Constructs a new ProdCheckCategoryPluginManager instance.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   The cache backend.
   */
  public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) {
    $this->factory = new ContainerFactory($this);
    $this->moduleHandler = $module_handler;
    $this
      ->alterInfo('prod_check_categories');
    $this
      ->setCacheBackend($cache_backend, 'prod_check_categories');
  }

  /**
   * {@inheritdoc}
   */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $this->discovery = new YamlDiscovery('prod_check_categories', $this->moduleHandler
        ->getModuleDirectories());
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery);
    }
    return $this->discovery;
  }

}

Classes

Namesort descending Description
ProdCheckCategoryPluginManager Defines a prod check categories plugin manager to deal with categories.