Commit da3c1027 authored by catch's avatar catch
Browse files

Issue #3261240 by andypost, longwave, quietone: Remove deprecated taxonomy module functions

parent a209347c
Loading
Loading
Loading
Loading
+0 −5
Changes for core/includes/bootstrap.inc: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -471,11 +471,6 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
 *   unit tests with a clean environment.
 */
function drupal_static_reset($name = NULL) {
  switch ($name) {
    case 'taxonomy_vocabulary_get_names':
      @trigger_error("Calling drupal_static_reset() with 'taxonomy_vocabulary_get_names' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3039041", E_USER_DEPRECATED);
      break;
  }
  drupal_static($name, NULL, TRUE);
}

+0 −19
Changes for core/modules/taxonomy/src/Controller/TaxonomyController.php: 0 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -26,25 +26,6 @@ public function addForm(VocabularyInterface $taxonomy_vocabulary) {
    return $this->entityFormBuilder()->getForm($term);
  }

  /**
   * Route title callback.
   *
   * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary
   *   The vocabulary.
   *
   * @return string
   *   The vocabulary label as a render array.
   *
   * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no
   *   replacement; route title callbacks are internal.
   *
   * @see https://www.drupal.org/project/drupal/issues/3037157
   */
  public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement; route title callbacks are internal. See https://www.drupal.org/project/drupal/issues/3037157.', E_USER_DEPRECATED);
    return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()];
  }

  /**
   * Route title callback.
   *
+0 −28
Changes for core/modules/taxonomy/src/Plugin/views/argument_validator/Term.php: 0 added lines, 28 removed lines.
Original line number Diff line number Diff line
<?php

namespace Drupal\taxonomy\Plugin\views\argument_validator;

use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\views\Plugin\views\argument_validator\Entity;

/**
 * Adds legacy vocabulary handling to standard Entity Argument validation.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal\views\Plugin\views\argument_validator\Entity instead.
 *
 * @see https://www.drupal.org/node/3221870
 */
class Term extends Entity {

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
    @trigger_error('The ' . __NAMESPACE__ . '\Term is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\views\Plugin\views\argument_validator\Entity instead. See https://www.drupal.org/node/3221870', E_USER_DEPRECATED);

    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_type_bundle_info);
  }

}
+1 −5
Changes for core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php: 1 added line, 5 removed lines.
Original line number Diff line number Diff line
@@ -66,14 +66,10 @@ class TaxonomyIndexTid extends ManyToOne {
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user = NULL) {
  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage, TermStorageInterface $term_storage, AccountInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->vocabularyStorage = $vocabulary_storage;
    $this->termStorage = $term_storage;
    if (!$current_user) {
      @trigger_error('The current_user service must be passed to ' . __NAMESPACE__ . '\TaxonomyIndexTid::__construct(). It was added in drupal:8.9.0 and will be required before drupal:10.0.0.', E_USER_DEPRECATED);
      $current_user = \Drupal::service('current_user');
    }
    $this->currentUser = $current_user;
  }

+0 −135
Changes for core/modules/taxonomy/taxonomy.module: 0 added lines, 135 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
 * Enables the organization of content into categories.
 */

use Drupal\Component\Utility\Tags;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Render\Element;
@@ -47,19 +46,6 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
  }
}

/**
 * Entity URI callback.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   $term->toUrl() instead.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_term_uri($term) {
  @trigger_error('taxonomy_term_uri() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use $term->toUrl() instead. See https://www.drupal.org/node/3039041', E_USER_DEPRECATED);
  return $term->toUrl();
}

/**
 * Implements hook_theme().
 */
@@ -151,127 +137,6 @@ function taxonomy_term_is_page(Term $term) {
  return FALSE;
}

/**
 * Clear all static cache variables for terms.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache()
 *   instead.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_terms_static_reset() {
  @trigger_error("taxonomy_terms_static_reset() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache() instead. See https://www.drupal.org/node/3039041", E_USER_DEPRECATED);
  \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache();
}

/**
 * Clear all static cache variables for vocabularies.
 *
 * @param $ids
 *   An array of ids to reset in the entity cache.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->resetCache($ids)
 *   instead.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_vocabulary_static_reset(array $ids = NULL) {
  @trigger_error('taxonomy_vocabulary_static_reset() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal::entityTypeManager()->getStorage("taxonomy_vocabulary")->resetCache($ids) instead. See https://www.drupal.org/node/3039041', E_USER_DEPRECATED);
  \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->resetCache($ids);
}

/**
 * Get names for all taxonomy vocabularies.
 *
 * @return array
 *   A list of existing vocabulary IDs.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal::entityQuery('taxonomy_vocabulary')->execute() instead.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_vocabulary_get_names() {
  @trigger_error("taxonomy_vocabulary_get_names() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal::entityQuery('taxonomy_vocabulary')->execute() instead. See https://www.drupal.org/node/3039041", E_USER_DEPRECATED);
  return \Drupal::entityQuery('taxonomy_vocabulary')->execute();
}

/**
 * Try to map a string to an existing term, as for glossary use.
 *
 * Provides a case-insensitive and trimmed mapping, to maximize the
 * likelihood of a successful match.
 *
 * @param $name
 *   Name of the term to search for.
 * @param $vocabulary
 *   (optional) Vocabulary machine name to limit the search. Defaults to NULL.
 *
 * @return
 *   An array of matching term objects.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->loadByProperties(['name' => $name, 'vid' => $vid])
 *   instead, to get a list of taxonomy term entities having the same name and
 *   keyed by their term ID.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
  @trigger_error('taxonomy_term_load_multiple_by_name() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal::entityTypeManager()->getStorage("taxonomy_vocabulary")->loadByProperties(["name" => $name, "vid" => $vid]) instead, to get a list of taxonomy term entities having the same name and keyed by their term ID. See https://www.drupal.org/node/3039041', E_USER_DEPRECATED);
  $values = ['name' => trim($name)];
  if (isset($vocabulary)) {
    $values['vid'] = $vocabulary;
  }
  return \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties($values);
}

/**
 * Implodes a list of tags of a certain vocabulary into a string.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal\Core\Entity\Element\EntityAutocomplete::getEntityLabels() instead.
 *
 * @see https://www.drupal.org/node/3039041
 * @see \Drupal\Component\Utility\Tags::explode()
 */
function taxonomy_implode_tags($tags, $vid = NULL) {
  @trigger_error('taxonomy_implode_tags() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Entity\Element\EntityAutocomplete::getEntityLabels() instead. See https://www.drupal.org/node/3039041', E_USER_DEPRECATED);
  $typed_tags = [];
  foreach ($tags as $tag) {
    // Extract terms belonging to the vocabulary in question.
    if (!isset($vid) || $tag->bundle() == $vid) {
      // Make sure we have a completed loaded taxonomy term.
      if ($tag instanceof EntityInterface && $label = $tag->label()) {
        // Commas and quotes in tag names are special cases, so encode 'em.
        $typed_tags[] = Tags::encode($label);
      }
    }
  }
  return implode(', ', $typed_tags);
}

/**
 * Title callback for term pages.
 *
 * @param \Drupal\taxonomy\Entity\Term $term
 *   A taxonomy term entity.
 *
 * @return
 *   The term name to be used as the page title.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   $term->label() instead.
 *
 * @see https://www.drupal.org/node/3039041
 */
function taxonomy_term_title(Term $term) {
  @trigger_error('taxonomy_term_title() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use $term->label() instead. See https://www.drupal.org/node/3039041', E_USER_DEPRECATED);
  return $term->label();
}

/**
 * @defgroup taxonomy_index Taxonomy indexing
 * @{
Loading