Skip to content
Snippets Groups Projects
Commit 79a3985d authored by catch's avatar catch
Browse files

Issue #3423889 by smustgrave, Spokje: [11.x] Remove deprecated code from block content module

parent 6490db80
No related branches found
No related tags found
30 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #108089 canceled
Pipeline: drupal

#108091

    ......@@ -8,32 +8,6 @@ block_content.add_page:
    requirements:
    _entity_create_any_access: 'block_content'
    # @todo Deprecate this route once
    # https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    # it in Drupal 11.
    # @see https://www.drupal.org/node/3320855
    entity.block_content_type.collection.bc:
    path: '/admin/structure/block/block-content/types'
    defaults:
    _controller: '\Drupal\block_content\Controller\BlockContentController::blockContentTypeRedirect'
    options:
    _admin_route: TRUE
    requirements:
    _permission: 'administer block types'
    # @todo Deprecate this route once
    # https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    # it in Drupal 11.
    # @see https://www.drupal.org/node/3320855
    entity.block_content_type.edit_form.bc:
    path: '/admin/structure/block/block-content/manage/{block_content_type}'
    defaults:
    _controller: '\Drupal\block_content\Controller\BlockContentController::blockContentTypeRedirect'
    options:
    _admin_route: TRUE
    requirements:
    _permission: 'administer block types'
    block_content.add_form:
    path: '/block/add/{block_content_type}'
    defaults:
    ......@@ -65,20 +39,6 @@ entity.block_content.edit_form:
    _entity_access: 'block_content.update'
    block_content: \d+
    # @todo Deprecate this route once
    # https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    # it in Drupal 11.
    # @see https://www.drupal.org/node/2317981
    entity.block_content.edit_form.bc:
    path: '/block/{block_content}'
    defaults:
    _controller: '\Drupal\block_content\Controller\BlockContentController::editRedirect'
    options:
    _admin_route: TRUE
    requirements:
    _entity_access: 'block_content.update'
    block_content: \d+
    entity.block_content.delete_form:
    path: '/admin/content/block/{block_content}/delete'
    defaults:
    ......@@ -90,20 +50,6 @@ entity.block_content.delete_form:
    _entity_access: 'block_content.delete'
    block_content: \d+
    # @todo Deprecate this route once
    # https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    # it in Drupal 11.
    # @see https://www.drupal.org/node/2317981
    entity.block_content.delete_form.bc:
    path: '/block/{block_content}/delete'
    defaults:
    _controller: '\Drupal\block_content\Controller\BlockContentController::editRedirect'
    options:
    _admin_route: TRUE
    requirements:
    _entity_access: 'block_content.delete'
    block_content: \d+
    block_content.type_add:
    path: '/admin/structure/block-content/add'
    defaults:
    ......@@ -119,14 +65,3 @@ entity.block_content.collection:
    _entity_list: 'block_content'
    requirements:
    _permission: 'access block library+administer block content'
    # @todo Deprecate this route once
    # https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    # it in Drupal 11.
    # @see https://www.drupal.org/node/3320855
    entity.block_content.collection.bc:
    path: '/admin/structure/block/block-content'
    defaults:
    _controller: '\Drupal\block_content\Controller\BlockContentController::blockLibraryRedirect'
    requirements:
    _permission: 'access block library+administer block content'
    ......@@ -4,15 +4,11 @@
    use Drupal\Core\Controller\ControllerBase;
    use Drupal\Core\Entity\EntityStorageInterface;
    use Drupal\Core\Routing\PathChangedHelper;
    use Drupal\Core\Routing\RouteMatchInterface;
    use Drupal\block_content\BlockContentInterface;
    use Drupal\block_content\BlockContentTypeInterface;
    use Drupal\Core\Extension\ThemeHandlerInterface;
    use Drupal\Core\Url;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\RedirectResponse;
    class BlockContentController extends ControllerBase {
    ......@@ -140,100 +136,4 @@ public function getAddFormTitle(BlockContentTypeInterface $block_content_type) {
    return $this->t('Add %type content block', ['%type' => $block_content_type->label()]);
    }
    /**
    * Provides a redirect to the list of block types.
    *
    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
    * A route match object, used for the route name and the parameters.
    * @param \Symfony\Component\HttpFoundation\Request $request
    * The current request object.
    *
    * @return \Symfony\Component\HttpFoundation\RedirectResponse
    *
    * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
    * /admin/structure/block-content directly instead of
    * /admin/structure/block/block-content/types.
    *
    * @see https://www.drupal.org/node/3320855
    */
    public function blockContentTypeRedirect(RouteMatchInterface $route_match, Request $request): RedirectResponse {
    @trigger_error('The path /admin/structure/block/block-content/types is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/structure/block-content. See https://www.drupal.org/node/3320855', E_USER_DEPRECATED);
    $helper = new PathChangedHelper($route_match, $request);
    $params = [
    '%old_path' => $helper->oldPath(),
    '%new_path' => $helper->newPath(),
    '%change_record' => 'https://www.drupal.org/node/3320855',
    ];
    $warning_message = $this->t('You have been redirected from %old_path. Update links, shortcuts, and bookmarks to use %new_path.', $params);
    $this->messenger()->addWarning($warning_message);
    $this->getLogger('block_content')->warning('A user was redirected from %old_path. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use %new_path. See %change_record for more information.', $params);
    return $helper->redirect();
    }
    /**
    * Provides a redirect to the content block library.
    *
    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
    * A route match object, used for the route name and the parameters.
    * @param \Symfony\Component\HttpFoundation\Request $request
    * The current request object.
    *
    * @return \Symfony\Component\HttpFoundation\RedirectResponse
    *
    * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
    * /admin/content/block directly instead of
    * /admin/structure/block/block-content.
    *
    * @see https://www.drupal.org/node/3320855
    */
    public function blockLibraryRedirect(RouteMatchInterface $route_match, Request $request) {
    @trigger_error('The path /admin/structure/block/block-content is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block. See https://www.drupal.org/node/3320855', E_USER_DEPRECATED);
    $helper = new PathChangedHelper($route_match, $request);
    $params = [
    '%old_path' => $helper->oldPath(),
    '%new_path' => $helper->newPath(),
    '%change_record' => 'https://www.drupal.org/node/3320855',
    ];
    $warning_message = $this->t('You have been redirected from %old_path. Update links, shortcuts, and bookmarks to use %new_path.', $params);
    $this->messenger()->addWarning($warning_message);
    $this->getLogger('block_content')
    ->warning('A user was redirected from %old_path. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use %new_path. See %change_record for more information.', $params);
    return $helper->redirect();
    }
    /**
    * Provides a redirect to block edit page.
    *
    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
    * A route match object, used for the route name and the parameters.
    * @param \Symfony\Component\HttpFoundation\Request $request
    * The current request object.
    * @param Drupal\block_content\BlockContentInterface $block_content
    * The block to be edited.
    *
    * @return \Symfony\Component\HttpFoundation\RedirectResponse
    *
    * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
    * /admin/content/block/{block_content} directly instead of
    * /block/{block_content}.
    *
    * @see https://www.drupal.org/node/3320855
    */
    public function editRedirect(RouteMatchInterface $route_match, Request $request, BlockContentInterface $block_content): RedirectResponse {
    @trigger_error('The path /block/{block_content} is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block/{block_content}. See https://www.drupal.org/node/3320855', E_USER_DEPRECATED);
    $helper = new PathChangedHelper($route_match, $request);
    $params = [
    '%old_path' => $helper->oldPath(),
    '%new_path' => $helper->newPath(),
    '%change_record' => 'https://www.drupal.org/node/3320855',
    ];
    $warning_message = $this->t('You have been redirected from %old_path. Update links, shortcuts, and bookmarks to use %new_path.', $params);
    $this->messenger()->addWarning($warning_message);
    $this->getLogger('block_content')->warning('A user was redirected from %old_path to %new_path. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use %new_path. See %change_record for more information.', $params);
    return $helper->redirect();
    }
    }
    <?php
    declare(strict_types=1);
    namespace Drupal\Tests\block_content\Functional;
    /**
    * Ensures that custom block type functions work correctly.
    *
    * @group block_content
    * @group legacy
    */
    class BlockContentRedirectTest extends BlockContentTestBase {
    /**
    * {@inheritdoc}
    */
    protected $defaultTheme = 'stark';
    /**
    * Tests the deprecation message from the old block-type page.
    *
    * @group legacy
    */
    public function testBlockContentTypeRedirect() {
    $this->drupalLogin($this->adminUser);
    $this->expectDeprecation('The path /admin/structure/block/block-content/types is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/structure/block-content. See https://www.drupal.org/node/3320855');
    $this->drupalGet('/admin/structure/block/block-content/types');
    $this->assertSession()
    ->pageTextContains("You have been redirected from admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use admin/structure/block-content.");
    }
    /**
    * Tests the deprecation message from the old block library page.
    *
    * @group legacy
    */
    public function testBlockLibraryRedirect() {
    $this->drupalLogin($this->adminUser);
    $this->expectDeprecation('The path /admin/structure/block/block-content is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block. See https://www.drupal.org/node/3320855');
    $this->drupalGet('admin/structure/block/block-content');
    $this->assertSession()
    ->pageTextContains("You have been redirected from admin/structure/block/block-content. Update links, shortcuts, and bookmarks to use admin/content/block.");
    }
    /**
    * Tests the deprecation message from the old block edit page.
    *
    * @group legacy
    */
    public function testBlockContentEditRedirect(): void {
    $block = $this->createBlockContent();
    $this->drupalLogin($this->adminUser);
    $this->expectDeprecation('The path /block/{block_content} is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block/{block_content}. See https://www.drupal.org/node/3320855');
    $this->drupalGet("/block/{$block->id()}");
    $this->assertSession()
    ->pageTextContains("You have been redirected from block/{$block->id()}. Update links, shortcuts, and bookmarks to use admin/content/block/{$block->id()}.");
    }
    /**
    * Tests the deprecation message from the old block delete page.
    *
    * @group legacy
    */
    public function testBlockContentDeleteRedirect(): void {
    $block = $this->createBlockContent();
    $this->drupalLogin($this->adminUser);
    $this->expectDeprecation('The path /block/{block_content} is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/content/block/{block_content}. See https://www.drupal.org/node/3320855');
    $this->drupalGet("/block/{$block->id()}/delete");
    $this->assertSession()
    ->pageTextContains("You have been redirected from block/{$block->id()}/delete. Update links, shortcuts, and bookmarks to use admin/content/block/{$block->id()}/delete.");
    }
    }
    ......@@ -508,7 +508,7 @@ public function testAccess() {
    $this->assertSaveLayout();
    $node_1_block_id = $this->getLatestBlockEntityId();
    $this->drupalGet("block/$node_1_block_id");
    $this->drupalGet("admin/content/block/$node_1_block_id");
    $assert_session->pageTextNotContains('You are not authorized to access this page');
    $this->drupalLogout();
    ......@@ -516,13 +516,13 @@ public function testAccess() {
    'administer nodes',
    ]));
    $this->drupalGet("block/$node_1_block_id");
    $this->drupalGet("admin/content/block/$node_1_block_id");
    $assert_session->pageTextContains('You are not authorized to access this page');
    $this->drupalLogin($this->drupalCreateUser([
    'create and edit custom blocks',
    ]));
    $this->drupalGet("block/$node_1_block_id");
    $this->drupalGet("admin/content/block/$node_1_block_id");
    $assert_session->pageTextNotContains('You are not authorized to access this page');
    }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment