You are here

class ContentEntityTestAlterSubscriber in Replication 8

Same name and namespace in other branches
  1. 8.2 tests/modules/replication_alter_test/src/Event/ContentEntityTestAlterSubscriber.php \Drupal\replication_alter_test\Event\ContentEntityTestAlterSubscriber

Event subscriber to test altering data during normalization.

Hierarchy

Expanded class hierarchy of ContentEntityTestAlterSubscriber

1 string reference to 'ContentEntityTestAlterSubscriber'
replication_alter_test.services.yml in tests/modules/replication_alter_test/replication_alter_test.services.yml
tests/modules/replication_alter_test/replication_alter_test.services.yml
1 service uses ContentEntityTestAlterSubscriber
replication_alter_test.content.subscriber in tests/modules/replication_alter_test/replication_alter_test.services.yml
Drupal\replication_alter_test\Event\ContentEntityTestAlterSubscriber

File

tests/modules/replication_alter_test/src/Event/ContentEntityTestAlterSubscriber.php, line 13

Namespace

Drupal\replication_alter_test\Event
View source
class ContentEntityTestAlterSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[ReplicationDataEvents::ALTER_CONTENT_DATA][] = [
      'onAlterContentData',
      0,
    ];
    return $events;
  }

  /**
   * Alter content normalization data.
   *
   * @param ReplicationContentDataAlterEvent $event
   */
  public function onAlterContentData(ReplicationContentDataAlterEvent $event) {

    // Add some data under a '_test' key.
    $normalized = $event
      ->getData();
    $normalized['_test'] = [
      'foo' => 'bar',
    ];
    $event
      ->setData($normalized);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityTestAlterSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ContentEntityTestAlterSubscriber::onAlterContentData public function Alter content normalization data.