MediaTestOembedThemeHooks.php

Namespace

Drupal\media_test_oembed\Hook

File

core/modules/media/tests/modules/media_test_oembed/src/Hook/MediaTestOembedThemeHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\media_test_oembed\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Theme hook implementations for media_test_oembed.
 */
class MediaTestOembedThemeHooks {
  
  /**
   * Implements hook_preprocess_media_oembed_iframe().
   */
  public function preprocessMediaOembedIframe(array &$variables) : void {
    if ($variables['resource']->getProvider()
      ->getName() === 'YouTube') {
      $variables['media'] = str_replace('?feature=oembed', '?feature=oembed&pasta=rigatoni', (string) $variables['media']);
    }
    // @see \Drupal\Tests\media\Kernel\OEmbedIframeControllerTest
    $variables['#attached']['library'][] = 'media_test_oembed/frame';
    $variables['#cache']['tags'][] = 'yo_there';
  }

}

Classes

Title Deprecated Summary
MediaTestOembedThemeHooks Theme hook implementations for media_test_oembed.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.