You are here

class InvoiceFilenameSubscriber in Commerce Invoice 8.2

Hierarchy

  • class \Drupal\commerce_invoice_test\EventSubscriber\InvoiceFilenameSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of InvoiceFilenameSubscriber

1 string reference to 'InvoiceFilenameSubscriber'
commerce_invoice_test.services.yml in tests/modules/commerce_invoice_test/commerce_invoice_test.services.yml
tests/modules/commerce_invoice_test/commerce_invoice_test.services.yml
1 service uses InvoiceFilenameSubscriber
commerce_invoice_test.invoice_filename_subscriber in tests/modules/commerce_invoice_test/commerce_invoice_test.services.yml
Drupal\commerce_invoice_test\EventSubscriber\InvoiceFilenameSubscriber

File

tests/modules/commerce_invoice_test/src/EventSubscriber/InvoiceFilenameSubscriber.php, line 9

Namespace

Drupal\commerce_invoice_test\EventSubscriber
View source
class InvoiceFilenameSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      InvoiceEvents::INVOICE_FILENAME => 'alterFilename',
    ];
  }

  /**
   * Alters the invoice filename.
   *
   * @param \Drupal\commerce_invoice\Event\InvoiceFilenameEvent $event
   *   The transition event.
   */
  public function alterFilename(InvoiceFilenameEvent $event) {
    $invoice = $event
      ->getInvoice();

    // Alter the filename if the "alter_filename" data flag is present.
    if ($invoice
      ->getData('alter_filename')) {
      $event
        ->setFilename($event
        ->getFilename() . '-altered');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InvoiceFilenameSubscriber::alterFilename public function Alters the invoice filename.
InvoiceFilenameSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.