diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 9bfca0b..c653217 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -643,7 +643,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) { // including unserializing all existing link options and running this code // on them, as well as adding validation to menu_link_save(). if (isset($item['options']['attributes']['class']) && is_string($item['options']['attributes']['class'])) { - if ($item instanceof MenuLink) { + if ($item instanceof MenuLinkInterface) { $item->localized_options->attributes['class'] = explode(' ', $item->options->attributes['class']); } else { @@ -676,7 +676,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) { } // Avoid calling check_plain again on l() function. if ($title_callback == 'check_plain') { - if ($item instanceof MenuLink) { + if ($item instanceof MenuLinkInterface) { $item->localized_options->html = TRUE; } else { diff --git a/core/includes/path.inc b/core/includes/path.inc index 52ab706..4c7aab7 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -6,6 +6,7 @@ */ use Symfony\Component\HttpFoundation\Request; +use Drupal\menu_link\Entity\MenuLink; /** * Check if the current page is the front page. @@ -201,9 +202,8 @@ function drupal_valid_path($path, $dynamic_allowed = FALSE) { elseif ($dynamic_allowed && preg_match('/\/\%/', $path)) { // Path is dynamic (ie 'user/%'), so check directly against menu_router table. if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) { - $item['link_path'] = $form_item['link_path']; - $item['link_title'] = $form_item['link_title']; - $item['external'] = FALSE; + $item = MenuLink::buildFromRouterItem($item); + $item['external'] = FALSE; $item['options'] = array(); _menu_link_translate($item); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 6e1bf95..389bf8b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -772,7 +772,7 @@ public function updateOriginalValues() { } /** - * Implements the magic method for getting object properties. + * Implements the magic method for setting object properties. * * @todo: A lot of code still uses non-fields (e.g. $entity->content in render * controllers) by reference. Clean that up. diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index d4b7715..b58707a 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -545,21 +545,6 @@ public function findParent(MenuLinkStorageControllerInterface $storage_controlle } /** - * overrides \Drupal\Core\Entity\EntityNG::set() - */ - public function set($property_name, $value, $notify = TRUE) { - // work-around entity_form_submit_build_entity() -> entity.set() trying to - // set a non-existing fields into MenuLink. - $definition = $this->getPropertyDefinition($property_name); - if (!$definition) { - $this->$property_name = $value; - } - else { - parent::set($property_name, $value, $notify); - } - } - - /** * {@inheritdoc} */ public function getMenuName() { diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index 9442cc8..08ca34c 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -77,7 +77,6 @@ public function create(array $values) { if (!isset($values['bundle']) && isset($values['menu_name'])) { $values['bundle'] = $values['menu_name']; } - return parent::create($values); } @@ -159,7 +158,7 @@ protected function mapFromStorageRecords(array $records, $load_revision = FALSE) } /** - * Overrides DatabaseStorageControllerNG::mapToStorageRecord(). + * {@inheritdoc} */ protected function mapToStorageRecord(EntityInterface $entity) { $record = parent::mapToStorageRecord($entity); @@ -290,7 +289,7 @@ public function loadUpdatedCustomized(array $router_paths) { $menu_links = array(); // @todo This doesn't really make sense anymore with EntityNG.. and EFQ got - // OR condition support in the meantime, so convert this query. + // OR condition support in the meantime, so convert this query. $query = parent::buildQuery(NULL); $query ->condition(db_or() @@ -330,13 +329,13 @@ public function loadModuleAdminTasks() { */ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) { // If plid == 0, there is nothing to update. - if ($entity->plid->target_id) { + if ($entity->getParentLinkId()) { // Check if at least one visible child exists in the table. $query = \Drupal::entityQuery($this->entityType); $query ->condition('menu_name', $entity->getMenuName()) ->condition('hidden', 0) - ->condition('plid', $entity->plid->target_id) + ->condition('plid', $entity->getParentLinkId()) ->count(); if ($exclude) { @@ -346,7 +345,7 @@ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) $parent_has_children = ((bool) $query->execute()) ? 1 : 0; $this->database->update('menu_links') ->fields(array('has_children' => $parent_has_children)) - ->condition('mlid', $entity->plid->target_id) + ->condition('mlid', $entity->getParentLinkId()) ->execute(); } } @@ -364,10 +363,9 @@ public function findChildrenRelativeDepth(EntityInterface $entity) { $query->range(0, 1); $i = 1; - $p = 'p1'; - while ($i <= MENU_MAX_DEPTH && $entity->{$p}->value) { - $query->condition($p, $entity->{$p}->value); - $p = 'p' . ++$i; + while ($i <= MENU_MAX_DEPTH && $entity->getMaterializedPathEntity($i)) { + $query->condition('p' . $i, $entity->getMaterializedPathEntity($i)); + $i++; } $max_depth = $query->execute()->fetchField();