You are here

function _taxonomy_edge_unify_parents in Taxonomy Edge 7

Same name and namespace in other branches
  1. 8 taxonomy_edge.module \_taxonomy_edge_unify_parents()
  2. 6 taxonomy_edge.module \_taxonomy_edge_unify_parents()
  3. 7.2 taxonomy_edge.module \_taxonomy_edge_unify_parents()

Unify parents.

Parameters

mixed $parents: Parents in various formats.

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 646
Optimization of taxonomy data model for SQL performance.

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;
}