You are here

public function PartyDefaultDataSet::createEntity in Party 8.2

Same name and namespace in other branches
  1. 7 includes/party.data.inc \PartyDefaultDataSet::createEntity()

Create a new entity

This method provides a helper to create a new attached entity for the data set without having to figure out the entity type and bundle.

Return value

object A newly created unsaved entity of the correct type and bundle.

1 call to PartyDefaultDataSet::createEntity()
PartyDefaultDataSet::getEntity in includes/party.data.inc
Get a particular attached entity

File

includes/party.data.inc, line 386
Provides the default class for managing party - Attached entity relationships.

Class

PartyDefaultDataSet
Class PartyDefaultDataSet

Code

public function createEntity() {

  // Create a placeholder entity
  $values = array();
  if ($this
    ->getDataInfo('bundle key')) {
    $values[$this
      ->getDataInfo('bundle key')] = $this
      ->getDataInfo('entity bundle');
  }

  // Create the entity, set our data set and return
  $entity = entity_create($this
    ->getDataInfo('entity type'), $values);

  // Add the other properties party needs.
  $entity->data_set_name = $this->data_set;
  if (isset($this->party->pid)) {
    $entity->party_attaching_party = $this->party->pid;
  }
  return $entity;
}