final public function PartyDefaultDataSet::detachEntityByDelta in Party 7
Same name and namespace in other branches
- 8.2 includes/party.data.inc \PartyDefaultDataSet::detachEntityByDelta()
Detatch an entity by delta
This method cannot be overloaded and any extensions of this class can make use of PartyDefaultDataSet::preAttach() and PartyDefaultDataSet::postAttach() to perform any additional logic required.
Parameters
int $delta: The delta of the entity to detach
bool $return: Whether you want to return the detached entity or $this for chaining. Defaults to FALSE.
Return value
object|$this Depending on $return, either the detached entity or this for chaining.
See also
PartyDefaultDataSet::preDetach()
PartyDefaultDataSet::postDetach()
2 calls to PartyDefaultDataSet::detachEntityByDelta()
- PartyDefaultDataSet::detachEntity in includes/
party.data.inc - Detach an entity
- PartyDefaultDataSet::loadEntities in includes/
party.data.inc - Load the full entities.
File
- includes/
party.data.inc, line 738 - Provides the default class for managing party - Attached entity relationships.
Class
- PartyDefaultDataSet
- Class PartyDefaultDataSet
Code
public final function detachEntityByDelta($delta, $return = FALSE) {
// Fire any pre attach logic
$this
->preDetach($delta);
if (isset($this->entities[$delta])) {
// Get our entity for returning if requested
$entity = $this->entities[$delta];
// Detach our entity
unset($this->entities[$delta]);
// Reset our numeric indexes
$this->entities = array_values($this->entities);
}
else {
// Can't return the entity if it didn't exist
$entity = FALSE;
}
// Fire any post attach logic
$this
->postDetach($delta);
$this
->invoke('detach', $entity, $delta);
if ($return) {
return $entity;
}
else {
return $this;
}
}