Skip to content
Snippets Groups Projects
Verified Commit 79a07a4e authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2901412 by claudiu.cristea, pfrenssen, grathbone, ravi.shankar,...

Issue #2901412 by claudiu.cristea, pfrenssen, grathbone, ravi.shankar, saidatom, Lendude, quietone: Add current route parameters to the confirmation form route
parent 64e5e002
No related branches found
No related tags found
36 merge requests!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8323Fix source code editing and in place front page site studio editing.,!6278Issue #3187770 by godotislate, smustgrave, catch, quietone: Views Rendered...,!3878Removed unused condition head title for views,!38582585169-10.1.x,!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),!3546refactored dialog.pcss file,!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3502Issue #3335308: Confusing behavior with FormState::setFormState and FormState::setMethod,!3452Issue #3332701: Refactor Claro's tablesort-indicator stylesheet,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3147Issue #3328457: Replace most substr($a, $i) where $i is negative with str_ends_with(),!3146Issue #3328456: Replace substr($a, 0, $i) with str_starts_with(),!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2614Issue #2981326: Replace non-test usages of \Drupal::logger() with IoC injection,!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,!844Resolve #3036010 "Updaters",!673Issue #3214208: FinishResponseSubscriber could create duplicate headers,!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 #61824 passed with warnings
Pipeline: drupal

#61830

    Pipeline: drupal

    #61829

      Pipeline: drupal

      #61828

        +1
        Showing
        with 245 additions and 6 deletions
        ......@@ -6,6 +6,7 @@
        use Drupal\comment\Plugin\views\field\CommentBulkForm;
        use Drupal\Core\Entity\EntityRepositoryInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Routing\ResettableStackedRouteMatchInterface;
        use Drupal\Tests\UnitTestCase;
        /**
        ......@@ -60,6 +61,8 @@ public function testConstructor() {
        $messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
        $route_match = $this->createMock(ResettableStackedRouteMatchInterface::class);
        $views_data = $this->getMockBuilder('Drupal\views\ViewsData')
        ->disableOriginalConstructor()
        ->getMock();
        ......@@ -90,7 +93,7 @@ public function testConstructor() {
        $definition['title'] = '';
        $options = [];
        $comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
        $comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository, $route_match);
        $comment_bulk_form->init($executable, $display, $options);
        $reflected_actions = (new \ReflectionObject($comment_bulk_form))->getProperty('actions');
        ......
        ......@@ -5,6 +5,7 @@
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\Entity\EntityRepositoryInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Routing\ResettableStackedRouteMatchInterface;
        use Drupal\node\Plugin\views\field\NodeBulkForm;
        use Drupal\Tests\UnitTestCase;
        ......@@ -60,6 +61,8 @@ public function testConstructor() {
        $messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
        $route_match = $this->createMock(ResettableStackedRouteMatchInterface::class);
        $views_data = $this->getMockBuilder('Drupal\views\ViewsData')
        ->disableOriginalConstructor()
        ->getMock();
        ......@@ -90,7 +93,7 @@ public function testConstructor() {
        $definition['title'] = '';
        $options = [];
        $node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
        $node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository, $route_match);
        $node_bulk_form->init($executable, $display, $options);
        $reflected_actions = (new \ReflectionObject($node_bulk_form))->getProperty('actions');
        ......
        ......@@ -5,6 +5,7 @@
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\Entity\EntityRepositoryInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Routing\ResettableStackedRouteMatchInterface;
        use Drupal\Tests\UnitTestCase;
        use Drupal\user\Plugin\views\field\UserBulkForm;
        ......@@ -60,6 +61,8 @@ public function testConstructor() {
        $messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
        $route_match = $this->createMock(ResettableStackedRouteMatchInterface::class);
        $views_data = $this->getMockBuilder('Drupal\views\ViewsData')
        ->disableOriginalConstructor()
        ->getMock();
        ......@@ -90,7 +93,7 @@ public function testConstructor() {
        $definition['title'] = '';
        $options = [];
        $user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
        $user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository, $route_match);
        $user_bulk_form->init($executable, $display, $options);
        $reflected_actions = (new \ReflectionObject($user_bulk_form))->getProperty('actions');
        ......
        ......@@ -12,6 +12,7 @@
        use Drupal\Core\Messenger\MessengerInterface;
        use Drupal\Core\Routing\RedirectDestinationTrait;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\Core\Routing\ResettableStackedRouteMatchInterface;
        use Drupal\Core\TypedData\TranslatableInterface;
        use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
        use Drupal\views\Plugin\views\display\DisplayPluginBase;
        ......@@ -73,6 +74,13 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
        */
        protected $messenger;
        /**
        * The current route match service.
        *
        * @var \Drupal\Core\Routing\ResettableStackedRouteMatchInterface
        */
        protected ResettableStackedRouteMatchInterface $routeMatch;
        /**
        * Constructs a new BulkForm object.
        *
        ......@@ -90,10 +98,13 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
        * The messenger.
        * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
        * The entity repository.
        * @param \Drupal\Core\Routing\ResettableStackedRouteMatchInterface $route_match
        * The current route match service.
        *
        * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
        * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
        */
        public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, MessengerInterface $messenger, EntityRepositoryInterface $entity_repository) {
        public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, MessengerInterface $messenger, EntityRepositoryInterface $entity_repository, ResettableStackedRouteMatchInterface $route_match = NULL) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->entityTypeManager = $entity_type_manager;
        ......@@ -101,6 +112,11 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
        $this->languageManager = $language_manager;
        $this->messenger = $messenger;
        $this->entityRepository = $entity_repository;
        if (!$route_match) {
        @trigger_error('Calling BulkForm::__construct() without the $route_match argument is deprecated in drupal:10.3.0 and the $route_match argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3115868', E_USER_DEPRECATED);
        $route_match = \Drupal::routeMatch();
        }
        $this->routeMatch = $route_match;
        }
        /**
        ......@@ -114,7 +130,8 @@ public static function create(ContainerInterface $container, array $configuratio
        $container->get('entity_type.manager'),
        $container->get('language_manager'),
        $container->get('messenger'),
        $container->get('entity.repository')
        $container->get('entity.repository'),
        $container->get('current_route_match')
        );
        }
        ......@@ -428,7 +445,8 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
        $options = [
        'query' => $this->getDestinationArray(),
        ];
        $form_state->setRedirect($operation_definition['confirm_form_route_name'], [], $options);
        $route_parameters = $this->routeMatch->getRawParameters()->all();
        $form_state->setRedirect($operation_definition['confirm_form_route_name'], $route_parameters, $options);
        }
        else {
        // Don't display the message unless there are some elements affected and
        ......
        action_bulk_test.action.confirm:
        path: '/node/{node}/confirm'
        defaults:
        _form: Drupal\action_bulk_test\Form\TestActionConfirmForm
        requirements:
        _access: 'TRUE'
        options:
        parameters:
        node:
        type: entity:node
        langcode: en
        status: true
        dependencies:
        module:
        - action_bulk_test
        id: test_action
        label: 'Test action'
        type: node
        plugin: test_action
        configuration: { }
        ......@@ -120,6 +120,8 @@ display:
        group: 1
        expose:
        operator: ''
        operator_limit_selection: false
        operator_list: { }
        style:
        type: table
        options:
        ......@@ -151,6 +153,17 @@ display:
        type: fields
        query:
        type: views_query
        display_extenders: { }
        arguments: { }
        cache_metadata:
        max-age: 0
        contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url.query_args
        - 'user.node_grants:view'
        - user.permissions
        tags: { }
        page_1:
        id: page_1
        display_title: Page
        ......@@ -158,6 +171,16 @@ display:
        position: null
        display_options:
        path: test_bulk_form
        display_extenders: { }
        cache_metadata:
        max-age: 0
        contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url.query_args
        - 'user.node_grants:view'
        - user.permissions
        tags: { }
        page_2:
        id: page_2
        display_title: Page
        ......@@ -205,3 +228,66 @@ display:
        row: false
        display_extenders: { }
        path: display-without-fields
        page_4:
        id: page_4
        display_title: 'Page 4'
        display_plugin: page
        position: 4
        display_options:
        arguments:
        nid:
        id: nid
        table: node_field_data
        field: nid
        relationship: none
        group_type: group
        admin_label: ''
        default_action: ignore
        exception:
        value: all
        title_enable: false
        title: All
        title_enable: false
        title: ''
        default_argument_type: fixed
        default_argument_options:
        argument: ''
        default_argument_skip_url: false
        summary_options:
        base_path: ''
        count: true
        items_per_page: 25
        override: false
        summary:
        sort_order: asc
        number_of_records: 0
        format: default_summary
        specify_validation: true
        validate:
        type: 'entity:node'
        fail: 'not found'
        validate_options:
        operation: view
        multiple: 0
        bundles: { }
        access: false
        break_phrase: false
        not: false
        entity_type: node
        entity_field: nid
        plugin_id: node_nid
        defaults:
        arguments: false
        display_description: ''
        display_extenders: { }
        path: node/%node/test_bulk_form
        cache_metadata:
        max-age: 0
        contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - 'user.node_grants:view'
        - user.permissions
        tags: { }
        action.configuration.test_action:
        type: mapping
        <?php
        namespace Drupal\action_bulk_test\Form;
        use Drupal\Component\Render\MarkupInterface;
        use Drupal\Core\Form\ConfirmFormBase;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Url;
        /**
        * Confirmation form for 'test_action' action.
        */
        class TestActionConfirmForm extends ConfirmFormBase {
        /**
        * {@inheritdoc}
        */
        public function getFormId(): string {
        return 'test_action_confirm_form';
        }
        /**
        * {@inheritdoc}
        */
        public function getCancelUrl(): Url {
        return Url::fromRoute('<front>');
        }
        /**
        * {@inheritdoc}
        */
        public function getQuestion(): MarkupInterface {
        return $this->t('Do you agree?');
        }
        /**
        * {@inheritdoc}
        */
        public function submitForm(array &$form, FormStateInterface $form_state): void {
        }
        }
        <?php
        namespace Drupal\action_bulk_test\Plugin\Action;
        use Drupal\Core\Access\AccessResult;
        use Drupal\Core\Access\AccessResultInterface;
        use Drupal\Core\Action\ActionBase;
        use Drupal\Core\Action\Attribute\Action;
        use Drupal\Core\Session\AccountInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        /**
        * Test action.
        */
        #[Action(
        id: 'test_action',
        label: new TranslatableMarkup('Test action'),
        type: 'node',
        confirm_form_route_name: 'action_bulk_test.action.confirm'
        )]
        class TestAction extends ActionBase {
        /**
        * {@inheritdoc}
        */
        public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE): bool|AccessResultInterface {
        return $return_as_object ? AccessResult::allowed() : TRUE;
        }
        /**
        * {@inheritdoc}
        */
        public function execute(): void {
        }
        }
        ......@@ -4,6 +4,7 @@
        use Drupal\Component\Render\FormattableMarkup;
        use Drupal\Tests\BrowserTestBase;
        use Drupal\Tests\node\Traits\NodeCreationTrait;
        use Drupal\views\Views;
        /**
        ......@@ -14,6 +15,8 @@
        */
        class BulkFormTest extends BrowserTestBase {
        use NodeCreationTrait;
        /**
        * Modules to install.
        *
        ......@@ -219,4 +222,27 @@ public function testBulkForm() {
        $this->assertSession()->pageTextContains('No content selected.');
        }
        /**
        * Tests that route parameters are passed to the confirmation form route.
        */
        public function testConfirmRouteWithParameters(): void {
        $session = $this->getSession();
        $page = $session->getPage();
        $assert = $this->assertSession();
        $node = $this->createNode();
        // Access the view page.
        $this->drupalGet('/node/' . $node->id() . '/test_bulk_form');
        // Select a node and perform the 'Test action'.
        $page->checkField('node_bulk_form[0]');
        $page->selectFieldOption('Action', 'Test action');
        $page->pressButton('Apply to selected items');
        // Check that we've been landed on the confirmation form.
        $assert->pageTextContains('Do you agree?');
        // Check that route parameters were passed to the confirmation from route.
        $assert->addressEquals('/node/' . $node->id() . '/confirm');
        }
        }
        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