DrupalCommerceEntityController::create

  1. commerce
    1. 7
Versions
7 public DrupalCommerceEntityController::create(array $values = array())

Create a new entity.

Parameters

array $values An array of values to set, keyed by property name.

Return value

A new instance of the entity type.

Code

includes/commerce.controller.inc, line 225

<?php
public function create(array $values = array()) {
  // Add is_new property if it is not set.
  $values += array('is_new' => TRUE);

  // If there is a class for this entity type, instantiate it now.
  if (isset($this->entityInfo['entity class']) && $class = $this->entityInfo['entity class']) {
    $entity = new $class($values, $this->entityType);
  }
  else {
    // Otherwise use a good old stdClass.
    $entity = (object) $values;
  }

  // Allow other modules to alter the created entity.
  drupal_alter('commerce_entity_create', $this->entityType, $entity);

  return $entity;
}
?>