AttachedProcessor.php in Cookie Content Blocker 8
File
src/ElementProcessor/AttachedProcessor.php
View source
<?php
namespace Drupal\cookie_content_blocker\ElementProcessor;
use Drupal\cookie_content_blocker\BlockedLibraryManagerInterface;
class AttachedProcessor extends ElementProcessorBase {
protected $libraryManager;
public function __construct(BlockedLibraryManagerInterface $library_manager) {
$this->libraryManager = $library_manager;
}
public function applies(array $element) : bool {
return !empty($element['#attached']['library']);
}
public function processElement(array $element) : array {
foreach ($element['#attached']['library'] as $library) {
$this->libraryManager
->addBlockedLibrary($library);
}
return $element;
}
}