function _taxonomy_edge_unify_parents in Taxonomy Edge 8
Same name and namespace in other branches
- 6 taxonomy_edge.module \_taxonomy_edge_unify_parents()
- 7.2 taxonomy_edge.module \_taxonomy_edge_unify_parents()
- 7 taxonomy_edge.module \_taxonomy_edge_unify_parents()
Unify parents
Parameters
mixed $parents:
Return value
array Flattened array of parent term IDs
3 calls to _taxonomy_edge_unify_parents()
- TaxonomyEdgeTreeUnitTestCase::testParents in tests/
unit.test - _taxonomy_edge_taxonomy_term_insert in ./
taxonomy_edge.module - Insert a term into the edge tree.
- _taxonomy_edge_taxonomy_term_update in ./
taxonomy_edge.module - Update a term in the edge tree.
File
- ./
taxonomy_edge.module, line 621 - Selecting all children of a given taxonomy term can be a pain. This module makes it easier to do this, by maintaining a complete list of edges for each term using the adjecency matrix graph theory.
Code
function _taxonomy_edge_unify_parents($parents) {
$parents = is_array($parents) ? $parents : array(
$parents,
);
$new_parents = array();
foreach ($parents as $parent) {
if (is_array($parent)) {
foreach ($parent as $new) {
$new_parents[] = $new;
}
}
else {
$new_parents[] = $parent;
}
}
return $new_parents;
}