public function CorrespondingReference::hasCorrespondingFields in Corresponding Entity References 8.4
Checks whether the given entity has the configured corresponding reference fields.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity.
Return value
bool TRUE if the entity has corresponding fields, FALSE otherwise.
Overrides CorrespondingReferenceInterface::hasCorrespondingFields
1 call to CorrespondingReference::hasCorrespondingFields()
- CorrespondingReference::isValid in src/
Entity/ CorrespondingReference.php - Checks if this corresponding reference is valid for the provided entity.
File
- src/
Entity/ CorrespondingReference.php, line 224
Class
- CorrespondingReference
- Defines a corresponding reference entity.
Namespace
Drupal\cer\EntityCode
public function hasCorrespondingFields(FieldableEntityInterface $entity) {
$hasCorrespondingFields = FALSE;
foreach ($this
->getCorrespondingFields() as $field) {
if ($entity
->hasField($field)) {
$hasCorrespondingFields = TRUE;
break;
}
}
return $hasCorrespondingFields;
}