WebformEntityPrintCssAlterSubscriber.php in Webform 6.x
File
modules/webform_entity_print/src/EventSubscriber/WebformEntityPrintCssAlterSubscriber.php
View source
<?php
namespace Drupal\webform_entity_print\EventSubscriber;
use Drupal\entity_print\Event\PrintCssAlterEvent;
use Drupal\entity_print\Event\PrintEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class WebformEntityPrintCssAlterSubscriber implements EventSubscriberInterface {
public function alterCss(PrintCssAlterEvent $event) {
$entities = $event
->getEntities();
foreach ($entities as $entity) {
if ($entity
->getEntityTypeId() === 'webform_submission') {
$event
->getBuild()['#attached']['library'][] = 'webform_entity_print/webform_entity_print';
}
}
}
public static function getSubscribedEvents() {
return [
PrintEvents::CSS_ALTER => 'alterCss',
];
}
}