You are here

class MockProvider in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 tests/modules/video_embed_field_mock_provider/src/Plugin/video_embed_field/Provider/MockProvider.php \Drupal\video_embed_field_mock_provider\Plugin\video_embed_field\Provider\MockProvider

A mock video provider for use in tests.

Plugin annotation


@VideoEmbedProvider(
  id = "mock",
  title = @Translation("Mock Provider")
)

Hierarchy

Expanded class hierarchy of MockProvider

File

tests/modules/video_embed_field_mock_provider/src/Plugin/video_embed_field/Provider/MockProvider.php, line 15

Namespace

Drupal\video_embed_field_mock_provider\Plugin\video_embed_field\Provider
View source
class MockProvider implements ProviderPluginInterface {

  /**
   * {@inheritdoc}
   */
  public static function isApplicable($input) {
    return strpos($input, 'example.com') !== FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function renderThumbnail($image_style, $link_url) {
    return [
      '#markup' => 'Mock provider thumbnail.',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function renderEmbedCode($width, $height, $autoplay) {
    return [
      '#markup' => 'Mock provider embed code.',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getRemoteThumbnailUrl() {
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public function getLocalThumbnailUri() {
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public function downloadThumbnail() {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public static function getIdFromInput($input) {
    return $input;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'Video Name';
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginId() {
    return 'foo';
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginDefinition() {
    return [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MockProvider::downloadThumbnail public function Download the remote thumbnail URL to the local thumbnail URI. Overrides ProviderPluginInterface::downloadThumbnail
MockProvider::getIdFromInput public static function Get the ID of the video from user input. Overrides ProviderPluginInterface::getIdFromInput
MockProvider::getLocalThumbnailUri public function Get the URL to the local thumbnail. Overrides ProviderPluginInterface::getLocalThumbnailUri
MockProvider::getName public function Get the name of the video. Overrides ProviderPluginInterface::getName
MockProvider::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
MockProvider::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
MockProvider::getRemoteThumbnailUrl public function Get the URL of the remote thumbnail. Overrides ProviderPluginInterface::getRemoteThumbnailUrl
MockProvider::isApplicable public static function Check if the plugin is applicable to the user input. Overrides ProviderPluginInterface::isApplicable
MockProvider::renderEmbedCode public function Render embed code. Overrides ProviderPluginInterface::renderEmbedCode
MockProvider::renderThumbnail public function Render a thumbnail. Overrides ProviderPluginInterface::renderThumbnail