Mercurial > hg > isophonics-drupal-site
diff core/modules/taxonomy/src/TermForm.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/core/modules/taxonomy/src/TermForm.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/modules/taxonomy/src/TermForm.php Mon Apr 23 09:46:53 2018 +0100 @@ -7,6 +7,8 @@ /** * Base for handler for taxonomy term edit forms. + * + * @internal */ class TermForm extends ContentEntityForm { @@ -36,14 +38,17 @@ // before loading the full vocabulary. Contrib modules can then intercept // before hook_form_alter to provide scalable alternatives. if (!$this->config('taxonomy.settings')->get('override_selector')) { - $parent = array_keys($taxonomy_storage->loadParents($term->id())); - $children = $taxonomy_storage->loadTree($vocabulary->id(), $term->id()); + $exclude = []; + if (!$term->isNew()) { + $parent = array_keys($taxonomy_storage->loadParents($term->id())); + $children = $taxonomy_storage->loadTree($vocabulary->id(), $term->id()); - // A term can't be the child of itself, nor of its children. - foreach ($children as $child) { - $exclude[] = $child->tid; + // A term can't be the child of itself, nor of its children. + foreach ($children as $child) { + $exclude[] = $child->tid; + } + $exclude[] = $term->id(); } - $exclude[] = $term->id(); $tree = $taxonomy_storage->loadTree($vocabulary->id()); $options = ['<' . $this->t('root') . '>'];