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) { ...@@ -103,7 +103,7 @@ function forum_form_submit($form, &$form_state) {
// @todo Set explicit entity properties instead of arbitrary form values. // @todo Set explicit entity properties instead of arbitrary form values.
form_state_values_clean($form_state); form_state_values_clean($form_state);
$term = entity_create('taxonomy_term', $form_state['values']); $term = entity_create('taxonomy_term', $form_state['values']);
$status = taxonomy_term_save($term); $status = $term->save();
switch ($status) { switch ($status) {
case SAVED_NEW: case SAVED_NEW:
if ($container) { if ($container) {
......
...@@ -44,7 +44,7 @@ function forum_enable() { ...@@ -44,7 +44,7 @@ function forum_enable() {
'module' => 'forum', 'module' => 'forum',
'weight' => -10, 'weight' => -10,
)); ));
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
} }
$config->set('vocabulary', $vocabulary->id())->save(); $config->set('vocabulary', $vocabulary->id())->save();
} }
...@@ -75,7 +75,7 @@ function forum_enable() { ...@@ -75,7 +75,7 @@ function forum_enable() {
'parent' => array(0), 'parent' => array(0),
'vid' => $vocabulary->id(), 'vid' => $vocabulary->id(),
)); ));
taxonomy_term_save($term); $term->save();
// Create the instance on the bundle. // Create the instance on the bundle.
$instance = array( $instance = array(
......
...@@ -243,7 +243,7 @@ function testAddOrphanTopic() { ...@@ -243,7 +243,7 @@ function testAddOrphanTopic() {
$tids = \Drupal::entityQuery('taxonomy_term') $tids = \Drupal::entityQuery('taxonomy_term')
->condition('vid', $vid) ->condition('vid', $vid)
->execute(); ->execute();
taxonomy_term_delete_multiple($tids); entity_delete_multiple('taxonomy_term', $tids);
// Create an orphan forum item. // Create an orphan forum item.
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->admin_user);
...@@ -321,7 +321,7 @@ private function doAdminTests($user) { ...@@ -321,7 +321,7 @@ private function doAdminTests($user) {
'langcode' => language_default()->langcode, 'langcode' => language_default()->langcode,
'help' => $help, 'help' => $help,
)); ));
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
// Test tags vocabulary form is not affected. // Test tags vocabulary form is not affected.
$this->drupalGet('admin/structure/taxonomy/manage/tags/edit'); $this->drupalGet('admin/structure/taxonomy/manage/tags/edit');
$this->assertFieldByName('op', t('Save'), 'Save button found.'); $this->assertFieldByName('op', t('Save'), 'Save button found.');
......
...@@ -346,7 +346,7 @@ public function testTaxonomyTermHooks() { ...@@ -346,7 +346,7 @@ public function testTaxonomyTermHooks() {
'description' => NULL, 'description' => NULL,
'module' => 'entity_crud_hook_test', 'module' => 'entity_crud_hook_test',
)); ));
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
$term = entity_create('taxonomy_term', array( $term = entity_create('taxonomy_term', array(
...@@ -363,7 +363,7 @@ public function testTaxonomyTermHooks() { ...@@ -363,7 +363,7 @@ public function testTaxonomyTermHooks() {
)); ));
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_save($term); $term->save();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called', 'entity_crud_hook_test_taxonomy_term_presave called',
...@@ -382,7 +382,7 @@ public function testTaxonomyTermHooks() { ...@@ -382,7 +382,7 @@ public function testTaxonomyTermHooks() {
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
$term->name = 'New name'; $term->name = 'New name';
taxonomy_term_save($term); $term->save();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_presave called', 'entity_crud_hook_test_taxonomy_term_presave called',
...@@ -392,7 +392,7 @@ public function testTaxonomyTermHooks() { ...@@ -392,7 +392,7 @@ public function testTaxonomyTermHooks() {
)); ));
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
taxonomy_term_delete($term->id()); $term->delete();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_term_predelete called', 'entity_crud_hook_test_taxonomy_term_predelete called',
...@@ -422,7 +422,7 @@ public function testTaxonomyVocabularyHooks() { ...@@ -422,7 +422,7 @@ public function testTaxonomyVocabularyHooks() {
)); ));
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_presave called', 'entity_crud_hook_test_taxonomy_vocabulary_presave called',
...@@ -441,7 +441,7 @@ public function testTaxonomyVocabularyHooks() { ...@@ -441,7 +441,7 @@ public function testTaxonomyVocabularyHooks() {
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
$vocabulary->name = 'New name'; $vocabulary->name = 'New name';
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_presave called', 'entity_crud_hook_test_taxonomy_vocabulary_presave called',
...@@ -451,7 +451,7 @@ public function testTaxonomyVocabularyHooks() { ...@@ -451,7 +451,7 @@ public function testTaxonomyVocabularyHooks() {
)); ));
$_SESSION['entity_crud_hook_test'] = array(); $_SESSION['entity_crud_hook_test'] = array();
taxonomy_vocabulary_delete($vocabulary->id()); $vocabulary->delete();
$this->assertHookMessageOrder(array( $this->assertHookMessageOrder(array(
'entity_crud_hook_test_taxonomy_vocabulary_predelete called', 'entity_crud_hook_test_taxonomy_vocabulary_predelete called',
......
...@@ -95,7 +95,7 @@ function setUp() { ...@@ -95,7 +95,7 @@ function setUp() {
'name' => $this->xss_label, 'name' => $this->xss_label,
'vid' => 1, 'vid' => 1,
)); ));
taxonomy_term_save($this->term); $this->term->save();
// Create a test node tagged with the test term. // Create a test node tagged with the test term.
$this->node = $this->drupalCreateNode(array( $this->node = $this->drupalCreateNode(array(
......
...@@ -138,7 +138,8 @@ public function buildEntity(array $form, array &$form_state) { ...@@ -138,7 +138,8 @@ public function buildEntity(array $form, array &$form_state) {
// Prevent leading and trailing spaces in term names. // Prevent leading and trailing spaces in term names.
$term->name->value = trim($term->name->value); $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']; $description = $form_state['values']['description'];
$term->description->value = $description['value']; $term->description->value = $description['value'];
$term->format->value = $description['format']; $term->format->value = $description['format'];
...@@ -155,8 +156,7 @@ public function buildEntity(array $form, array &$form_state) { ...@@ -155,8 +156,7 @@ public function buildEntity(array $form, array &$form_state) {
public function save(array $form, array &$form_state) { public function save(array $form, array &$form_state) {
$term = $this->entity; $term = $this->entity;
$status = taxonomy_term_save($term); switch ($term->save()) {
switch ($status) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message(t('Created new term %term.', array('%term' => $term->label()))); 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')); 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) { ...@@ -186,7 +186,7 @@ public function save(array $form, array &$form_state) {
// hierarchy, update the vocabulary immediately. // hierarchy, update the vocabulary immediately.
elseif ($current_parent_count > $previous_parent_count && $form_state['taxonomy']['vocabulary']->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE) { 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; $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(); $form_state['values']['tid'] = $term->id();
......
...@@ -70,7 +70,7 @@ protected function postDelete($entities) { ...@@ -70,7 +70,7 @@ protected function postDelete($entities) {
->execute(); ->execute();
if (!empty($orphans)) { if (!empty($orphans)) {
taxonomy_term_delete_multiple($orphans); entity_delete_multiple('taxonomy_term', $orphans);
} }
} }
......
...@@ -60,7 +60,7 @@ function createTerm($vocabulary) { ...@@ -60,7 +60,7 @@ function createTerm($vocabulary) {
'vid' => $vocabulary->id(), 'vid' => $vocabulary->id(),
'langcode' => LANGUAGE_NOT_SPECIFIED, 'langcode' => LANGUAGE_NOT_SPECIFIED,
)); ));
taxonomy_term_save($term); $term->save();
return $term; return $term;
} }
} }
...@@ -106,7 +106,7 @@ function testTaxonomyTermFieldMultipleVocabularies() { ...@@ -106,7 +106,7 @@ function testTaxonomyTermFieldMultipleVocabularies() {
$this->assertText($term2->label(), 'Term 2 name is displayed.'); $this->assertText($term2->label(), 'Term 2 name is displayed.');
// Delete vocabulary 2. // Delete vocabulary 2.
taxonomy_vocabulary_delete($this->vocabulary2->id()); $this->vocabulary2->delete();
// Re-render the content. // Re-render the content.
$entity = field_test_entity_test_load($id); $entity = field_test_entity_test_load($id);
......
...@@ -130,7 +130,7 @@ function testTaxonomyTermFieldWidgets() { ...@@ -130,7 +130,7 @@ function testTaxonomyTermFieldWidgets() {
$this->assertText($term->label(), 'Term label is displayed.'); $this->assertText($term->label(), 'Term label is displayed.');
// Delete the vocabulary and verify that the widget is gone. // 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->drupalGet('test-entity/add/test_bundle');
$this->assertNoFieldByName("{$this->field_name}[$langcode]", '', 'Widget is not displayed'); $this->assertNoFieldByName("{$this->field_name}[$langcode]", '', 'Widget is not displayed');
} }
...@@ -159,7 +159,7 @@ function testTaxonomyTermFieldChangeMachineName() { ...@@ -159,7 +159,7 @@ function testTaxonomyTermFieldChangeMachineName() {
// Change the machine name. // Change the machine name.
$new_name = drupal_strtolower($this->randomName()); $new_name = drupal_strtolower($this->randomName());
$this->vocabulary->vid = $new_name; $this->vocabulary->vid = $new_name;
taxonomy_vocabulary_save($this->vocabulary); $this->vocabulary->save();
// Check that the field instance is still attached to the vocabulary. // Check that the field instance is still attached to the vocabulary.
$field = field_info_field($this->field_name); $field = field_info_field($this->field_name);
......
...@@ -209,7 +209,7 @@ function testTaxonomyTermHierarchyBreadcrumbs() { ...@@ -209,7 +209,7 @@ function testTaxonomyTermHierarchyBreadcrumbs() {
$term1 = $this->createTerm($this->vocabulary); $term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary);
$term1->parent = array($term2->id()); $term1->parent = array($term2->id());
taxonomy_term_save($term1); $term1->save();
// Verify that the page breadcrumbs include a link to the parent term. // Verify that the page breadcrumbs include a link to the parent term.
$this->drupalGet('taxonomy/term/' . $term1->id()); $this->drupalGet('taxonomy/term/' . $term1->id());
......
...@@ -82,14 +82,14 @@ function testTaxonomyTermHierarchy() { ...@@ -82,14 +82,14 @@ function testTaxonomyTermHierarchy() {
// Load and save a term, confirming that parents are still set. // Load and save a term, confirming that parents are still set.
$term = taxonomy_term_load($term2->id()); $term = taxonomy_term_load($term2->id());
taxonomy_term_save($term); $term->save();
$parents = taxonomy_term_load_parents($term2->id()); $parents = taxonomy_term_load_parents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]), 'Parent found correctly.'); $this->assertTrue(isset($parents[$term1->id()]), 'Parent found correctly.');
// Create a third term and save this as a parent of term2. // Create a third term and save this as a parent of term2.
$term3 = $this->createTerm($this->vocabulary); $term3 = $this->createTerm($this->vocabulary);
$term2->parent = array($term1->id(), $term3->id()); $term2->parent = array($term1->id(), $term3->id());
taxonomy_term_save($term2); $term2->save();
$parents = taxonomy_term_load_parents($term2->id()); $parents = taxonomy_term_load_parents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.'); $this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.');
} }
...@@ -239,15 +239,15 @@ function testTermAutocompletion() { ...@@ -239,15 +239,15 @@ function testTermAutocompletion() {
// Add a term with a slash in the name. // Add a term with a slash in the name.
$first_term = $this->createTerm($this->vocabulary); $first_term = $this->createTerm($this->vocabulary);
$first_term->name = '10/16/2011'; $first_term->name = '10/16/2011';
taxonomy_term_save($first_term); $first_term->save();
// Add another term that differs after the slash character. // Add another term that differs after the slash character.
$second_term = $this->createTerm($this->vocabulary); $second_term = $this->createTerm($this->vocabulary);
$second_term->name = '10/17/2011'; $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. // Add another term that has both a comma and a slash character.
$third_term = $this->createTerm($this->vocabulary); $third_term = $this->createTerm($this->vocabulary);
$third_term->name = 'term with, a comma and / a slash'; $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. // Try to autocomplete a term name that matches both terms.
// We should get both term in a json encoded string. // We should get both term in a json encoded string.
...@@ -332,7 +332,7 @@ function testTermInterface() { ...@@ -332,7 +332,7 @@ function testTermInterface() {
$this->assertPattern('|class="taxonomy-term-description"|', 'Term page displayed the term description element.'); $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. // Check that it does NOT show a description when description is blank.
$term->description = ''; $term->description = '';
taxonomy_term_save($term); $term->save();
$this->drupalGet('taxonomy/term/' . $term->id()); $this->drupalGet('taxonomy/term/' . $term->id());
$this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.'); $this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.');
...@@ -476,7 +476,7 @@ function testTaxonomyGetTermByName() { ...@@ -476,7 +476,7 @@ function testTaxonomyGetTermByName() {
'name' => $term->label(), 'name' => $term->label(),
'vid' => $new_vocabulary->id(), 'vid' => $new_vocabulary->id(),
)); ));
taxonomy_term_save($new_term); $new_term->save();
// Load multiple terms with the same name. // Load multiple terms with the same name.
$terms = taxonomy_term_load_multiple_by_name($term->label()); $terms = taxonomy_term_load_multiple_by_name($term->label());
......
...@@ -24,12 +24,12 @@ function testTermDelete() { ...@@ -24,12 +24,12 @@ function testTermDelete() {
$vocabulary = $this->createVocabulary(); $vocabulary = $this->createVocabulary();
$valid_term = $this->createTerm($vocabulary); $valid_term = $this->createTerm($vocabulary);
// Delete a valid term. // 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())); $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
$this->assertTrue(empty($terms), 'Vocabulary is empty after deletion'); $this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
// Delete an invalid term. Should not throw any notices. // 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() { ...@@ -45,13 +45,13 @@ function testTaxonomyVocabularyTree() {
// $term[2] is a child of 1 and 5. // $term[2] is a child of 1 and 5.
$term[2]->parent = array($term[1]->id(), $term[5]->id()); $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] is a child of 2.
$term[3]->parent = array($term[2]->id()); $term[3]->parent = array($term[2]->id());
taxonomy_term_save($term[3]); $term[3]->save();
// $term[5] is a child of 4. // $term[5] is a child of 4.
$term[5]->parent = array($term[4]->id()); $term[5]->parent = array($term[4]->id());
taxonomy_term_save($term[5]); $term[5]->save();
/** /**
* Expected tree: * Expected tree:
......
...@@ -113,7 +113,7 @@ function testTaxonomyAdminNoVocabularies() { ...@@ -113,7 +113,7 @@ function testTaxonomyAdminNoVocabularies() {
// Delete all vocabularies. // Delete all vocabularies.
$vocabularies = taxonomy_vocabulary_load_multiple(); $vocabularies = taxonomy_vocabulary_load_multiple();
foreach ($vocabularies as $key => $vocabulary) { foreach ($vocabularies as $key => $vocabulary) {
taxonomy_vocabulary_delete($key); $vocabulary->delete();
} }
// Confirm that no vocabularies are found in the database. // Confirm that no vocabularies are found in the database.
$this->assertFalse(taxonomy_vocabulary_load_multiple(), 'No vocabularies found.'); $this->assertFalse(taxonomy_vocabulary_load_multiple(), 'No vocabularies found.');
......
...@@ -41,7 +41,7 @@ function setUp() { ...@@ -41,7 +41,7 @@ function setUp() {
function testTaxonomyVocabularyDeleteWithTerms() { function testTaxonomyVocabularyDeleteWithTerms() {
// Delete any existing vocabularies. // Delete any existing vocabularies.
foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) { foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->id()); $vocabulary->delete();
} }
// Assert that there are no terms left. // Assert that there are no terms left.
...@@ -56,14 +56,14 @@ function testTaxonomyVocabularyDeleteWithTerms() { ...@@ -56,14 +56,14 @@ function testTaxonomyVocabularyDeleteWithTerms() {
// Set up hierarchy. term 2 is a child of 1 and 4 a child of 1 and 2. // 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()); $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()); $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. // Assert that there are now 5 terms.
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField()); $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. // Assert that there are no terms left.
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField()); $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField());
...@@ -81,7 +81,7 @@ function testTaxonomyVocabularyLoadStaticReset() { ...@@ -81,7 +81,7 @@ function testTaxonomyVocabularyLoadStaticReset() {
$vocabulary = $original_vocabulary; $vocabulary = $original_vocabulary;
$vocabulary->name = $this->randomName(); $vocabulary->name = $this->randomName();
$vocabulary->description = $this->randomName(); $vocabulary->description = $this->randomName();
taxonomy_vocabulary_save($vocabulary); $vocabulary->save();
// Load the vocabulary. // Load the vocabulary.
$new_vocabulary = taxonomy_vocabulary_load($original_vocabulary->id()); $new_vocabulary = taxonomy_vocabulary_load($original_vocabulary->id());
...@@ -89,7 +89,7 @@ function testTaxonomyVocabularyLoadStaticReset() { ...@@ -89,7 +89,7 @@ function testTaxonomyVocabularyLoadStaticReset() {
$this->assertEqual($new_vocabulary->name, $vocabulary->name); $this->assertEqual($new_vocabulary->name, $vocabulary->name);
// Delete the vocabulary. // Delete the vocabulary.
taxonomy_vocabulary_delete($this->vocabulary->id()); $this->vocabulary->delete();
$vocabularies = taxonomy_vocabulary_load_multiple(); $vocabularies = taxonomy_vocabulary_load_multiple();
$this->assertTrue(!isset($vocabularies[$this->vocabulary->id()]), 'The vocabulary was deleted.'); $this->assertTrue(!isset($vocabularies[$this->vocabulary->id()]), 'The vocabulary was deleted.');
} }
...@@ -101,19 +101,19 @@ function testTaxonomyVocabularyLoadMultiple() { ...@@ -101,19 +101,19 @@ function testTaxonomyVocabularyLoadMultiple() {
// Delete any existing vocabularies. // Delete any existing vocabularies.
foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) { foreach (taxonomy_vocabulary_load_multiple() as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->id()); $vocabulary->delete();
} }
// Create some vocabularies and assign weights. // Create some vocabularies and assign weights.
$vocabulary1 = $this->createVocabulary(); $vocabulary1 = $this->createVocabulary();
$vocabulary1->weight = 0; $vocabulary1->weight = 0;
taxonomy_vocabulary_save($vocabulary1); $vocabulary1->save();
$vocabulary2 = $this->createVocabulary(); $vocabulary2 = $this->createVocabulary();
$vocabulary2->weight = 1; $vocabulary2->weight = 1;
taxonomy_vocabulary_save($vocabulary2); $vocabulary2->save();
$vocabulary3 = $this->createVocabulary(); $vocabulary3 = $this->createVocabulary();
$vocabulary3->weight = 2; $vocabulary3->weight = 2;
taxonomy_vocabulary_save($vocabulary3); $vocabulary3->save();
// Fetch the names for all vocabularies, confirm that they are keyed by // Fetch the names for all vocabularies, confirm that they are keyed by
// machine name. // machine name.
...@@ -157,7 +157,7 @@ function testTaxonomyVocabularyChangeMachineName() { ...@@ -157,7 +157,7 @@ function testTaxonomyVocabularyChangeMachineName() {
$old_name = $this->vocabulary->id(); $old_name = $this->vocabulary->id();
$new_name = drupal_strtolower($this->randomName()); $new_name = drupal_strtolower($this->randomName());
$this->vocabulary->vid = $new_name; $this->vocabulary->vid = $new_name;
taxonomy_vocabulary_save($this->vocabulary); $this->vocabulary->save();
// Check that entity bundles are properly updated. // Check that entity bundles are properly updated.
$info = entity_get_bundles('taxonomy_term'); $info = entity_get_bundles('taxonomy_term');
...@@ -195,7 +195,7 @@ function testUninstallReinstall() { ...@@ -195,7 +195,7 @@ function testUninstallReinstall() {
// module was uninstalled. Creating a new field with the same name and // 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. // an instance of this field on the same bundle name should be successful.
$this->vocabulary->enforceIsNew(); $this->vocabulary->enforceIsNew();
taxonomy_vocabulary_save($this->vocabulary); $this->vocabulary->save();
field_create_field($this->field_definition); field_create_field($this->field_definition);
field_create_instance($this->instance_definition); field_create_instance($this->instance_definition);
} }
......
...@@ -149,7 +149,7 @@ public function save(array $form, array &$form_state) { ...@@ -149,7 +149,7 @@ public function save(array $form, array &$form_state) {
// Prevent leading and trailing spaces in vocabulary names. // Prevent leading and trailing spaces in vocabulary names.
$vocabulary->name = trim($vocabulary->name); $vocabulary->name = trim($vocabulary->name);
switch (taxonomy_vocabulary_save($vocabulary)) { switch ($vocabulary->save()) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name))); 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')); 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) { ...@@ -54,7 +54,7 @@ protected function preDelete($entities) {
parent::preDelete($entities); parent::preDelete($entities);
// Only load terms without a parent, child terms will get deleted too. // 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(); $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) { ...@@ -84,7 +84,7 @@ function taxonomy_overview_vocabularies_submit($form, &$form_state) {
foreach ($form_state['values']['vocabularies'] as $vid => $vocabulary) { 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']) { 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']; $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.')); drupal_set_message(t('The configuration options have been saved.'));
...@@ -467,7 +467,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) { ...@@ -467,7 +467,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
// Update the vocabulary hierarchy to flat or single hierarchy. // Update the vocabulary hierarchy to flat or single hierarchy.
if ($vocabulary->hierarchy != $hierarchy) { if ($vocabulary->hierarchy != $hierarchy) {
$vocabulary->hierarchy = $hierarchy; $vocabulary->hierarchy = $hierarchy;
taxonomy_vocabulary_save($vocabulary);