You are here

class TestEngineConfigurationAlter in Entity Print 8

Same name and namespace in other branches
  1. 8.2 tests/modules/entity_print_test/src/EventSubscriber/TestEngineConfigurationAlter.php \Drupal\entity_print_test\EventSubscriber\TestEngineConfigurationAlter

The TestEngineConfigurationAlter class.

Hierarchy

  • class \Drupal\entity_print_test\EventSubscriber\TestEngineConfigurationAlter implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of TestEngineConfigurationAlter

1 string reference to 'TestEngineConfigurationAlter'
entity_print_test.services.yml in tests/modules/entity_print_test/entity_print_test.services.yml
tests/modules/entity_print_test/entity_print_test.services.yml
1 service uses TestEngineConfigurationAlter
entity_print_test.configuration_alter in tests/modules/entity_print_test/entity_print_test.services.yml
Drupal\entity_print_test\EventSubscriber\TestEngineConfigurationAlter

File

tests/modules/entity_print_test/src/EventSubscriber/TestEngineConfigurationAlter.php, line 14

Namespace

Drupal\entity_print_test\EventSubscriber
View source
class TestEngineConfigurationAlter implements EventSubscriberInterface {

  /**
   * Alter the configuration for our testpdf engine.
   *
   * @param \Symfony\Component\EventDispatcher\GenericEvent $event
   *   The event object.
   */
  public function alterConfiguration(GenericEvent $event) {
    if ($event
      ->getArgument('config')
      ->id() === 'testpdfengine') {
      $event
        ->setArgument('configuration', [
        'test_engine_suffix' => 'overridden',
      ] + $event
        ->getArgument('configuration'));
    }
  }

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

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

}

Members

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