function taxonomy_implode_tags in Drupal 9
Same name and namespace in other branches
- 8 core/modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
- 6 modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
- 7 modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
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 also
https://www.drupal.org/node/3039041
\Drupal\Component\Utility\Tags::explode()
1 call to taxonomy_implode_tags()
- TaxonomyDeprecationTest::testTaxonomyDeprecations in core/
modules/ taxonomy/ tests/ src/ Kernel/ TaxonomyDeprecationTest.php
File
- core/
modules/ taxonomy/ taxonomy.module, line 240 - Enables the organization of content into categories.
Code
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);
}