You are here

class VideoFilterCore in Video Filter 8

Core class for Video Fitler module.

Contains helper methods.

@package Drupal\video_filter

Hierarchy

Expanded class hierarchy of VideoFilterCore

1 file declares its use of VideoFilterCore
VideoFilterDialog.php in src/Form/VideoFilterDialog.php

File

src/VideoFilterCore.php, line 14

Namespace

Drupal\video_filter
View source
class VideoFilterCore {
  use StringTranslationTrait;

  /**
   * Load Video Filter plugins.
   */
  public function loadPlugins($url = '') {
    $result = [];
    $manager = \Drupal::service('plugin.manager.video_filter');
    $plugins = [];
    foreach ($manager
      ->getDefinitions() as $plugin_info) {
      $plugin = $manager
        ->createInstance($plugin_info['id']);

      // Plugin options.
      $options = $plugin
        ->options();

      // Check if URL is supported.
      $regexp = $plugin
        ->getRegexp();
      $_regexp = !is_array($regexp) ? [
        $regexp,
      ] : $regexp;
      foreach ($_regexp as $regexp) {
        if (preg_match($regexp, $url, $matches) && !empty($options)) {
          $result['id'] = $plugin_info['id'];
          $result['options'] = $options;
          $result['plugin'] = $plugin;
        }
      }
      $plugins[$plugin_info['id']] = [
        'options' => $options,
        'regexp' => $_regexp,
      ];
    }
    $result['plugins'] = $plugins;
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
VideoFilterCore::loadPlugins public function Load Video Filter plugins.