protected function MenuTreeStorage::updateParentalStatus
protected MenuTreeStorage::updateParentalStatus(array $link)
Sets has_children for the link's parent if it has visible children.
Parameters
array $link: The link to get a parent ID from.
File
- core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 596
Class
- MenuTreeStorage
- Provides a menu tree storage using the database.
Namespace
Drupal\Core\MenuCode
protected function updateParentalStatus(array $link) { // If parent is empty, there is nothing to update. if (!empty($link['parent'])) { // Check if at least one visible child exists in the table. $query = $this->connection->select($this->table, $this->options); $query->addExpression('1'); $query->range(0, 1); $query ->condition('menu_name', $link['menu_name']) ->condition('parent', $link['parent']) ->condition('enabled', 1); $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0; $this->connection->update($this->table, $this->options) ->fields(array('has_children' => $parent_has_children)) ->condition('id', $link['parent']) ->execute(); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeStorage.php/function/MenuTreeStorage::updateParentalStatus/8.1.x