protected function MenuLinkStorageController::setParents

Sets the p1 through p9 properties for a menu link entity being saved.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: A menu link entity.

\Drupal\Core\Entity\EntityInterface $parent: A menu link entity.

1 call to MenuLinkStorageController::setParents()
MenuLinkStorageController::preSave in drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
Overrides DatabaseStorageController::preSave().

File

drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php, line 547
Contains \Drupal\menu_link\MenuLinkStorageController.

Class

MenuLinkStorageController
Controller class for menu links.

Namespace

Drupal\menu_link

Code

protected function setParents(EntityInterface $entity, EntityInterface $parent) {
  $i = 1;
  while ($i < $entity->depth) {
    $p = 'p' . $i++;
    $entity->{$p} = $parent->{$p};
  }
  $p = 'p' . $i++;

  // The parent (p1 - p9) corresponding to the depth always equals the mlid.
  $entity->{$p} = $entity
    ->id();
  while ($i <= MENU_MAX_DEPTH) {
    $p = 'p' . $i++;
    $entity->{$p} = 0;
  }
}