You are here

public static function Youku::getIdFromInput in Video Embed Youku 8

Get the Youku id from page url.

File

src/Plugin/video_embed_field/Provider/Youku.php, line 71
Contains \Drupal\video_embed_youku\Plugin\video_embed_field\Provider\Youku.

Class

Youku
Plugin annotation @VideoEmbedProvider( id = "youku", title = @Translation("Youku") )

Namespace

Drupal\video_embed_youku\Plugin\video_embed_field\Provider

Code

public static function getIdFromInput($input) {
  $id = FALSE;

  // Parse_url is an easy way to break a url into its components.
  $parsed = parse_url($input);
  $path = $parsed['path'];
  $parts = explode('/', $path);
  foreach ($parts as $part) {
    if (strstr($part, 'id_')) {
      $id = str_replace('id_', '', $part);
      $id = str_replace('.html', '', $id);
      return $id;
    }
  }
}