You are here

class WebformEntityPrintCssAlterSubscriber in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_entity_print/src/EventSubscriber/WebformEntityPrintCssAlterSubscriber.php \Drupal\webform_entity_print\EventSubscriber\WebformEntityPrintCssAlterSubscriber

Event subscriber to alter entity print css.

Hierarchy

Expanded class hierarchy of WebformEntityPrintCssAlterSubscriber

See also

\Drupal\entity_print\Asset\AssetCollector::getCssLibraries

1 string reference to 'WebformEntityPrintCssAlterSubscriber'
webform_entity_print.services.yml in modules/webform_entity_print/webform_entity_print.services.yml
modules/webform_entity_print/webform_entity_print.services.yml
1 service uses WebformEntityPrintCssAlterSubscriber
webform_entity_print.print_css_alter_subscriber in modules/webform_entity_print/webform_entity_print.services.yml
Drupal\webform_entity_print\EventSubscriber\WebformEntityPrintCssAlterSubscriber

File

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

Namespace

Drupal\webform_entity_print\EventSubscriber
View source
class WebformEntityPrintCssAlterSubscriber implements EventSubscriberInterface {

  /**
   * React to a config object being saved.
   *
   * @param \Drupal\entity_print\Event\PrintCssAlterEvent $event
   *   Entity Print CSS alter event.
   */
  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';
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      PrintEvents::CSS_ALTER => 'alterCss',
    ];
  }

}

Members