Overrides Drupal\Core\Entity\DatabaseStorageController::create().
array $values: An array of values to set, keyed by property name. A value for the vocabulary ID ('vid') is required.
Overrides DatabaseStorageController::create
public function create(array $values) {
$entity = parent::create($values);
// Ensure the vocabulary machine name is initialized as it is used as the
// bundle key. Only attempt to do this if a vocabulary ID is available,
// which might not be the case when creating partial entity structures.
// @todo Move to Term::bundle() once field API has been converted
// to make use of it.
if (!isset($entity->vocabulary_machine_name) && isset($entity->vid)) {
$vocabulary = taxonomy_vocabulary_load($entity->vid);
$entity->vocabulary_machine_name = $vocabulary->machine_name;
}
// Save new terms with no parents by default.
if (!isset($entity->parent)) {
$entity->parent = array(
0,
);
}
return $entity;
}