protected MenuTreeStorage::findParent($link, $original)
Loads the parent definition if it exists.
Parameters
array $link: The link definition to find the parent of.
array|false $original: The original link that might be used to find the parent if the parent is not set on the $link, or FALSE if the original could not be loaded.
Return value
array|false Returns a definition array, or FALSE if no parent was found.
File
- core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 563
Class
- MenuTreeStorage
- Provides a menu tree storage using the database.
Namespace
Drupal\Core\Menu
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | protected function findParent( $link , $original ) { $parent = FALSE; // This item is explicitly top-level, skip the rest of the parenting. if (isset( $link [ 'parent' ]) && empty ( $link [ 'parent' ])) { return $parent ; } // If we have a parent link ID, try to use that. $candidates = array (); if (isset( $link [ 'parent' ])) { $candidates [] = $link [ 'parent' ]; } elseif (! empty ( $original [ 'parent' ]) && $link [ 'menu_name' ] == $original [ 'menu_name' ]) { // Otherwise, fall back to the original parent. $candidates [] = $original [ 'parent' ]; } foreach ( $candidates as $id ) { $parent = $this ->loadFull( $id ); if ( $parent ) { break ; } } return $parent ; } |
Please login to continue.