public function Facebook::attachConstraints in Media entity facebook 8
Attaches type-specific constraints to media.
Parameters
MediaInterface $media: Media entity.
Overrides MediaTypeBase::attachConstraints
File
- src/
Plugin/ MediaEntity/ Type/ Facebook.php, line 244
Class
- Provides media type plugin for Facebook.
Namespace
Drupal\media_entity_facebook\Plugin\MediaEntity\TypeCode
public function attachConstraints(MediaInterface $media) {
parent::attachConstraints($media);
if (isset($this->configuration['source_field'])) {
$source_field_name = $this->configuration['source_field'];
if ($media
->hasField($source_field_name)) {
foreach ($media
->get($source_field_name) as &$embed_code) {
/** @var \Drupal\Core\TypedData\DataDefinitionInterface $typed_data */
$typed_data = $embed_code
->getDataDefinition();
$typed_data
->addConstraint('FacebookEmbedCode');
}
}
}
}