protected function Instagram::matchRegexp in Media entity Instagram 8.2
Same name and namespace in other branches
- 3.x src/Plugin/media/Source/Instagram.php \Drupal\media_entity_instagram\Plugin\media\Source\Instagram::matchRegexp()
Runs preg_match on embed code/URL.
Parameters
\Drupal\media\MediaInterface $media: Media object.
Return value
array|bool Array of preg matches or FALSE if no match.
See also
1 call to Instagram::matchRegexp()
- Instagram::getMetadata in src/
Plugin/ media/ Source/ Instagram.php - Gets the value for a metadata attribute for a given media item.
File
- src/
Plugin/ media/ Source/ Instagram.php, line 243
Class
- Provides media type plugin for Instagram.
Namespace
Drupal\media_entity_instagram\Plugin\media\SourceCode
protected function matchRegexp(MediaInterface $media) {
$matches = [];
if (isset($this->configuration['source_field'])) {
$source_field = $this->configuration['source_field'];
if ($media
->hasField($source_field)) {
$property_name = $media->{$source_field}
->first()
->mainPropertyName();
foreach (static::$validationRegexp as $pattern => $key) {
if (preg_match($pattern, $media->{$source_field}->{$property_name}, $matches)) {
return $matches;
}
}
}
}
return FALSE;
}