You are here

public function WebformEntityPrintCssAlterSubscriber::alterCss in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_entity_print/src/EventSubscriber/WebformEntityPrintCssAlterSubscriber.php \Drupal\webform_entity_print\EventSubscriber\WebformEntityPrintCssAlterSubscriber::alterCss()

React to a config object being saved.

Parameters

\Drupal\entity_print\Event\PrintCssAlterEvent $event: Entity Print CSS alter event.

File

modules/webform_entity_print/src/EventSubscriber/WebformEntityPrintCssAlterSubscriber.php, line 22

Class

WebformEntityPrintCssAlterSubscriber
Event subscriber to alter entity print css.

Namespace

Drupal\webform_entity_print\EventSubscriber

Code

public function alterCss(PrintCssAlterEvent $event) {

  /** @var \Drupal\webform\WebformSubmissionInterface[] $entities */
  $entities = $event
    ->getEntities();
  foreach ($entities as $entity) {
    if ($entity
      ->getEntityTypeId() === 'webform_submission') {
      $event
        ->getBuild()['#attached']['library'][] = 'webform_entity_print/webform_entity_print';
    }
  }
}