diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php index 1ebd637..1a1ff0d 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php @@ -161,17 +161,17 @@ public function testConfigEntityReferenceItem() { $this->assertTrue($entity->field_test_taxonomy_vocabulary instanceof FieldItemListInterface, 'Field implements interface.'); $this->assertTrue($entity->field_test_taxonomy_vocabulary[0] instanceof FieldItemInterface, 'Field item implements interface.'); $this->assertEqual($entity->field_test_taxonomy_vocabulary->target_id, $referenced_entity_id); - $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->getName(), $this->vocabulary->getName()); + $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->get('name'), $this->vocabulary->get('name')); $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->id(), $referenced_entity_id); $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->uuid(), $this->vocabulary->uuid()); // Change the name of the term via the reference. $new_name = $this->randomMachineName(); - $entity->field_test_taxonomy_vocabulary->entity->setName($new_name); + $entity->field_test_taxonomy_vocabulary->entity->set('name', $new_name); $entity->field_test_taxonomy_vocabulary->entity->save(); // Verify it is the correct name. $vocabulary = entity_load('taxonomy_vocabulary', $referenced_entity_id); - $this->assertEqual($vocabulary->getName(), $new_name); + $this->assertEqual($vocabulary->get('name'), $new_name); // Make sure the computed term reflects updates to the term id. $vocabulary2 = entity_create('taxonomy_vocabulary', array( @@ -183,7 +183,7 @@ public function testConfigEntityReferenceItem() { $entity->field_test_taxonomy_vocabulary->target_id = $vocabulary2->id(); $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->id(), $vocabulary2->id()); - $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->getName(), $vocabulary2->getName()); + $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->get('name'), $vocabulary2->get('name')); // Delete terms so we have nothing to reference and try again $this->vocabulary->delete(); diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php index d663b75..6199532 100755 --- a/core/modules/forum/src/Tests/ForumTest.php +++ b/core/modules/forum/src/Tests/ForumTest.php @@ -340,16 +340,16 @@ function editForumVocabulary() { $current_vocabulary = entity_load('taxonomy_vocabulary', $vid); // Make sure we actually edited the vocabulary properly. - $this->assertEqual($current_vocabulary->getName(), $edit['name'], 'The name was updated'); + $this->assertEqual($current_vocabulary->get('name'), $edit['name'], 'The name was updated'); $this->assertEqual($current_vocabulary->get('description'), $edit['description'], 'The description was updated'); // Restore the original vocabulary's name and description. - $current_vocabulary->set('name', $original_vocabulary->getName()); + $current_vocabulary->set('name', $original_vocabulary->get('name')); $current_vocabulary->set('description', $original_vocabulary->get('description')); $current_vocabulary->save(); // Reload vocabulary to make sure changes are saved. $current_vocabulary = entity_load('taxonomy_vocabulary', $vid); - $this->assertEqual($current_vocabulary->getName(), $original_vocabulary->getName(), 'The original vocabulary settings were restored'); + $this->assertEqual($current_vocabulary->get('name'), $original_vocabulary->get('name'), 'The original vocabulary settings were restored'); } /** diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php index f805070..4c825eb 100755 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php @@ -46,15 +46,15 @@ public function testTaxonomyVocabulary() { $j = $i + 1; $vocabulary = entity_load('taxonomy_vocabulary', "vocabulary_{$j}_i_{$i}_"); $this->assertEqual(array($vocabulary->id()), entity_load('migration', 'd6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j))); - $this->assertEqual($vocabulary->getName(), "vocabulary $j (i=$i)"); + $this->assertEqual($vocabulary->get('name'), "vocabulary $j (i=$i)"); $this->assertEqual($vocabulary->get('description'), "description of vocabulary $j (i=$i)"); - $this->assertEqual($vocabulary->getHierarchy(), $i); + $this->assertEqual($vocabulary->get('hierarchy'), $i); $this->assertEqual($vocabulary->get('weight'), 4 + $i); } $vocabulary = entity_load('taxonomy_vocabulary', 'vocabulary_name_much_longer_than'); - $this->assertEqual($vocabulary->getName(), 'vocabulary name much longer than thirty two characters'); + $this->assertEqual($vocabulary->get('name'), 'vocabulary name much longer than thirty two characters'); $this->assertEqual($vocabulary->get('description'), 'description of vocabulary name much longer than thirty two characters'); - $this->assertEqual($vocabulary->getHierarchy(), 3); + $this->assertEqual($vocabulary->get('hierarchy'), 3); $this->assertEqual($vocabulary->get('weight'), 7); } diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php index fca861a..e5a44f8 100644 --- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php @@ -450,7 +450,7 @@ public function testTaxonomyVocabularyHooks() { )); $_SESSION['entity_crud_hook_test'] = array(); - $vocabulary->setName('New name'); + $vocabulary->set('name', 'New name'); $vocabulary->save(); $this->assertHookMessageOrder(array( diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index defef87..35013e9 100755 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -425,7 +425,7 @@ function hook_mail($key, &$message, $params) { '%term_description' => $entity->description, '%term_id' => $entity->id(), '%vocabulary_name' => $vocabulary->getName(), - '%vocabulary_description' => $vocabulary->get('description'), + '%vocabulary_description' => $vocabulary->getDescription(), '%vocabulary_id' => $vocabulary->id(), ); } diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index db72aa7..5bb7982 100755 --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -127,6 +127,13 @@ public function id() { /** * {@inheritdoc} */ + public function getDescription() { + return $this->description; + } + + /** + * {@inheritdoc} + */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); diff --git a/core/modules/taxonomy/src/Tests/EfqTest.php b/core/modules/taxonomy/src/Tests/EfqTest.php index 364f181..59ae716 100644 --- a/core/modules/taxonomy/src/Tests/EfqTest.php +++ b/core/modules/taxonomy/src/Tests/EfqTest.php @@ -55,7 +55,7 @@ function testTaxonomyEfq() { ->condition('vid', $vocabulary2->id()) ->execute(); sort($result); - $this->assertEqual(array_keys($terms2), $result, format_string('Taxonomy terms from the %name vocabulary were retrieved by entity query.', array('%name' => $vocabulary2->getName()))); + $this->assertEqual(array_keys($terms2), $result, format_string('Taxonomy terms from the %name vocabulary were retrieved by entity query.', array('%name' => $vocabulary2->get('name')))); $tid = reset($result); $ids = (object) array( 'entity_type' => 'taxonomy_term', diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php index 95784d9..19760f5 100644 --- a/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -72,7 +72,7 @@ function testTaxonomyTermHierarchy() { // Check that hierarchy is flat. $vocabulary = entity_load('taxonomy_vocabulary', $this->vocabulary->id()); - $this->assertEqual(0, $vocabulary->getHierarchy(), 'Vocabulary is flat.'); + $this->assertEqual(0, $vocabulary->get('hierarchy'), 'Vocabulary is flat.'); // Edit $term2, setting $term1 as parent. $edit = array(); diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index b8fa469..1ac3896 100755 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -88,7 +88,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:url]'] = $term1->url('canonical', array('absolute' => TRUE)); $tests['[term:node-count]'] = 0; $tests['[term:parent:name]'] = '[term:parent:name]'; - $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->getName()); + $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->get('name')); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId())); @@ -105,7 +105,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:parent:name]'] = String::checkPlain($term1->getName()); $tests['[term:parent:url]'] = $term1->url('canonical', array('absolute' => TRUE)); $tests['[term:parent:parent:name]'] = '[term:parent:parent:name]'; - $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->getName()); + $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->get('name')); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); @@ -119,7 +119,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:name]'] = $term2->getName(); $tests['[term:description]'] = $term2->getDescription(); $tests['[term:parent:name]'] = $term1->getName(); - $tests['[term:vocabulary:name]'] = $this->vocabulary->getName(); + $tests['[term:vocabulary:name]'] = $this->vocabulary->get('name'); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); @@ -129,7 +129,7 @@ function testTaxonomyTokenReplacement() { // Generate and test sanitized tokens. $tests = array(); $tests['[vocabulary:vid]'] = $this->vocabulary->id(); - $tests['[vocabulary:name]'] = String::checkPlain($this->vocabulary->getName()); + $tests['[vocabulary:name]'] = String::checkPlain($this->vocabulary->get('name')); $tests['[vocabulary:description]'] = Xss::filter($this->vocabulary->get('description')); $tests['[vocabulary:node-count]'] = 1; $tests['[vocabulary:term-count]'] = 2; @@ -143,7 +143,7 @@ function testTaxonomyTokenReplacement() { } // Generate and test unsanitized tokens. - $tests['[vocabulary:name]'] = $this->vocabulary->getName(); + $tests['[vocabulary:name]'] = $this->vocabulary->get('name'); $tests['[vocabulary:description]'] = $this->vocabulary->get('description'); foreach ($tests as $input => $expected) { diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index 7b96a22..0fbaa09 100755 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -70,17 +70,17 @@ function testTaxonomyVocabularyDeleteWithTerms() { function testTaxonomyVocabularyLoadStaticReset() { $original_vocabulary = entity_load('taxonomy_vocabulary', $this->vocabulary->id()); $this->assertTrue(is_object($original_vocabulary), 'Vocabulary loaded successfully.'); - $this->assertEqual($this->vocabulary->getName(), $original_vocabulary->getName(), 'Vocabulary loaded successfully.'); + $this->assertEqual($this->vocabulary->get('name'), $original_vocabulary->get('name'), 'Vocabulary loaded successfully.'); // Change the name and description. $vocabulary = $original_vocabulary; - $vocabulary->setName($this->randomMachineName()); + $vocabulary->set('name', $this->randomMachineName()); $vocabulary->set('description', $this->randomMachineName()); $vocabulary->save(); // Load the vocabulary. $new_vocabulary = entity_load('taxonomy_vocabulary', $original_vocabulary->id()); - $this->assertEqual($new_vocabulary->getName(), $vocabulary->getName(), 'The vocabulary was loaded.'); + $this->assertEqual($new_vocabulary->get('name'), $vocabulary->get('name'), 'The vocabulary was loaded.'); // Delete the vocabulary. $this->vocabulary->delete(); @@ -129,12 +129,12 @@ function testTaxonomyVocabularyLoadMultiple() { // Test loading vocabularies by their properties. $controller = $this->container->get('entity.manager')->getStorage('taxonomy_vocabulary'); // Fetch vocabulary 1 by name. - $vocabulary = current($controller->loadByProperties(array('name' => $vocabulary1->getName()))); + $vocabulary = current($controller->loadByProperties(array('name' => $vocabulary1->get('name')))); $this->assertEqual($vocabulary->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by name.'); // Fetch vocabulary 2 by name and ID. $vocabulary = current($controller->loadByProperties(array( - 'name' => $vocabulary2->getName(), + 'name' => $vocabulary2->get('name'), 'vid' => $vocabulary2->id(), ))); $this->assertEqual($vocabulary->id(), $vocabulary2->id(), 'Vocabulary loaded successfully by name and ID.'); diff --git a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php index 5f55b53..87623a6 100755 --- a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php @@ -137,12 +137,12 @@ function testTaxonomyAdminDeletingVocabulary() { // Delete the vocabulary. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id()); $this->clickLink(t('Delete')); - $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->getName())), '[confirm deletion] Asks for confirmation.'); + $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->get('name'))), '[confirm deletion] Asks for confirmation.'); $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[confirm deletion] Inform that all terms will be deleted.'); // Confirm deletion. $this->drupalPostForm(NULL, NULL, t('Delete')); - $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->getName())), 'Vocabulary deleted.'); + $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->get('name'))), 'Vocabulary deleted.'); $this->container->get('entity.manager')->getStorage('taxonomy_vocabulary')->resetCache(); $this->assertFalse(entity_load('taxonomy_vocabulary', $vid), 'Vocabulary not found.'); } diff --git a/core/modules/taxonomy/src/VocabularyForm.php b/core/modules/taxonomy/src/VocabularyForm.php index e94ecc2..e483588 100755 --- a/core/modules/taxonomy/src/VocabularyForm.php +++ b/core/modules/taxonomy/src/VocabularyForm.php @@ -49,7 +49,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['description'] = array( '#type' => 'textfield', '#title' => $this->t('Description'), - '#default_value' => $vocabulary->get('description'), + '#default_value' => $vocabulary->getDescription(), ); // $form['langcode'] is not wrapped in an diff --git a/core/modules/taxonomy/src/VocabularyInterface.php b/core/modules/taxonomy/src/VocabularyInterface.php index b7c4ed7..ea0636d 100755 --- a/core/modules/taxonomy/src/VocabularyInterface.php +++ b/core/modules/taxonomy/src/VocabularyInterface.php @@ -16,22 +16,31 @@ interface VocabularyInterface extends ConfigEntityInterface, ThirdPartySettingsInterface { /** + * Returns the vocabulary name. + * + * @return string + * The vocabulary name. + */ + public function getName(); + + /** * Sets the vocabulary name. * * @param string $name * The vocabulary name. + * * @return \Drupal\taxonomy\VocabularyInterface * The called Vocabulary entity. */ public function setName($name); /** - * Returns the vocabulary name. + * Returns the vocabulary hierarchy. * - * @return string - * The vocabulary name. + * @return integer + * The vocabulary hierarchy. */ - public function getName(); + public function getHierarchy(); /** * Sets the vocabulary hierarchy. @@ -49,11 +58,10 @@ public function getName(); public function setHierarchy($hierarchy); /** - * Returns the vocabulary hierarchy. + * Returns the vocabulary description. * - * @return integer - * The vocabulary hierarchy. + * @return string + * The vocabulary description. */ - public function getHierarchy(); - + public function getDescription(); } diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index bd14e01..8d00fcc 100755 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -165,7 +165,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = break; case 'description': - $replacements[$original] = $sanitize ? Xss::filter($vocabulary->get('description')) : $vocabulary->get('description'); + $replacements[$original] = $sanitize ? Xss::filter($vocabulary->getDescription()) : $vocabulary->getDescription(); break; case 'term-count':