private function CerHandler::getReferenceIDs in Corresponding Entity References 7.2
Gets all the referenced entity IDs from a specific field on $entity.
Parameters
object $entity: The entity to scan for references.
array $field: Field or instance definition.
Return value
array Array of unique IDs, empty if there are no references or the field does not exist on $entity.
3 calls to CerHandler::getReferenceIDs()
- CerHandler::getLocalReferenceIDs in ./
handler.inc - Gets the IDs of the entities referenced by the local entity.
- CerHandler::getRemoteReferenceIDs in ./
handler.inc - Gets the IDs of the entities referenced by $entity.
- CerHandler::update in ./
handler.inc - Implements CerHandlerInterface::update().
File
- ./
handler.inc, line 445 - Contains base code for CER handlers, which are objects responsible for creating, updating and deleting corresponding references between entities.
Class
- CerHandler
- @class Generic CER handler with rudimentary language handling.
Code
private function getReferenceIDs($entity, $field) {
$IDs = array();
if (isset($entity->{$field['field_name']})) {
foreach ($entity->{$field['field_name']} as $references) {
foreach ($references as $reference) {
$IDs[] = $reference['target_id'];
}
}
}
return array_unique(array_filter($IDs));
}