protected function DataReferenceDefinitionNormalizer::validateEntity in Schemata 8
Ensure the entity type is one we support for schema reference.
If somehow the entity does not exist, or is not a ContentEntity, skip it.
Parameters
mixed $entity: The object to be normalized.
Return value
bool TRUE if valid for use.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException If the plugin could not be found.
2 calls to DataReferenceDefinitionNormalizer::validateEntity()
- DataReferenceDefinitionNormalizer::normalize in schemata_json_schema/
src/ Normalizer/ json/ DataReferenceDefinitionNormalizer.php - Normalizes an object into a set of arrays/scalars.
- DataReferenceDefinitionNormalizer::normalize in schemata_json_schema/
src/ Normalizer/ hal/ DataReferenceDefinitionNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- schemata_json_schema/
src/ Normalizer/ json/ DataReferenceDefinitionNormalizer.php, line 75
Class
- DataReferenceDefinitionNormalizer
- Normalizer for Entity References.
Namespace
Drupal\schemata_json_schema\Normalizer\jsonCode
protected function validateEntity($entity) {
// Only entity references have a schema.
// This leads to incompatibility with alternate reference modules such as
// Dynamic Entity Reference.
if ($entity
->getDataType() != 'entity_reference') {
return FALSE;
}
$entity_type_plugin = $this->entityTypeManager
->getDefinition($entity
->getConstraint('EntityType'), FALSE);
return !empty($entity_type_plugin) && $entity_type_plugin
->entityClassImplements(ContentEntityInterface::class);
}