trait ValidationConstraintMatchTrait in Varbase Media 9.0.x
Same name and namespace in other branches
- 8.7 modules/entity_browser_generic_embed/src/ValidationConstraintMatchTrait.php \Drupal\entity_browser_generic_embed\ValidationConstraintMatchTrait
- 8.5 modules/entity_browser_generic_embed/src/ValidationConstraintMatchTrait.php \Drupal\entity_browser_generic_embed\ValidationConstraintMatchTrait
- 8.6 modules/entity_browser_generic_embed/src/ValidationConstraintMatchTrait.php \Drupal\entity_browser_generic_embed\ValidationConstraintMatchTrait
Implements InputMatchInterface for media types that use an embed code or URL.
Hierarchy
- trait \Drupal\entity_browser_generic_embed\ValidationConstraintMatchTrait
2 files declare their use of ValidationConstraintMatchTrait
- VarbaseMediaInstagram.php in modules/
varbase_media_instagram/ src/ Plugin/ media/ Source/ VarbaseMediaInstagram.php - VarbaseMediaTwitter.php in modules/
varbase_media_twitter/ src/ Plugin/ media/ Source/ VarbaseMediaTwitter.php
File
- modules/
entity_browser_generic_embed/ src/ ValidationConstraintMatchTrait.php, line 11
Namespace
Drupal\entity_browser_generic_embedView source
trait ValidationConstraintMatchTrait {
/**
* Returns the typed data manager.
*
* @return \Drupal\Core\TypedData\TypedDataManagerInterface
* The typed data manager.
*/
private function typedDataManager() {
return @($this->typedDataManager ?: \Drupal::typedDataManager());
}
/**
* Implements InputMatchInterface::appliesTo().
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ValidationConstraintMatchTrait:: |
public | function | Implements InputMatchInterface::appliesTo(). | |
ValidationConstraintMatchTrait:: |
private | function | Returns the typed data manager. |