function TermStorage::create
Same name in other branches
- 9 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::create()
- 8.9.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::create()
- 11.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::create()
Parameters
array $values: An array of values to set, keyed by property name. A value for the vocabulary ID ('vid') is required.
Overrides ContentEntityStorageBase::create
File
-
core/
modules/ taxonomy/ src/ TermStorage.php, line 69
Class
- TermStorage
- Defines a Controller class for taxonomy terms.
Namespace
Drupal\taxonomyCode
public function create(array $values = []) {
// Save new terms with no parents by default.
if (empty($values['parent'])) {
$values['parent'] = [
0,
];
}
$entity = parent::create($values);
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.