public function EntityformController::create in Entityform 7.2
Same name and namespace in other branches
- 7 entityform.module \EntityformController::create()
Create a entityform - we first set up the values that are specific to our entityform schema but then also go through the EntityAPIController function.
Parameters
$type: The machine-readable type of the entityform.
Return value
A entityform object with all default fields initialized.
Overrides EntityAPIController::create
File
- ./
entityform.module, line 1274 - Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface
Class
- EntityformController
- The Controller for Entityform entities
Code
public function create(array $values = array()) {
// We need a type for the bundle but it may not be valid.
if (isset($values['type'])) {
// Rules supplies a EntityformType object instead of string.
if (is_object($values['type'])) {
if (get_class($values['type']) == 'EntityformType') {
$values['type'] = $values['type']->type;
}
else {
// This should never happen.
throw new EntityMalformedException("Object sent for EntityformType not of class EntityformType.");
}
}
$type = entityform_get_types($values['type']);
}
if (empty($type)) {
return NULL;
}
// Add values that are specific to our Entityform.
$values += array(
'is_new' => TRUE,
'title' => '',
'created' => '',
'changed' => '',
'data' => '',
);
$entityform = parent::create($values);
return $entityform;
}