public function Pinterest::getField in Media entity Pinterest 8
Gets a media-related field/value.
Parameters
MediaInterface $media: Media object.
string $name: Name of field to fetch.
Return value
mixed Field value or FALSE if data unavailable.
Overrides MediaTypeInterface::getField
2 calls to Pinterest::getField()
- Pinterest::getDefaultName in src/
Plugin/ MediaEntity/ Type/ Pinterest.php - Provide a default name for the media.
- Pinterest::thumbnail in src/
Plugin/ MediaEntity/ Type/ Pinterest.php - Gets thumbnail image.
File
- src/
Plugin/ MediaEntity/ Type/ Pinterest.php, line 117
Class
- Provides media type plugin for Pinterest.
Namespace
Drupal\media_entity_pinterest\Plugin\MediaEntity\TypeCode
public function getField(MediaInterface $media, $name) {
$matches = $this
->matchRegexp($media);
if (empty($matches)) {
return FALSE;
}
// First we return the fields that are available from regex.
switch ($name) {
case 'id':
if (!empty($matches['id'])) {
return $matches['id'];
}
return FALSE;
case 'section':
if (!empty($matches['section'])) {
return $matches['section'];
}
return NULL;
case 'board':
if (!empty($matches['slug'])) {
return $matches['slug'];
}
return FALSE;
case 'user':
if (!empty($matches['username'])) {
return $matches['username'];
}
return FALSE;
}
// TODO: Implement getField() method for API fields.
// If we have auth settings return the other fields.
return FALSE;
}