public function PartyDefaultDataSet::getEntity in Party 8.2
Same name and namespace in other branches
- 7 includes/party.data.inc \PartyDefaultDataSet::getEntity()
Get a particular attached entity
Parameters
int $delta: (optional) A delta to get. Defaults to 0.
bool $create: (optional) Create an entity if it doesn't exist. Defaults to FALSE.
Return value
mixed An entity object or one doesn't exist and we're not creating, FALSE.
4 calls to PartyDefaultDataSet::getEntity()
- PartyDefaultDataSet::display in includes/
party.data.inc - Return the renderable array for one of our attached entities.
- PartyDefaultDataSet::getLabel in includes/
party.data.inc - Get the label of one of our attached entities.
- PartyDefaultDataSet::saveEntity in includes/
party.data.inc - Save an entity.
- PartyUserDataSet::getLabel in modules/
party_user/ includes/ party_user.data.inc - Get the user label.
File
- includes/
party.data.inc, line 241 - Provides the default class for managing party - Attached entity relationships.
Class
- PartyDefaultDataSet
- Class PartyDefaultDataSet
Code
public function getEntity($delta = 0, $create = FALSE) {
// If this delta exists, check it's loaded and return it.
if (isset($this->entities[$delta])) {
if (isset($this->entities[$delta]->is_stub)) {
$this
->loadEntities(array(
$delta,
));
}
}
else {
// Let's create an entity and attach it, but no saving happens unless
// explicitly called. To maintain unsaved entities, this data controller
// can be stored against forms etc.
if ($create) {
$entity = $this
->createEntity();
$this
->attachEntity($entity, $delta);
}
else {
// Nothing found and not creating; return false.
return FALSE;
}
}
return $this->entities[$delta];
}