You are here

class ElementProcessor in Cookie Content Blocker 8

Class ElementProcessor.

@package Drupal\cookie_content_blocker\ElementProcessor

Hierarchy

Expanded class hierarchy of ElementProcessor

1 string reference to 'ElementProcessor'
cookie_content_blocker.services.yml in ./cookie_content_blocker.services.yml
cookie_content_blocker.services.yml
1 service uses ElementProcessor
cookie_content_blocker.element.processor in ./cookie_content_blocker.services.yml
Drupal\cookie_content_blocker\ElementProcessor\ElementProcessor

File

src/ElementProcessor/ElementProcessor.php, line 12

Namespace

Drupal\cookie_content_blocker\ElementProcessor
View source
class ElementProcessor extends ElementProcessorBase {

  /**
   * The processor list.
   *
   * @var \Drupal\cookie_content_blocker\ElementProcessorInterface[]
   */
  protected $processors = [];

  /**
   * {@inheritdoc}
   */
  public function addProcessor(ElementProcessorInterface $processor) : void {
    $this->processors[] = $processor;
  }

  /**
   * {@inheritdoc}
   */
  public function processElement(array $element) : array {
    if (!$this
      ->applies($element)) {
      return $element;
    }
    foreach ($this->processors as $processor) {
      if (!$processor
        ->applies($element)) {
        continue;
      }
      $element = $processor
        ->processElement($element);
    }
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(array $element) : bool {
    return !empty($element['#cookie_content_blocker']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ElementProcessor::$processors protected property The processor list.
ElementProcessor::addProcessor public function
ElementProcessor::applies public function Declares if the route processor applies to the given element. Overrides ElementProcessorBase::applies
ElementProcessor::processElement public function Processes the element. Overrides ElementProcessorBase::processElement
ElementProcessorBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.