public ContentEntityBase::referencedEntities()
Gets a list of entities referenced by this entity.
Return value
\Drupal\Core\Entity\EntityInterface[] An array of entities.
Overrides Entity::referencedEntities
File
- core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 1061
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public function referencedEntities() { $referenced_entities = array (); // Gather a list of referenced entities. foreach ( $this ->getFields() as $field_items ) { foreach ( $field_items as $field_item ) { // Loop over all properties of a field item. foreach ( $field_item ->getProperties(TRUE) as $property ) { if ( $property instanceof EntityReference && $entity = $property ->getValue()) { $referenced_entities [] = $entity ; } } } } return $referenced_entities ; } |
Please login to continue.