diff --git a/src/Controller/TaxonomiesController.php b/src/Controller/TaxonomiesController.php index 1831025eef5e7f7573be77026f834c61b5a66fb2..4986ef1149c8416b3885dbfb342aff506b2972dd 100755 --- a/src/Controller/TaxonomiesController.php +++ b/src/Controller/TaxonomiesController.php @@ -151,6 +151,16 @@ class TaxonomiesController extends ControllerBase { $taxonomies = $taxonomiesConfig; } + // Sorts taxonomies so that all parent terms come before -- and therefore + // are created before -- their respective child terms + foreach ($taxonomies as $taxonomy => $terms) { + $parents = []; + foreach ($terms as $key => $term_data) { + $parents[$key] = $term_data['parent']; + } + array_multisort($parents, SORT_ASC, $taxonomies[$taxonomy]); + } + if (array_key_exists('drush', $form) && $form['drush'] === TRUE) { $context = []; $context['drush'] = TRUE;