diff options
Diffstat (limited to 'core/modules/taxonomy')
14 files changed, 56 insertions, 32 deletions
diff --git a/core/modules/taxonomy/src/Hook/TaxonomyHooks.php b/core/modules/taxonomy/src/Hook/TaxonomyHooks.php index 4cc0a6f6eb6..82a88ce8a19 100644 --- a/core/modules/taxonomy/src/Hook/TaxonomyHooks.php +++ b/core/modules/taxonomy/src/Hook/TaxonomyHooks.php @@ -180,4 +180,9 @@ class TaxonomyHooks { } } + // phpcs:ignore Drupal.Commenting.InlineComment.DocBlock + /** + * @} End of "defgroup taxonomy_index". + */ + } diff --git a/core/modules/taxonomy/src/Hook/TaxonomyThemeHooks.php b/core/modules/taxonomy/src/Hook/TaxonomyThemeHooks.php new file mode 100644 index 00000000000..89f177daf24 --- /dev/null +++ b/core/modules/taxonomy/src/Hook/TaxonomyThemeHooks.php @@ -0,0 +1,25 @@ +<?php + +namespace Drupal\taxonomy\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for taxonomy. + */ +class TaxonomyThemeHooks { + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_taxonomy_term')] + public function themeSuggestionsTaxonomyTerm(array $variables): array { + $suggestions = []; + /** @var \Drupal\taxonomy\TermInterface $term */ + $term = $variables['elements']['#taxonomy_term']; + $suggestions[] = 'taxonomy_term__' . $term->bundle(); + $suggestions[] = 'taxonomy_term__' . $term->id(); + return $suggestions; + } + +} diff --git a/core/modules/taxonomy/src/Hook/TaxonomyTokensHooks.php b/core/modules/taxonomy/src/Hook/TaxonomyTokensHooks.php index 12c8f7dc885..7c7fbf63d98 100644 --- a/core/modules/taxonomy/src/Hook/TaxonomyTokensHooks.php +++ b/core/modules/taxonomy/src/Hook/TaxonomyTokensHooks.php @@ -65,7 +65,7 @@ class TaxonomyTokensHooks { 'name' => $this->t("Term count"), 'description' => $this->t("The number of terms belonging to the taxonomy vocabulary."), ]; - // Chained tokens for taxonomies + // Chained tokens for taxonomies. $term['vocabulary'] = [ 'name' => $this->t("Vocabulary"), 'description' => $this->t("The vocabulary the taxonomy term belongs to."), diff --git a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php index 7b7a57363bc..f4fd0c8641f 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php +++ b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php @@ -181,7 +181,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf } if (!empty($this->options['limit'])) { $tids = []; - // Filter by vocabulary + // Filter by vocabulary. foreach ($taxonomy as $tid => $vocab) { if (!empty($this->options['vids'][$vocab])) { $tids[] = $tid; diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index bf83b7067c5..b41086d059e 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -174,10 +174,10 @@ class TaxonomyIndexTid extends PrerenderList { * {@inheritdoc} */ protected function documentSelfTokens(&$tokens) { - $tokens['{{ ' . $this->options['id'] . '__tid' . ' }}'] = $this->t('The taxonomy term ID for the term.'); - $tokens['{{ ' . $this->options['id'] . '__name' . ' }}'] = $this->t('The taxonomy term name for the term.'); - $tokens['{{ ' . $this->options['id'] . '__vocabulary_vid' . ' }}'] = $this->t('The machine name for the vocabulary the term belongs to.'); - $tokens['{{ ' . $this->options['id'] . '__vocabulary' . ' }}'] = $this->t('The name for the vocabulary the term belongs to.'); + $tokens['{{ ' . $this->options['id'] . '__tid }}'] = $this->t('The taxonomy term ID for the term.'); + $tokens['{{ ' . $this->options['id'] . '__name }}'] = $this->t('The taxonomy term name for the term.'); + $tokens['{{ ' . $this->options['id'] . '__vocabulary_vid }}'] = $this->t('The machine name for the vocabulary the term belongs to.'); + $tokens['{{ ' . $this->options['id'] . '__vocabulary }}'] = $this->t('The name for the vocabulary the term belongs to.'); } /** diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 6d1b18c7647..e48931b5267 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -289,7 +289,7 @@ class TaxonomyIndexTid extends ManyToOne { } if (!$form_state->get('exposed')) { - // Retain the helper option + // Retain the helper option. $this->helper->buildOptionsForm($form, $form_state); // Show help text if not exposed to end users. @@ -330,7 +330,7 @@ class TaxonomyIndexTid extends ManyToOne { } // If view is an attachment and is inheriting exposed filters, then assume - // exposed input has already been validated + // exposed input has already been validated. if (!empty($this->view->is_attachment) && $this->view->display_handler->usesExposed()) { $this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']]; } @@ -418,7 +418,7 @@ class TaxonomyIndexTid extends ManyToOne { * {@inheritdoc} */ public function adminSummary() { - // Set up $this->valueOptions for the parent summary + // Set up $this->valueOptions for the parent summary. $this->valueOptions = []; if ($this->value) { diff --git a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php index 5987d9fe933..28c9cc8b06b 100644 --- a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php +++ b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php @@ -109,7 +109,7 @@ class NodeTermData extends RelationshipPluginBase { $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER'; } else { - // If vocabularies are supplied join a subselect instead + // If vocabularies are supplied join a subselect instead. $def['left_table'] = $this->tableAlias; $def['left_field'] = 'nid'; $def['field'] = 'nid'; diff --git a/core/modules/taxonomy/src/TermViewsData.php b/core/modules/taxonomy/src/TermViewsData.php index 7ca182d9693..c6a1463fc25 100644 --- a/core/modules/taxonomy/src/TermViewsData.php +++ b/core/modules/taxonomy/src/TermViewsData.php @@ -139,12 +139,12 @@ class TermViewsData extends EntityViewsData { $data['taxonomy_index']['table']['join'] = [ 'taxonomy_term_field_data' => [ - // Links directly to taxonomy_term_field_data via tid + // Links directly to taxonomy_term_field_data via tid. 'left_field' => 'tid', 'field' => 'tid', ], 'node_field_data' => [ - // Links directly to node via nid + // Links directly to node via nid. 'left_field' => 'nid', 'field' => 'nid', ], diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 04c00e36b6c..6694f62e563 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -10,21 +10,6 @@ use Drupal\Core\Render\Element; use Drupal\taxonomy\Entity\Term; /** - * Implements hook_theme_suggestions_HOOK(). - */ -function taxonomy_theme_suggestions_taxonomy_term(array $variables): array { - $suggestions = []; - - /** @var \Drupal\taxonomy\TermInterface $term */ - $term = $variables['elements']['#taxonomy_term']; - - $suggestions[] = 'taxonomy_term__' . $term->bundle(); - $suggestions[] = 'taxonomy_term__' . $term->id(); - - return $suggestions; -} - -/** * Prepares variables for taxonomy term templates. * * Default template: taxonomy-term.html.twig. @@ -90,6 +75,11 @@ function taxonomy_term_is_page(Term $term) { } /** + * @addtogroup taxonomy_index + * @{ + */ + +/** * Builds and inserts taxonomy index entries for a given node. * * The index lists all terms that are related to a given node entity, and is @@ -152,5 +142,5 @@ function taxonomy_delete_node_index(EntityInterface $node): void { } /** - * @} End of "defgroup taxonomy_index". + * @} End of "addtogroup taxonomy_index". */ diff --git a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php index 4fa2b896c25..11ba24f7c06 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php @@ -164,7 +164,7 @@ class TermLanguageTest extends TaxonomyTestBase { ]); $term->save(); - // Overview page in the other language shows the translated term + // Overview page in the other language shows the translated term. $this->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); $this->assertSession()->responseMatches('|<a[^>]*>' . $translated_title . '</a>|'); } diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php index 7747682a42e..b751f6b52ba 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Drupal\Tests\taxonomy\Functional; -use Drupal\Component\Render\FormattableMarkup; +use Drupal\Component\Utility\Html; use Drupal\Core\Url; use Drupal\taxonomy\Entity\Vocabulary; @@ -101,9 +101,10 @@ class VocabularyUiTest extends TaxonomyTestBase { $link->click(); // Confirm deletion. - $this->assertSession()->responseContains(new FormattableMarkup('Are you sure you want to delete the vocabulary %name?', ['%name' => $edit['name']])); + $name = Html::escape($edit['name']); + $this->assertSession()->responseContains("Are you sure you want to delete the vocabulary <em class=\"placeholder\">$name</em>?"); $this->submitForm([], 'Delete'); - $this->assertSession()->responseContains(new FormattableMarkup('Deleted vocabulary %name.', ['%name' => $edit['name']])); + $this->assertSession()->responseContains("Deleted vocabulary <em class=\"placeholder\">$name</em>."); $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache(); $this->assertNull(Vocabulary::load($edit['vid']), 'Vocabulary not found.'); } diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php index 1d9654dd505..511778daf20 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php @@ -10,6 +10,7 @@ use Drupal\node\Entity\Node; /** * Upgrade taxonomy term node associations. * + * @group #slow * @group migrate_drupal_6 */ class MigrateTermNodeTest extends MigrateDrupal6TestBase { diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php index 8d9465f61a3..7fcb764eac3 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php @@ -11,6 +11,7 @@ use Drupal\node\Entity\Node; * Upgrade taxonomy term node associations. * * @group migrate_drupal_6 + * @group #slow */ class MigrateTermNodeTranslationTest extends MigrateDrupal6TestBase { diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php index 1fb8b819fdc..3499a404ac9 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php @@ -12,6 +12,7 @@ use Drupal\taxonomy\TermInterface; * Test migration of translated taxonomy terms. * * @group migrate_drupal_7 + * @group #slow */ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal7TestBase { |