class FacebookEmbedCodeConstraintValidator in Media entity facebook 8
Same name and namespace in other branches
- 8.2 src/Plugin/Validation/Constraint/FacebookEmbedCodeConstraintValidator.php \Drupal\media_entity_facebook\Plugin\Validation\Constraint\FacebookEmbedCodeConstraintValidator
- 3.x src/Plugin/Validation/Constraint/FacebookEmbedCodeConstraintValidator.php \Drupal\media_entity_facebook\Plugin\Validation\Constraint\FacebookEmbedCodeConstraintValidator
Validates the FacebookEmbedCode constraint.
Hierarchy
- class \Drupal\media_entity_facebook\Plugin\Validation\Constraint\FacebookEmbedCodeConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator uses EmbedCodeValueTrait
Expanded class hierarchy of FacebookEmbedCodeConstraintValidator
File
- src/
Plugin/ Validation/ Constraint/ FacebookEmbedCodeConstraintValidator.php, line 13
Namespace
Drupal\media_entity_facebook\Plugin\Validation\ConstraintView source
class FacebookEmbedCodeConstraintValidator extends ConstraintValidator {
use EmbedCodeValueTrait;
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
$value = $this
->getEmbedCode($value);
if (!isset($value)) {
return;
}
$post_url = Facebook::parseFacebookEmbedField($value);
if ($post_url === FALSE) {
$this->context
->addViolation($constraint->message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EmbedCodeValueTrait:: |
protected | function | Extracts the raw embed code from input which may or may not be wrapped. | |
FacebookEmbedCodeConstraintValidator:: |
public | function | Checks if the passed value is valid. |