public function YamlFormRequest::isValidSourceEntity in YAML Form 8
Check if a source entity is attached to a form.
Parameters
\Drupal\Core\Entity\EntityInterface $yamlform_entity: A form or form submission.
\Drupal\Core\Entity\EntityInterface|null $source_entity: A form submission's source entity.
Return value
bool TRUE if a form is attached to a form submission source entity.
Overrides YamlFormRequestInterface::isValidSourceEntity
2 calls to YamlFormRequest::isValidSourceEntity()
- YamlFormRequest::getBaseRouteName in src/
YamlFormRequest.php - Get the base route name for a form/submission and source entity.
- YamlFormRequest::getRouteParameters in src/
YamlFormRequest.php - Get the route parameters for a form/submission and source entity.
File
- src/
YamlFormRequest.php, line 182
Class
- YamlFormRequest
- Handles form requests.
Namespace
Drupal\yamlformCode
public function isValidSourceEntity(EntityInterface $yamlform_entity, EntityInterface $source_entity = NULL) {
if ($yamlform_entity instanceof YamlFormSubmissionInterface) {
$yamlform = $yamlform_entity
->getYamlForm();
}
elseif ($yamlform_entity instanceof YamlFormInterface) {
$yamlform = $yamlform_entity;
}
else {
throw new \InvalidArgumentException('Form entity');
}
if ($source_entity && method_exists($source_entity, 'hasField') && $source_entity
->hasField('yamlform') && $source_entity->yamlform->target_id == $yamlform
->id()) {
return TRUE;
}
else {
return FALSE;
}
}