function taxonomy_term_load_multiple_by_name
Same name in other branches
- 8.9.x core/modules/taxonomy/taxonomy.module \taxonomy_term_load_multiple_by_name()
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.
Parameters
$name: Name of the term to search for.
$vocabulary: (optional) Vocabulary machine name to limit the search. Defaults to NULL.
Return value
\Drupal\taxonomy\TermInterface[] 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_term')->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 also
https://www.drupal.org/node/3039041
1 call to taxonomy_term_load_multiple_by_name()
- TermTest::testTaxonomyGetTermByName in core/
modules/ taxonomy/ tests/ src/ Functional/ TermTest.php - Tests taxonomy_term_load_multiple_by_name().
File
-
core/
modules/ taxonomy/ taxonomy.module, line 222
Code
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_term")->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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.