Commit 46b3fa5a authored by catch's avatar catch

Issue #2850691 by claudiu.cristea, hchonov: Deprecate TermInterface::getVocabularyId()

parent ed4ad77a
......@@ -229,7 +229,8 @@ public function setWeight($weight) {
* {@inheritdoc}
*/
public function getVocabularyId() {
return $this->get('vid')->target_id;
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.4.0 and will be removed before 9.0.0. Use ' . __CLASS__ . '::bundle() instead to get the vocabulary ID.', E_USER_DEPRECATED);
return $this->bundle();
}
}
......@@ -194,7 +194,7 @@ public function getArgument() {
$taxonomy_terms = $node->{$field->getName()}->referencedEntities();
/** @var \Drupal\taxonomy\TermInterface $taxonomy_term */
foreach ($taxonomy_terms as $taxonomy_term) {
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->getVocabularyId();
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->bundle();
}
}
}
......
......@@ -145,8 +145,8 @@ public function preRender(&$values) {
foreach ($data as $tid => $term) {
$this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
$this->items[$node_nid][$tid]['tid'] = $tid;
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->getVocabularyId();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->getVocabularyId()]->label();
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->bundle();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->bundle()]->label();
if (!empty($this->options['link_to_taxonomy'])) {
$this->items[$node_nid][$tid]['make_link'] = TRUE;
......
......@@ -87,6 +87,9 @@ public function setWeight($weight);
*
* @return int
* The id of the vocabulary.
*
* @deprecated Scheduled for removal before Drupal 9.0.0. Use
* TermInterface::bundle() instead.
*/
public function getVocabularyId();
......
......@@ -57,7 +57,7 @@ public function testViewsHandlerAllTermsWithTokens() {
$this->assertText('The taxonomy term name for the term: ' . $this->term1->getName());
// The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}
$this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->getVocabularyId());
$this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->bundle());
// The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
$vocabulary = Vocabulary::load($this->term1->bundle());
......
......@@ -76,7 +76,7 @@ protected function assertEntity($id, $expected_label, $expected_vid, $expected_d
$entity = Term::load($id);
$this->assertTrue($entity instanceof TermInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_vid, $entity->getVocabularyId());
$this->assertIdentical($expected_vid, $entity->bundle());
$this->assertEqual($expected_description, $entity->getDescription());
$this->assertEquals($expected_format, $entity->getFormat());
$this->assertEqual($expected_weight, $entity->getWeight());
......
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