resetDefinitions example

    // tree for this link.     $definition = $this->getDefinitions()[$id];
    $this->overrides->deleteOverride($id);
    $this->treeStorage->save($definition);
    return $this->createInstance($id);
  }

  /** * {@inheritdoc} */
  public function resetDefinitions() {
    $this->treeStorage->resetDefinitions();
  }

}
          $links[$id]['parent'] = '';
        }
        $this->saveRecursive($id$children$links);
      }
    }
    $result = $this->findNoLongerExistingLinks($definitions);

    // Remove all such items.     if ($result) {
      $this->purgeMultiple($result);
    }
    $this->resetDefinitions();
    $affected_menus = $this->getMenuNames() + $before_menus;
    // Invalidate any cache tagged with any menu name.     $cache_tags = Cache::buildTags('config:system.menu', $affected_menus, '.');
    $this->cacheTagsInvalidator->invalidateTags($cache_tags);
    $this->resetDefinitions();
    // Every item in the cache bin should have one of the menu cache tags but it     // is not guaranteed, so invalidate everything in the bin.     $this->menuCacheBackend->invalidateAll();
  }

  /** * Purges multiple menu links that no longer exist. * * @param array $ids * An array of menu link IDs. */
static::assertEquals(ProductDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertTrue($offset->hasNextDefinition());
        static::assertSame($timestamp$offset->getTimestamp());
        static::assertNull($offset->getLastId());

        $offset->selectNextDefinition();

        static::assertEquals(ProductManufacturerDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertEmpty($offset->getDefinitions());
        static::assertFalse($offset->hasNextDefinition());

        $offset->resetDefinitions();

        static::assertEquals(ProductDefinition::ENTITY_NAME, $offset->getDefinition());
        static::assertEquals(
            [
                ProductManufacturerDefinition::ENTITY_NAME,
            ],
            $offset->getDefinitions()
        );

        $offset->setLastId(['offset' => 42]);
        static::assertEquals(['offset' => 42]$offset->getLastId());
    }
if ($message) {
            return $message;
        }

        // all definitions in all languages indexed         if (!$offset->hasNextLanguage()) {
            return null;
        }

        // all definitions are indexed in current language, start again with next language         $offset->selectNextLanguage();
        $offset->resetDefinitions();
        $offset->setLastId(null);

        return $this->iterate($offset);
    }

    /** * @param array<string> $ids */
    public function updateIds(EntityDefinition $definition, array $ids): void
    {
        if ($this->helper->enabledMultilingualIndex()) {
            
// Modify and reset a standard menu link.     $instance = $this->getStandardMenuLink();
    $old_weight = $instance->getWeight();
    // Edit the static menu link.     $edit = [];
    $edit['weight'] = 10;
    $id = $instance->getPluginId();
    $this->drupalGet("admin/structure/menu/link/{$id}/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('The menu link has been saved.');
    $menu_link_manager->resetDefinitions();

    $instance = $menu_link_manager->createInstance($instance->getPluginId());
    $this->assertEquals($edit['weight']$instance->getWeight(), 'Saving an existing link updates the weight.');
    $this->resetMenuLink($instance$old_weight);
  }

  /** * Adds a custom menu using CRUD functions. */
  public function addCustomMenuCRUD() {
    // Add a new custom menu.

  protected function assertMenuLink(array $expected_item$menu_plugin_id) {
    // Retrieve the menu link.     /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    $menu_link_manager->resetDefinitions();
    // Reset the static load cache.     \Drupal::entityTypeManager()->getStorage('menu_link_content')->resetCache();
    $definition = $menu_link_manager->getDefinition($menu_plugin_id);

    $entity = NULL;

    // Pull the path from the menu link content.     if (str_starts_with($menu_plugin_id, 'menu_link_content')) {
      [$uuid] = explode(':', $menu_plugin_id, 2);
      /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */
      $entity = \Drupal::service('entity.repository')
        
Home | Imprint | This part of the site doesn't use cookies.