diff -u b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php --- b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyVocabularyTest.php @@ -49,13 +49,13 @@ $this->assertEqual($vocabulary->getName(), "vocabulary $j (i=$i)"); $this->assertEqual($vocabulary->getDescription(), "description of vocabulary $j (i=$i)"); $this->assertEqual($vocabulary->getHierarchy(), $i); - $this->assertEqual($vocabulary->getWeight(), 4 + $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->getDescription(), 'description of vocabulary name much longer than thirty two characters'); $this->assertEqual($vocabulary->getHierarchy(), 3); - $this->assertEqual($vocabulary->getWeight(), 7); + $this->assertEqual($vocabulary->get('weight'), 7); } } interdiff impossible; taking evasive action reverted: --- b/core/modules/taxonomy/src/Entity/Vocabulary.php +++ a/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -52,21 +52,21 @@ * * @var string */ + public $vid; - protected $vid; /** * Name of the vocabulary. * * @var string */ + public $name; - protected $name; /** * Description of the vocabulary. * * @var string */ + public $description; - protected $description; /** * The type of hierarchy allowed within the vocabulary. @@ -78,14 +78,58 @@ * * @var integer */ + public $hierarchy = TAXONOMY_HIERARCHY_DISABLED; - protected $hierarchy = TAXONOMY_HIERARCHY_DISABLED; /** * The weight of this vocabulary in relation to other vocabularies. * * @var integer */ + public $weight = 0; + + /** + * {@inheritdoc} + */ + public function id() { + return $this->vid; + } + + /** + * {@inheritdoc} + */ + public function postSave(EntityStorageInterface $storage, $update = TRUE) { + parent::postSave($storage, $update); + + if ($update && $this->getOriginalId() != $this->id() && !$this->isSyncing()) { + // Reflect machine name changes in the definitions of existing 'taxonomy' + // fields. + $field_ids = array(); + $field_map = \Drupal::entityManager()->getFieldMapByFieldType('taxonomy_term_reference'); + foreach ($field_map as $entity_type => $field_storages) { + foreach ($field_storages as $field_storage => $info) { + $field_ids[] = $entity_type . '.' . $field_storage; + } + } + + $field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple($field_ids); + + foreach ($field_storages as $field_storage) { + $update_storage = FALSE; + + foreach ($field_storage->settings['allowed_values'] as &$value) { + if ($value['vocabulary'] == $this->getOriginalId()) { + $value['vocabulary'] = $this->id(); + $update_storage = TRUE; + } + } + + if ($update_storage) { + $field_storage->save(); + } + } + } + $storage->resetCache($update ? array($this->getOriginalId()) : array()); + } - protected $weight = 0; /** * {@inheritdoc} @@ -139,123 +183,4 @@ } } - /** - * {@inheritdoc} - */ - public function getWeight() { - return $this->get('weight'); - } - - /** - * {@inheritdoc} - */ - public function setWeight($weight) { - $this->set('weight', $weight); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getDescription() { - return $this->get('description'); - } - - /** - * {@inheritdoc} - */ - public function setDescription($description) { - $this->set('description', $description); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getHierarchy() { - return $this->get('hierarchy'); - } - - /** - * {@inheritdoc} - */ - public function setHierarchy($hierarchy) { - $this->set('hierarchy', $hierarchy); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getVid() { - return $this->get('vid'); - } - - /** - * {@inheritdoc} - */ - public function setVid($machineName) { - $this->set('vid', $machineName); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getName() { - return $this->get('name'); - } - - /** - * {@inheritdoc} - */ - public function setName($name) { - $this->set('name', $name); - return $this; - } - - /** - * {@inheritdoc} - */ - public function postSave(EntityStorageInterface $storage, $update = TRUE) { - parent::postSave($storage, $update); - - if ($update && $this->getOriginalId() != $this->id() && !$this->isSyncing()) { - // Reflect machine name changes in the definitions of existing 'taxonomy' - // fields. - $field_ids = array(); - $field_map = \Drupal::entityManager()->getFieldMapByFieldType('taxonomy_term_reference'); - foreach ($field_map as $entity_type => $fields) { - foreach ($fields as $field => $info) { - $field_ids[] = $entity_type . '.' . $field; - } - } - - $field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple($field_ids); - - foreach ($field_storages as $field_storage) { - $update_field = FALSE; - - foreach ($field_storage->settings['allowed_values'] as &$value) { - if ($value['vocabulary'] == $this->getOriginalId()) { - $value['vocabulary'] = $this->id(); - $update_field = TRUE; - } - } - - if ($update_field) { - $field_storage->save(); - } - } - } - $storage->resetCache($update ? array($this->getOriginalId()) : array()); - } - - /** - * {@inheritdoc} - */ - public function id() { - return $this->vid; - } - } unchanged: --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -52,21 +52,21 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface { * * @var string */ - public $vid; + protected $vid; /** * Name of the vocabulary. * * @var string */ - public $name; + protected $name; /** * Description of the vocabulary. * * @var string */ - public $description; + protected $description; /** * The type of hierarchy allowed within the vocabulary. @@ -78,14 +78,51 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface { * * @var integer */ - public $hierarchy = TAXONOMY_HIERARCHY_DISABLED; + protected $hierarchy = TAXONOMY_HIERARCHY_DISABLED; /** * The weight of this vocabulary in relation to other vocabularies. * * @var integer */ - public $weight = 0; + protected $weight = 0; + + /** + * {@inheritdoc} + */ + public function getDescription() { + return $this->get('description'); + } + + /** + * {@inheritdoc} + */ + public function getHierarchy() { + return $this->get('hierarchy'); + } + + /** + * {@inheritdoc} + */ + public function setHierarchy($hierarchy) { + $this->set('hierarchy', $hierarchy); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return $this->get('name'); + } + + /** + * {@inheritdoc} + */ + public function setName($name) { + $this->set('name', $name); + return $this; + } /** * {@inheritdoc} diff -u b/core/modules/taxonomy/src/Tests/TermFieldTest.php b/core/modules/taxonomy/src/Tests/TermFieldTest.php --- b/core/modules/taxonomy/src/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/src/Tests/TermFieldTest.php @@ -166,7 +166,7 @@ $this->field_storage->save(); // Change the machine name. $new_name = Unicode::strtolower($this->randomMachineName()); - $this->vocabulary->setVid($new_name); + $this->vocabulary->set('vid', $new_name); $this->vocabulary->save(); // Check that the field is still attached to the vocabulary. diff -u b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php --- b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -75,7 +75,7 @@ // Change the name and description. $vocabulary = $original_vocabulary; $vocabulary->setName($this->randomMachineName()); - $vocabulary->setDescription($this->randomMachineName()); + $vocabulary->set('description', $this->randomMachineName()); $vocabulary->save(); // Load the vocabulary. @@ -100,13 +100,13 @@ // Create some vocabularies and assign weights. $vocabulary1 = $this->createVocabulary(); - $vocabulary1->setWeight(0); + $vocabulary1->set('weight', 0); $vocabulary1->save(); $vocabulary2 = $this->createVocabulary(); - $vocabulary2->setWeight(1); + $vocabulary2->set('weight', 1); $vocabulary2->save(); $vocabulary3 = $this->createVocabulary(); - $vocabulary3->setWeight(2); + $vocabulary3->set('weight', 2); $vocabulary3->save(); // Check if third party settings exist. @@ -159,7 +159,7 @@ // Change the machine name. $old_name = $this->vocabulary->id(); $new_name = Unicode::strtolower($this->randomMachineName()); - $this->vocabulary->setVid($new_name); + $this->vocabulary->set('vid', $new_name); $this->vocabulary->save(); // Check that entity bundles are properly updated. diff -u b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php --- b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php @@ -83,8 +83,8 @@ $vocabularies = entity_load_multiple('taxonomy_vocabulary'); $edit = array(); foreach ($vocabularies as $key => $vocabulary) { - $weight = -$vocabulary->getWeight(); - $vocabularies[$key]->setWeight($weight); + $weight = -$vocabulary->get('weight'); + $vocabularies[$key]->set('weight', $weight); $edit['vocabularies[' . $key . '][weight]'] = $weight; } // Saving the new weights via the interface. @@ -96,7 +96,7 @@ // Check that the weights are saved in the database correctly. foreach ($vocabularies as $key => $vocabulary) { - $this->assertEqual($new_vocabularies[$key]->getWeight(), $vocabularies[$key]->getWeight(), 'The vocabulary weight was changed.'); + $this->assertEqual($new_vocabularies[$key]->get('weight'), $vocabularies[$key]->get('weight'), 'The vocabulary weight was changed.'); } } diff -u b/core/modules/taxonomy/src/VocabularyInterface.php b/core/modules/taxonomy/src/VocabularyInterface.php --- b/core/modules/taxonomy/src/VocabularyInterface.php +++ b/core/modules/taxonomy/src/VocabularyInterface.php @@ -34,25 +34,6 @@ public function getName(); /** - * Sets the vocabulary weight. - * - * @param integer $weight - * The weight of vocabulary. - * - * @return \Drupal\taxonomy\VocabularyInterface - * The called Vocabulary entity. - */ - public function setWeight($weight); - - /** - * Returns the vocabulary weight. - * - * @return integer - * The vocabulary weight. - */ - public function getWeight(); - - /** * Sets the vocabulary hierarchy. * * @param integer $hierarchy @@ -76,17 +57,6 @@ public function getHierarchy(); /** - * Sets the vocabulary description. - * - * @param string description - * The vocabulary description. - * - * @return \Drupal\taxonomy\VocabularyInterface - * The called Vocabulary entity. - */ - public function setDescription($description); - - /** * Returns the vocabulary description. * * @return string @@ -96,20 +66,2 @@ - /** - * Sets the vocabulary vid. - * - * @param string $machineName - * The vocabulary machine name. - * - * @return \Drupal\taxonomy\VocabularyInterface - * The called Vocabulary entity. - */ - public function setVid($machineName); - - /** - * Returns the vocabulary vid. - * - * @return string - * The vocabulary machine name. - */ - public function getVid(); } diff -u b/core/modules/views/src/Tests/ViewsTaxonomyAutocompleteTest.php b/core/modules/views/src/Tests/ViewsTaxonomyAutocompleteTest.php --- b/core/modules/views/src/Tests/ViewsTaxonomyAutocompleteTest.php +++ b/core/modules/views/src/Tests/ViewsTaxonomyAutocompleteTest.php @@ -67,7 +67,7 @@ public function testTaxonomyAutocomplete() { $this->user = $this->drupalCreateUser(array('access content')); $this->drupalLogin($this->user); - $base_autocomplete_path = 'taxonomy/autocomplete_vid/' . $this->vocabulary->getVid(); + $base_autocomplete_path = 'taxonomy/autocomplete_vid/' . $this->vocabulary->id(); // Test that no terms returns an empty array. $this->assertIdentical(array(), $this->drupalGetJSON($base_autocomplete_path));