You are here

public function NodeRegistrationController::create in Node registration 7

Override create() to add registration properties.

Overrides EntityAPIController::create

File

includes/node_registration.entity.inc, line 121
Entity hooks and callbacks for registrations.

Class

NodeRegistrationController
Controller class Node Registrations

Code

public function create(array $values = array()) {
  if (!isset($values['created'])) {
    $values['created'] = REQUEST_TIME;
  }
  if (!isset($values['updated'])) {
    $values['updated'] = $values['created'];
  }
  if (isset($values['node'])) {
    $node = $values['node'];
  }
  else {
    $node = node_load($values['nid']);
    $values['node'] = $node;
  }

  // The dynamic type: fields per registration type or per node.
  $values['type'] = !empty($node->registration->private_fields) ? 'node_' . $node->nid : $node->type;

  // The node type.
  $values['node_type'] = $node->type;
  $entity = parent::create($values);
  return $entity;
}