Issue #2850691 by claudiu.cristea, hchonov: Deprecate TermInterface::getVocabularyId()
parent
ed4ad77a12
commit
46b3fa5a8b
|
@ -229,7 +229,8 @@ class Term extends ContentEntityBase implements TermInterface {
|
|||
* {@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 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
|
|||
$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 @@ class TaxonomyIndexTid extends PrerenderList {
|
|||
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 @@ interface TermInterface extends ContentEntityInterface, EntityChangedInterface {
|
|||
*
|
||||
* @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 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
|
|||
$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 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
|
|||
$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());
|
||||
|
|
Loading…
Reference in New Issue