public function DrupalCommerceEntityController::create in Commerce Core 7
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.
Overrides EntityAPIControllerInterface::create
5 calls to DrupalCommerceEntityController::create()
- CommerceCustomerProfileEntityController::create in modules/
customer/ includes/ commerce_customer_profile.controller.inc - Create a default customer profile.
- CommerceLineItemEntityController::create in modules/
line_item/ includes/ commerce_line_item.controller.inc - Create a default line item.
- CommerceOrderEntityController::create in modules/
order/ includes/ commerce_order.controller.inc - Create a default order.
- CommercePaymentTransactionEntityController::create in modules/
payment/ includes/ commerce_payment_transaction.controller.inc - Create a default payment transaction.
- CommerceProductEntityController::create in modules/
product/ includes/ commerce_product.controller.inc - Create a default product.
5 methods override DrupalCommerceEntityController::create()
- CommerceCustomerProfileEntityController::create in modules/
customer/ includes/ commerce_customer_profile.controller.inc - Create a default customer profile.
- CommerceLineItemEntityController::create in modules/
line_item/ includes/ commerce_line_item.controller.inc - Create a default line item.
- CommerceOrderEntityController::create in modules/
order/ includes/ commerce_order.controller.inc - Create a default order.
- CommercePaymentTransactionEntityController::create in modules/
payment/ includes/ commerce_payment_transaction.controller.inc - Create a default payment transaction.
- CommerceProductEntityController::create in modules/
product/ includes/ commerce_product.controller.inc - Create a default product.
File
- includes/
commerce.controller.inc, line 319 - Provides a central controller for Drupal Commerce.
Class
- DrupalCommerceEntityController
- Default implementation of DrupalCommerceEntityControllerInterface.
Code
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;
}