public function PartyDataBase::getEntityDelta in Party 8.2
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 PartyDataBase::getEntityDelta()
- PartyDataBase::attachEntity in lib/
Drupal/ party/ Plugin/ PartyDataBase.php - Attach an entity to the party
- PartyDataBase::detachEntity in lib/
Drupal/ party/ Plugin/ PartyDataBase.php - Detach an entity
File
- lib/
Drupal/ party/ Plugin/ PartyDataBase.php, line 149 - Contains \Drupal\party\Plugin\PartyDataBase.
Class
- PartyDataBase
- Class PartyDataBase
Namespace
Drupal\party\PluginCode
public function getEntityDelta($entity) {
// If $entity is saved, we can just compare entity ids.
if ($entity
->isNew()) {
// Flip our entity ids so it's delta keyed by id.
$deltas = array_flip($this
->getEntityIds());
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;
}