public function PartyDefaultDataSet::getEntityDelta in Party 8.2
Same name and namespace in other branches
- 7 includes/party.data.inc \PartyDefaultDataSet::getEntityDelta()
Get the delta from an entity object.
Parameters
$entity: The entity object we want to find the delta for.
Return value
int|FALSE The delta of $entity, or FALSE if it isn't attached.
2 calls to PartyDefaultDataSet::getEntityDelta()
- PartyDefaultDataSet::attachEntity in includes/
party.data.inc - Attach an entity to the party
- PartyDefaultDataSet::detachEntity in includes/
party.data.inc - Detach an entity
File
- includes/
party.data.inc, line 174 - Provides the default class for managing party - Attached entity relationships.
Class
- PartyDefaultDataSet
- Class PartyDefaultDataSet
Code
public function getEntityDelta($entity) {
// If $entity is saved, we can just compare entity ids.
if (!isset($entity->is_new)) {
// Flip our entity ids so it's delta keyed by id.
$deltas = array_flip($this
->getEntityIds());
$entity_id = $entity->{$this
->getDataInfo('id key')};
if (isset($deltas[$entity_id])) {
return $deltas[$entity_id];
}
}
else {
foreach ($this->entities as $delta => $row) {
if ($entity === $row) {
return $delta;
}
}
}
// If we've got here, we can't find it.
return FALSE;
}