You are here

media_event_dispatcher.module in Hook Event Dispatcher 8.2

Same filename and directory in other branches
  1. 3.x modules/media_event_dispatcher/media_event_dispatcher.module

Media event dispatcher submodule.

File

modules/media_event_dispatcher/media_event_dispatcher.module
View source
<?php

/**
 * @file
 * Media event dispatcher submodule.
 */
use Drupal\media_event_dispatcher\Event\Media\MediaSourceInfoAlterEvent;
use Drupal\media_event_dispatcher\Event\Media\OEmbedResourceUrlAlterEvent;
use Drupal\media\OEmbed\Provider;

/**
 * Implements hook_media_source_info_alter().
 *
 * {@inheritdoc}
 */
function media_event_dispatcher_media_source_info_alter(array &$sources) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new MediaSourceInfoAlterEvent($sources);
  $manager
    ->register($event);
}

/**
 * Implements hook_oembed_resource_url_alter().
 *
 * {@inheritdoc}
 */
function media_event_dispatcher_oembed_resource_url_alter(array &$parsedURL, Provider $provider) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new OEmbedResourceUrlAlterEvent($parsedURL, $provider);
  $manager
    ->register($event);
}