You are here

protected function MongodbMenuTreeStorage::updateParentalStatus in MongoDB 8

Sets has_children for the link's parent if it has visible children.

Parameters

array $link: The link to get a parent ID from.

Overrides MenuTreeStorage::updateParentalStatus

1 call to MongodbMenuTreeStorage::updateParentalStatus()
MongodbMenuTreeStorage::doSave in src/MongodbMenuTreeStorage.php
Saves a link without clearing caches.

File

src/MongodbMenuTreeStorage.php, line 235
Contains \Drupal\mongodb\MongodbMenuTreeStorage .

Class

MongodbMenuTreeStorage

Namespace

Drupal\mongodb

Code

protected function updateParentalStatus(array $link) {

  // If parent is empty, there is nothing to update.
  if (!empty($link['parent'])) {
    $query = [
      'value.menu_name' => $link['menu_name'],
      'value.parent' => $link['parent'],
      'value.enabled' => 1,
    ];
    $update['$set']['value.has_children'] = (int) (bool) $this
      ->mongoCollection()
      ->findOne($query, []);
    $this
      ->mongoCollection()
      ->update([
      'value.id' => $link['parent'],
    ], $update);
  }
}