Commit e741d4ca authored by Jakob P's avatar Jakob P
Browse files

Issue #3465313: Max Bundles not being honored

parent 9fa420b4
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -120,7 +120,12 @@ class SearchLinks {
      $content_entity = $entities['content_entity'];
      // Load the remaining items that were not loaded by the toolbar.
      $content_entity_bundle_storage = $this->entityTypeManager->getStorage($content_entity_bundle);
      $bundles_ids = $content_entity_bundle_storage->getQuery()->accessCheck()->sort('weight')->range($max_bundle_number)->execute();
      $bundles_ids = $content_entity_bundle_storage->getQuery()
        ->accessCheck()
        ->sort('weight')
        ->sort($this->entityTypeManager->getDefinition($content_entity_bundle)->getKey('label'))
        ->range($max_bundle_number)
        ->execute();
      if (!empty($bundles_ids)) {
        $bundles = $this->entityTypeManager
          ->getStorage($content_entity_bundle)
+7 −0
Original line number Diff line number Diff line
@@ -185,6 +185,13 @@ class AdminToolbarToolsSearchTest extends AdminToolbarSearchTestBase {
    // Test that bundle within admin toolbar appears in search.
    $this->assertSuggestionContains('lola', 'admin/structure/media/manage/lola/fields');

    // Assert that a link after the limit doesn't appear in admin toolbar.
    $zora_url = '/admin/structure/media/manage/zora/fields';
    $assert_session->elementNotContains('css', '#toolbar-administration', $zora_url);

    // Assert that a link excluded from admin toolbar appears in search.
    $this->assertSuggestionContains('zora', $zora_url);

    // Test that adding a new bundle updates the extra links loaded from
    // admin_toolbar.search route.
    $this->createMediaType('image', [
+6 −1
Original line number Diff line number Diff line
@@ -111,7 +111,12 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface {
      $content_entity_bundle = $entities['content_entity_bundle'];
      $content_entity = $entities['content_entity'];
      $content_entity_bundle_storage = $this->entityTypeManager->getStorage($content_entity_bundle);
      $bundles_ids = $content_entity_bundle_storage->getQuery()->accessCheck()->sort('weight')->pager($max_bundle_number)->execute();
      $bundles_ids = $content_entity_bundle_storage->getQuery()
        ->accessCheck()
        ->sort('weight')
        ->sort($this->entityTypeManager->getDefinition($content_entity_bundle)->getKey('label'))
        ->pager($max_bundle_number)
        ->execute();
      $bundles = $this->entityTypeManager->getStorage($content_entity_bundle)->loadMultiple($bundles_ids);
      if (count($bundles) == $max_bundle_number && $this->routeExists('entity.' . $content_entity_bundle . '.collection')) {
        $links[$content_entity_bundle . '.collection'] = [