Commit 5838ea9a authored by alexpott's avatar alexpott

Issue #1980982 by andypost, aspilicious: Clean-up procedural wrappers for taxonomy.

parent d78f5a96
......@@ -103,7 +103,7 @@ function forum_form_submit($form, &$form_state) {
// @todo Set explicit entity properties instead of arbitrary form values.
form_state_values_clean($form_state);
$term = entity_create('taxonomy_term', $form_state['values']);
$status = taxonomy_term_save($term);
$status = $term->save();
switch ($status) {
case SAVED_NEW:
if ($container) {
......
......@@ -44,7 +44,7 @@ function forum_enable() {
'module' => 'forum',
'weight' => -10,
));
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
}
$config->set('vocabulary', $vocabulary->id())->save();
}
......@@ -75,7 +75,7 @@ function forum_enable() {
'parent' => array(0),
'vid' => $vocabulary->id(),
));
taxonomy_term_save($term);
$term->save();
// Create the instance on the bundle.
$instance = array(
......
......@@ -243,7 +243,7 @@ function testAddOrphanTopic() {
$tids = \Drupal::entityQuery('taxonomy_term')
->condition('vid', $vid)
->execute();
taxonomy_term_delete_multiple($tids);
entity_delete_multiple('taxonomy_term', $tids);
// Create an orphan forum item.
$this->drupalLogin($this->admin_user);
......@@ -321,7 +321,7 @@ private function doAdminTests($user) {
'langcode' => language_default()->langcode,
'help' => $help,
));
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
// Test tags vocabulary form is not affected.
$this->drupalGet('admin/structure/taxonomy/manage/tags/edit');
$this->assertFieldByName('op', t('Save'), 'Save button found.');
......
......@@ -346,7 +346,7 @@ public function testTaxonomyTermHooks() {
'description' => NULL,
'module' => 'entity_crud_hook_test',
));
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
$_SESSION['entity_crud_hook_test'] = array();
$term = entity_create('taxonomy_term', array(
......@@ -363,7 +363,7 @@ public function testTaxonomyTermHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_save($term);
$term->save();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called',
......@@ -382,7 +382,7 @@ public function testTaxonomyTermHooks() {
$_SESSION['entity_crud_hook_test'] = array();
$term->name = 'New name';
taxonomy_term_save($term);
$term->save();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called',
......@@ -392,7 +392,7 @@ public function testTaxonomyTermHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_delete($term->id());
$term->delete();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_predelete called',
......@@ -422,7 +422,7 @@ public function testTaxonomyVocabularyHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_presave called',
......@@ -441,7 +441,7 @@ public function testTaxonomyVocabularyHooks() {
$_SESSION['entity_crud_hook_test'] = array();
$vocabulary->name = 'New name';
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_presave called',
......@@ -451,7 +451,7 @@ public function testTaxonomyVocabularyHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
taxonomy_vocabulary_delete($vocabulary->id());
$vocabulary->delete();
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_predelete called',
......
......@@ -95,7 +95,7 @@ function setUp() {
'name' => $this->xss_label,
'vid' => 1,
));
taxonomy_term_save($this->term);
$this->term->save();
// Create a test node tagged with the test term.
$this->node = $this->drupalCreateNode(array(
......
......@@ -138,7 +138,8 @@ public function buildEntity(array $form, array &$form_state) {
// Prevent leading and trailing spaces in term names.
$term->name->value = trim($term->name->value);
// Convert text_format field into values expected by taxonomy_term_save().
// Convert text_format field into values expected by
// \Drupal\Core\Entity\Entity::save() method.
$description = $form_state['values']['description'];
$term->description->value = $description['value'];
$term->format->value = $description['format'];
......@@ -155,8 +156,7 @@ public function buildEntity(array $form, array &$form_state) {
public function save(array $form, array &$form_state) {
$term = $this->entity;
$status = taxonomy_term_save($term);
switch ($status) {
switch ($term->save()) {
case SAVED_NEW:
drupal_set_message(t('Created new term %term.', array('%term' => $term->label())));
watchdog('taxonomy', 'Created new term %term.', array('%term' => $term->label()), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->id() . '/edit'));
......@@ -186,7 +186,7 @@ public function save(array $form, array &$form_state) {
// hierarchy, update the vocabulary immediately.
elseif ($current_parent_count > $previous_parent_count && $form_state['taxonomy']['vocabulary']->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE) {
$form_state['taxonomy']['vocabulary']->hierarchy = $current_parent_count == 1 ? TAXONOMY_HIERARCHY_SINGLE : TAXONOMY_HIERARCHY_MULTIPLE;
taxonomy_vocabulary_save($form_state['taxonomy']['vocabulary']);
$form_state['taxonomy']['vocabulary']->save();
}
$form_state['values']['tid'] = $term->id();
......
......@@ -70,7 +70,7 @@ protected function postDelete($entities) {
->execute();
if (!empty($orphans)) {
taxonomy_term_delete_multiple($orphans);
entity_delete_multiple('taxonomy_term', $orphans);
}
}
......
......@@ -60,7 +60,7 @@ function createTerm($vocabulary) {
'vid' => $vocabulary->id(),
'langcode' => LANGUAGE_NOT_SPECIFIED,
));
taxonomy_term_save($term);
$term->save();
return $term;
}
}
......@@ -106,7 +106,7 @@ function testTaxonomyTermFieldMultipleVocabularies() {
$this->assertText($term2->label(), 'Term 2 name is displayed.');
// Delete vocabulary 2.
taxonomy_vocabulary_delete($this->vocabulary2->id());
$this->vocabulary2->delete();
// Re-render the content.
$entity = field_test_entity_test_load($id);
......
......@@ -130,7 +130,7 @@ function testTaxonomyTermFieldWidgets() {
$this->assertText($term->label(), 'Term label is displayed.');
// Delete the vocabulary and verify that the widget is gone.
taxonomy_vocabulary_delete($this->vocabulary->id());
$this->vocabulary->delete();
$this->drupalGet('test-entity/add/test_bundle');
$this->assertNoFieldByName("{$this->field_name}[$langcode]", '', 'Widget is not displayed');
}
......@@ -159,7 +159,7 @@ function testTaxonomyTermFieldChangeMachineName() {
// Change the machine name.
$new_name = drupal_strtolower($this->randomName());
$this->vocabulary->vid = $new_name;
taxonomy_vocabulary_save($this->vocabulary);
$this->vocabulary->save();
// Check that the field instance is still attached to the vocabulary.
$field = field_info_field($this->field_name);
......
......@@ -209,7 +209,7 @@ function testTaxonomyTermHierarchyBreadcrumbs() {
$term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
$term1->parent = array($term2->id());
taxonomy_term_save($term1);
$term1->save();
// Verify that the page breadcrumbs include a link to the parent term.
$this->drupalGet('taxonomy/term/' . $term1->id());
......
......@@ -82,14 +82,14 @@ function testTaxonomyTermHierarchy() {
// Load and save a term, confirming that parents are still set.
$term = taxonomy_term_load($term2->id());
taxonomy_term_save($term);
$term->save();
$parents = taxonomy_term_load_parents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]), 'Parent found correctly.');
// Create a third term and save this as a parent of term2.
$term3 = $this->createTerm($this->vocabulary);
$term2->parent = array($term1->id(), $term3->id());
taxonomy_term_save($term2);
$term2->save();
$parents = taxonomy_term_load_parents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.');
}
......@@ -239,15 +239,15 @@ function testTermAutocompletion() {
// Add a term with a slash in the name.
$first_term = $this->createTerm($this->vocabulary);
$first_term->name = '10/16/2011';
taxonomy_term_save($first_term);
$first_term->save();
// Add another term that differs after the slash character.
$second_term = $this->createTerm($this->vocabulary);
$second_term->name = '10/17/2011';
taxonomy_term_save($second_term);
$second_term->save();
// Add another term that has both a comma and a slash character.
$third_term = $this->createTerm($this->vocabulary);
$third_term->name = 'term with, a comma and / a slash';
taxonomy_term_save($third_term);
$third_term->save();
// Try to autocomplete a term name that matches both terms.
// We should get both term in a json encoded string.
......@@ -332,7 +332,7 @@ function testTermInterface() {
$this->assertPattern('|class="taxonomy-term-description"|', 'Term page displayed the term description element.');
// Check that it does NOT show a description when description is blank.
$term->description = '';
taxonomy_term_save($term);
$term->save();
$this->drupalGet('taxonomy/term/' . $term->id());
$this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.');
......@@ -476,7 +476,7 @@ function testTaxonomyGetTermByName() {
'name' => $term->label(),
'vid' => $new_vocabulary->id(),
));
taxonomy_term_save($new_term);
$new_term->save();
// Load multiple terms with the same name.
$terms = taxonomy_term_load_multiple_by_name($term->label());
......
......@@ -24,12 +24,12 @@ function testTermDelete() {
$vocabulary = $this->createVocabulary();
$valid_term = $this->createTerm($vocabulary);
// Delete a valid term.
taxonomy_term_delete($valid_term->id());
$valid_term->delete();
$terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
$this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
// Delete an invalid term. Should not throw any notices.
taxonomy_term_delete(42);
entity_delete_multiple('taxonomy_term', array(42));
}
/**
......@@ -45,13 +45,13 @@ function testTaxonomyVocabularyTree() {
// $term[2] is a child of 1 and 5.
$term[2]->parent = array($term[1]->id(), $term[5]->id());
taxonomy_term_save($term[2]);
$term[2]->save();
// $term[3] is a child of 2.
$term[3]->parent = array($term[2]->id());
taxonomy_term_save($term[3]);
$term[3]->save();
// $term[5] is a child of 4.
$term[5]->parent = array($term[4]->id());
taxonomy_term_save($term[5]);
$term[5]->save();
/**
* Expected tree:
......
......@@ -113,7 +113,7 @@ function testTaxonomyAdminNoVocabularies() {
// Delete all vocabularies.
$vocabularies = taxonomy_vocabulary_load_multiple();
foreach ($vocabularies as $key => $vocabulary) {
taxonomy_vocabulary_delete($key);
$vocabulary->delete();
}
// Confirm that no vocabularies are found in the database.
$this->assertFalse(taxonomy_vocabulary_load_multiple(), 'No vocabularies found.');
......
......@@ -41,7 +41,7 @@ function setUp() {
function testTaxonomyVocabularyDeleteWithTerms() {
// Delete any existing vocabularies.
foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->id());
$vocabulary->delete();
}
// Assert that there are no terms left.
......@@ -56,14 +56,14 @@ function testTaxonomyVocabularyDeleteWithTerms() {
// Set up hierarchy. term 2 is a child of 1 and 4 a child of 1 and 2.
$terms[2]->parent = array($terms[1]->id());
taxonomy_term_save($terms[2]);
$terms[2]->save();
$terms[4]->parent = array($terms[1]->id(), $terms[2]->id());
taxonomy_term_save($terms[4]);
$terms[4]->save();
// Assert that there are now 5 terms.
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField());
taxonomy_vocabulary_delete($vocabulary->id());
$vocabulary->delete();
// Assert that there are no terms left.
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField());
......@@ -81,7 +81,7 @@ function testTaxonomyVocabularyLoadStaticReset() {
$vocabulary = $original_vocabulary;
$vocabulary->name = $this->randomName();
$vocabulary->description = $this->randomName();
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
// Load the vocabulary.
$new_vocabulary = taxonomy_vocabulary_load($original_vocabulary->id());
......@@ -89,7 +89,7 @@ function testTaxonomyVocabularyLoadStaticReset() {
$this->assertEqual($new_vocabulary->name, $vocabulary->name);
// Delete the vocabulary.
taxonomy_vocabulary_delete($this->vocabulary->id());
$this->vocabulary->delete();
$vocabularies = taxonomy_vocabulary_load_multiple();
$this->assertTrue(!isset($vocabularies[$this->vocabulary->id()]), 'The vocabulary was deleted.');
}
......@@ -101,19 +101,19 @@ function testTaxonomyVocabularyLoadMultiple() {
// Delete any existing vocabularies.
foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->id());
$vocabulary->delete();
}
// Create some vocabularies and assign weights.
$vocabulary1 = $this->createVocabulary();
$vocabulary1->weight = 0;
taxonomy_vocabulary_save($vocabulary1);
$vocabulary1->save();
$vocabulary2 = $this->createVocabulary();
$vocabulary2->weight = 1;
taxonomy_vocabulary_save($vocabulary2);
$vocabulary2->save();
$vocabulary3 = $this->createVocabulary();
$vocabulary3->weight = 2;
taxonomy_vocabulary_save($vocabulary3);
$vocabulary3->save();
// Fetch the names for all vocabularies, confirm that they are keyed by
// machine name.
......@@ -157,7 +157,7 @@ function testTaxonomyVocabularyChangeMachineName() {
$old_name = $this->vocabulary->id();
$new_name = drupal_strtolower($this->randomName());
$this->vocabulary->vid = $new_name;
taxonomy_vocabulary_save($this->vocabulary);
$this->vocabulary->save();
// Check that entity bundles are properly updated.
$info = entity_get_bundles('taxonomy_term');
......@@ -195,7 +195,7 @@ function testUninstallReinstall() {
// module was uninstalled. Creating a new field with the same name and
// an instance of this field on the same bundle name should be successful.
$this->vocabulary->enforceIsNew();
taxonomy_vocabulary_save($this->vocabulary);
$this->vocabulary->save();
field_create_field($this->field_definition);
field_create_instance($this->instance_definition);
}
......
......@@ -149,7 +149,7 @@ public function save(array $form, array &$form_state) {
// Prevent leading and trailing spaces in vocabulary names.
$vocabulary->name = trim($vocabulary->name);
switch (taxonomy_vocabulary_save($vocabulary)) {
switch ($vocabulary->save()) {
case SAVED_NEW:
drupal_set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name)));
watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/edit'));
......
......@@ -54,7 +54,7 @@ protected function preDelete($entities) {
parent::preDelete($entities);
// Only load terms without a parent, child terms will get deleted too.
$tids = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid IN (:vids) AND th.parent = 0', array(':vids' => array_keys($entities)))->fetchCol();
taxonomy_term_delete_multiple($tids);
entity_delete_multiple('taxonomy_term', $tids);
}
/**
......
......@@ -84,7 +84,7 @@ function taxonomy_overview_vocabularies_submit($form, &$form_state) {
foreach ($form_state['values']['vocabularies'] as $vid => $vocabulary) {
if (isset($form['vocabularies'][$vid]['#vocabulary']) && $form['vocabularies'][$vid]['#vocabulary']->weight != $form_state['values']['vocabularies'][$vid]['weight']) {
$form['vocabularies'][$vid]['#vocabulary']->weight = $form_state['values']['vocabularies'][$vid]['weight'];
taxonomy_vocabulary_save($form['vocabularies'][$vid]['#vocabulary']);
$form['vocabularies'][$vid]['#vocabulary']->save();
}
}
drupal_set_message(t('The configuration options have been saved.'));
......@@ -467,7 +467,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
// Update the vocabulary hierarchy to flat or single hierarchy.
if ($vocabulary->hierarchy != $hierarchy) {
$vocabulary->hierarchy = $hierarchy;
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
}
drupal_set_message(t('The configuration options have been saved.'));
}
......@@ -513,7 +513,7 @@ function taxonomy_term_confirm_delete($form, &$form_state, Term $term) {
* @see taxonomy_term_confirm_delete()
*/
function taxonomy_term_confirm_delete_submit($form, &$form_state) {
taxonomy_term_delete($form_state['values']['tid']);
entity_delete_multiple('taxonomy_term', array($form_state['values']['tid']));
taxonomy_check_vocabulary_hierarchy($form_state['taxonomy']['vocabulary'], $form_state['values']);
drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
......@@ -556,7 +556,7 @@ function taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid) {
* @see taxonomy_vocabulary_confirm_delete()
*/
function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
$status = taxonomy_vocabulary_delete($form_state['values']['vid']);
$form_state['taxonomy']['vocabulary']->delete();
drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
$form_state['redirect'] = 'admin/structure/taxonomy';
......
......@@ -89,15 +89,13 @@ function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Plugin\Core\Entity\Voca
/**
* Act before taxonomy vocabulary deletion.
*
* This hook is invoked from taxonomy_vocabulary_delete() before
* entity_bundle_delete() is called and before the vocabulary is actually
* removed from the database.
* This hook is invoked before entity_bundle_delete() is called and before
* the vocabulary is actually removed.
*
* @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary
* The taxonomy vocabulary entity that is about to be deleted.
*
* @see hook_taxonomy_vocabulary_delete()
* @see taxonomy_vocabulary_delete()
*/
function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) {
if (variable_get('taxonomy_' . $vocabulary->id() . '_synonyms', FALSE)) {
......@@ -108,15 +106,13 @@ function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Plugin\Core\Entity\V
/**
* Respond to taxonomy vocabulary deletion.
*
* This hook is invoked from taxonomy_vocabulary_delete() after
* entity_bundle_delete() has been called and after the vocabulary has
* been removed from the database.
* This hook is invoked after entity_bundle_delete() has been called and after
* the vocabulary has been removed.
*
* @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary
* The taxonomy vocabulary entity that has been deleted.
*
* @see hook_taxonomy_vocabulary_predelete()
* @see taxonomy_vocabulary_delete()
*/
function hook_taxonomy_vocabulary_delete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) {
if (variable_get('taxonomy_' . $vocabulary->id() . '_synonyms', FALSE)) {
......@@ -226,14 +222,12 @@ function hook_taxonomy_term_update(Drupal\taxonomy\Term $term) {
/**
* Act before taxonomy term deletion.
*
* This hook is invoked from taxonomy_term_delete() before
* This hook is invoked from taxonomy term deletion before
* field_attach_delete() is called and before the term is actually removed from
* the database.
*
* @param Drupal\taxonomy\Term $term
* The taxonomy term entity that is about to be deleted.
*
* @see taxonomy_term_delete()
*/
function hook_taxonomy_term_predelete(Drupal\taxonomy\Term $term) {
db_delete('term_synoynm')->condition('tid', $term->id())->execute();
......@@ -242,13 +236,11 @@ function hook_taxonomy_term_predelete(Drupal\taxonomy\Term $term) {
/**
* Respond to taxonomy term deletion.
*
* This hook is invoked from taxonomy_term_delete() after field_attach_delete()
* This hook is invoked from taxonomy term deletion after field_attach_delete()
* has been called and after the term has been removed from the database.
*
* @param Drupal\taxonomy\Term $term
* The taxonomy term entity that has been deleted.
*
* @see taxonomy_term_delete()
*/
function hook_taxonomy_term_delete(Drupal\taxonomy\Term $term) {
db_delete('term_synoynm')->condition('tid', $term->id())->execute();
......
......@@ -388,37 +388,6 @@ function taxonomy_admin_paths() {
return $paths;
}
/**
* Saves a vocabulary.
*
* @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary
* The taxonomy vocabulary entity to be saved.
*/
function taxonomy_vocabulary_save(Vocabulary $vocabulary) {
return $vocabulary->save();
}
/**
* Deletes a vocabulary.
*
* @param $vid
* A vocabulary ID.
*
*/
function taxonomy_vocabulary_delete($vid) {
taxonomy_vocabulary_delete_multiple(array($vid));
}
/**
* Deletes vocabularies.
*
* @param $vids
* The vocabulary ids.
*/
function taxonomy_vocabulary_delete_multiple(array $vids) {
entity_delete_multiple('taxonomy_vocabulary', $vids);
}
/**
* Checks and updates the hierarchy flag of a vocabulary.
*
......@@ -458,47 +427,12 @@ function taxonomy_check_vocabulary_hierarchy(Vocabulary $vocabulary, $changed_te
}
if ($hierarchy != $vocabulary->hierarchy) {
$vocabulary->hierarchy = $hierarchy;
taxonomy_vocabulary_save($vocabulary);
$vocabulary->save();
}
return $hierarchy;
}
/**
* Saves a term object to the database.
*
* @param Drupal\taxonomy\Plugin\Core\Entity\Term $term
* The taxonomy term entity to be saved.
*
* @return
* Status constant indicating whether term was inserted (SAVED_NEW) or updated
* (SAVED_UPDATED). When inserting a new term, $term->id() will contain the
* term ID of the newly created term.
*/
function taxonomy_term_save(Term $term) {
return $term->save();
}
/**
* Deletes a term.
*
* @param $tid
* The term ID.
*/
function taxonomy_term_delete($tid) {
taxonomy_term_delete_multiple(array($tid));
}
/**
* Deletes taxonomy terms.
*
* @param $tids
* The term ids to be deleted.
*/
function taxonomy_term_delete_multiple(array $tids) {
entity_delete_multiple('taxonomy_term', $tids);
}
/**
* Generates an array which displays a term detail page.
*
......@@ -1238,7 +1172,7 @@ function taxonomy_field_presave(EntityInterface $entity, $field, $instance, $lan
foreach ($items as $delta => $item) {
if (!$item['tid'] && isset($item['entity'])) {
unset($item['tid']);
taxonomy_term_save($item['entity']);
$item['entity']->save();
$items[$delta]['tid'] = $item['entity']->id();
}
}
......
......@@ -163,7 +163,7 @@ function createTerm($vocabulary) {
'vid' => $vocabulary->id(),
'langcode' => LANGUAGE_NOT_SPECIFIED,
));
taxonomy_term_save($term);
$term->save();
return $term;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment