public function ValidationConstraintMatchTrait::appliesTo in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/ValidationConstraintMatchTrait.php \Drupal\lightning_media\ValidationConstraintMatchTrait::appliesTo()
- 8.2 src/ValidationConstraintMatchTrait.php \Drupal\lightning_media\ValidationConstraintMatchTrait::appliesTo()
- 8.3 src/ValidationConstraintMatchTrait.php \Drupal\lightning_media\ValidationConstraintMatchTrait::appliesTo()
Implements InputMatchInterface::appliesTo().
File
- src/
ValidationConstraintMatchTrait.php, line 26
Class
- ValidationConstraintMatchTrait
- Implements InputMatchInterface for media types that use an embed code or URL.
Namespace
Drupal\lightning_mediaCode
public function appliesTo($value, MediaTypeInterface $media_type) {
$plugin_definition = $this
->getPluginDefinition();
$definition = $this
->typedDataManager()
->createDataDefinition('string')
->addConstraint($plugin_definition['input_match']['constraint']);
$data = StringData::createInstance($definition);
$data
->setValue($value);
return $data
->validate()
->count() === 0;
}