You are here

class AnonymizerFactory in General Data Protection Regulation 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/anonymizer/src/Anonymizer/AnonymizerFactory.php \Drupal\anonymizer\Anonymizer\AnonymizerFactory
  2. 8 modules/anonymizer/src/Anonymizer/AnonymizerFactory.php \Drupal\anonymizer\Anonymizer\AnonymizerFactory

Class AnonymizerFactory.

@package Drupal\anonymizer\Anonymizer

Hierarchy

Expanded class hierarchy of AnonymizerFactory

2 files declare their use of AnonymizerFactory
GdprSqlDump.php in modules/gdpr_dump/src/Service/GdprSqlDump.php
RightToBeForgottenEntityTraversal.php in modules/gdpr_tasks/src/Traversal/RightToBeForgottenEntityTraversal.php
1 string reference to 'AnonymizerFactory'
anonymizer.services.yml in modules/anonymizer/anonymizer.services.yml
modules/anonymizer/anonymizer.services.yml
1 service uses AnonymizerFactory
anonymizer.anonymizer_factory in modules/anonymizer/anonymizer.services.yml
Drupal\anonymizer\Anonymizer\AnonymizerFactory

File

modules/anonymizer/src/Anonymizer/AnonymizerFactory.php, line 10

Namespace

Drupal\anonymizer\Anonymizer
View source
class AnonymizerFactory {

  /**
   * Anonymizer instances keyed by their ID.
   *
   * @var \Drupal\anonymizer\Anonymizer\AnonymizerInterface[]
   */
  protected $anonymizers = [];

  /**
   * The anonymizer plugin manager.
   *
   * @var \Drupal\anonymizer\Anonymizer\AnonymizerPluginManager
   */
  protected $pluginManager;

  /**
   * AnonymizerFactory constructor.
   *
   * @param \Drupal\anonymizer\Anonymizer\AnonymizerPluginManager $pluginManager
   *   The anonymizer plugin manager.
   */
  public function __construct(AnonymizerPluginManager $pluginManager) {
    $this->pluginManager = $pluginManager;
  }

  /**
   * Gets all anonymizers currently registered.
   */
  public function getDefinitions() {
    return $this->pluginManager
      ->getDefinitions();
  }

  /**
   * Get an instance of a anonymizer.
   *
   * @param string $name
   *   Anonymizer name.
   *
   * @return \Drupal\anonymizer\Anonymizer\AnonymizerInterface
   *   The anonymizer instance.
   *
   * @throws \Drupal\Component\Plugin\Exception\PluginException
   */
  public function get($name) {
    if (!isset($this->anonymizers[$name])) {
      $this->anonymizers[$name] = $this->pluginManager
        ->createInstance($name);
    }
    return $this->anonymizers[$name];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AnonymizerFactory::$anonymizers protected property Anonymizer instances keyed by their ID.
AnonymizerFactory::$pluginManager protected property The anonymizer plugin manager.
AnonymizerFactory::get public function Get an instance of a anonymizer.
AnonymizerFactory::getDefinitions public function Gets all anonymizers currently registered.
AnonymizerFactory::__construct public function AnonymizerFactory constructor.