You are here

class AttachedProcessor in Cookie Content Blocker 8

Class AttachedProcessor.

Processes attachments on blocked elements.

@package Drupal\cookie_content_blocker\ElementProcessor

Hierarchy

Expanded class hierarchy of AttachedProcessor

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

File

src/ElementProcessor/AttachedProcessor.php, line 14

Namespace

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

  /**
   * The library manager.
   *
   * @var \Drupal\cookie_content_blocker\BlockedLibraryManagerInterface
   */
  protected $libraryManager;

  /**
   * Constructs a AttachedProcessor object.
   *
   * @param \Drupal\cookie_content_blocker\BlockedLibraryManagerInterface $library_manager
   *   The library manager for blocked libraries.
   */
  public function __construct(BlockedLibraryManagerInterface $library_manager) {
    $this->libraryManager = $library_manager;
  }

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

  /**
   * {@inheritdoc}
   */
  public function processElement(array $element) : array {
    foreach ($element['#attached']['library'] as $library) {
      $this->libraryManager
        ->addBlockedLibrary($library);
    }
    return $element;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AttachedProcessor::$libraryManager protected property The library manager.
AttachedProcessor::applies public function Declares if the route processor applies to the given element. Overrides ElementProcessorBase::applies
AttachedProcessor::processElement public function Processes the element. Overrides ElementProcessorBase::processElement
AttachedProcessor::__construct public function Constructs a AttachedProcessor object.
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.