You are here

class EntityPrintSubscriber in Commerce Invoice 8.2

Add our CSS for the invoice PDFS.

Hierarchy

  • class \Drupal\commerce_invoice\EventSubscriber\EntityPrintSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of EntityPrintSubscriber

1 string reference to 'EntityPrintSubscriber'
commerce_invoice.services.yml in ./commerce_invoice.services.yml
commerce_invoice.services.yml
1 service uses EntityPrintSubscriber
commerce_invoice.entity_print_subscriber in ./commerce_invoice.services.yml
Drupal\commerce_invoice\EventSubscriber\EntityPrintSubscriber

File

src/EventSubscriber/EntityPrintSubscriber.php, line 12

Namespace

Drupal\commerce_invoice\EventSubscriber
View source
class EntityPrintSubscriber implements EventSubscriberInterface {

  /**
   * Alter the CSS renderable array and add our CSS.
   *
   * @param \Drupal\entity_print\Event\PrintCssAlterEvent $event
   *   The event object.
   */
  public function alterCss(PrintCssAlterEvent $event) {
    $event
      ->getBuild()['#attached']['library'][] = 'commerce_invoice/entity-print-styling';
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
EntityPrintSubscriber::alterCss public function Alter the CSS renderable array and add our CSS.
EntityPrintSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.