You are here

abstract class ConfigNormalizerBase in Configuration Normalizer 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ConfigNormalizerBase.php \Drupal\config_normalizer\Plugin\ConfigNormalizerBase

Base class for Config normalizer plugins.

Hierarchy

Expanded class hierarchy of ConfigNormalizerBase

3 files declare their use of ConfigNormalizerBase
ConfigNormalizerActive.php in src/Plugin/ConfigNormalizer/ConfigNormalizerActive.php
ConfigNormalizerFilterFormat.php in src/Plugin/ConfigNormalizer/ConfigNormalizerFilterFormat.php
ConfigNormalizerSort.php in src/Plugin/ConfigNormalizer/ConfigNormalizerSort.php

File

src/Plugin/ConfigNormalizerBase.php, line 13

Namespace

Drupal\config_normalizer\Plugin
View source
abstract class ConfigNormalizerBase extends PluginBase implements ConfigNormalizerInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Creates a new config normalizer plugin.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'));
  }

  /**
   * Determines whether the context has a default normalization mode.
   *
   * @param array $context
   *   An array of key-value pairs to pass additional context when needed.
   *
   * @return bool
   *   TRUE if the context normalization mode is default. Otherwise, FALSE.
   */
  protected function isDefaultModeContext(array $context) {
    return !empty($context['normalization_mode']) && $context['normalization_mode'] === NormalizedReadOnlyStorageInterface::DEFAULT_NORMALIZATION_MODE;
  }

  /**
   * Determines whether the context reference storage is the active storage.
   *
   * @param array $context
   *   An array of key-value pairs to pass additional context when needed.
   *
   * @return bool
   *   TRUE if the context normalization mode is default. Otherwise, FALSE.
   */
  protected function isActiveStorageContext(array $context) {
    if (!empty($context['reference_storage_service']) && !empty($context['reference_storage_service']->_serviceId) && $context['reference_storage_service']->_serviceId === 'config.storage') {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigNormalizerBase::$entityTypeManager protected property The entity type manager.
ConfigNormalizerBase::create public static function
ConfigNormalizerBase::isActiveStorageContext protected function Determines whether the context reference storage is the active storage.
ConfigNormalizerBase::isDefaultModeContext protected function Determines whether the context has a default normalization mode.
ConfigNormalizerBase::__construct public function Creates a new config normalizer plugin. Overrides PluginBase::__construct
ConfigNormalizerInterface::normalize public function Normalizes config for comparison. 3
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.