ElementProcessor.php in Cookie Content Blocker 8
File
src/ElementProcessor/ElementProcessor.php
View source
<?php
namespace Drupal\cookie_content_blocker\ElementProcessor;
use Drupal\cookie_content_blocker\ElementProcessorInterface;
class ElementProcessor extends ElementProcessorBase {
protected $processors = [];
public function addProcessor(ElementProcessorInterface $processor) : void {
$this->processors[] = $processor;
}
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;
}
public function applies(array $element) : bool {
return !empty($element['#cookie_content_blocker']);
}
}