Skip to content
Snippets Groups Projects
Unverified Commit 3de28c0f authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3483353 by a.dmitriiev, phenaproxima, atul_ghate, alexpott, roderik:...

Issue #3483353 by a.dmitriiev, phenaproxima, atul_ghate, alexpott, roderik: Remove the createCopy action from EntityDisplayBase, and make cloneAs compatible with wildcards
parent 4650172f
Branches
Tags
13 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #350124 passed with warnings
Pipeline: drupal

#350171

    Pipeline: drupal

    #350165

      Pipeline: drupal

      #350157

        +4
        ......@@ -56,6 +56,21 @@ public function apply(string $configName, mixed $value): void {
        if (empty($original)) {
        throw new ConfigActionException("Cannot clone '$configName' because it does not exist.");
        }
        // Treat the original ID like a period-separated array of strings, and
        // replace any `%` parts in the clone's ID with the corresponding part of
        // the original ID. For example, if we're cloning an entity view display
        // with the ID `node.foo.teaser`, and the clone's ID is
        // `node.%.search_result`, the final ID of the clone will be
        // `node.foo.search_result`.
        $original_id_parts = explode('.', $original->id());
        $clone_id_parts = explode('.', $value['id']);
        assert(count($original_id_parts) === count($clone_id_parts));
        foreach ($clone_id_parts as $index => $part) {
        $clone_id_parts[$index] = $part === '%' ? $original_id_parts[$index] : $part;
        }
        $value['id'] = implode('.', $clone_id_parts);
        $clone = $original->createDuplicate();
        $clone->set($original->getEntityType()->getKey('id'), $value['id']);
        ......
        ......@@ -324,7 +324,6 @@ public function toArray() {
        /**
        * {@inheritdoc}
        */
        #[ActionMethod(adminLabel: new TranslatableMarkup('Copy to another mode'), pluralize: FALSE)]
        public function createCopy($mode) {
        $display = $this->createDuplicate();
        $display->mode = $display->originalMode = $mode;
        ......
        ......@@ -93,9 +93,9 @@ public function testFailIfEntityExists(): void {
        }
        /**
        * Tests cloning entity displays, which have specialized logic for that.
        * Tests wildcard support, which allows positional tokens in the clone's ID.
        */
        public function testCloneEntityDisplay(): void {
        public function testCloneWithWildcards(): void {
        $this->container->get(ModuleInstallerInterface::class)->install(['node']);
        $this->createContentType(['type' => 'alpha']);
        $this->createContentType(['type' => 'beta']);
        ......@@ -112,17 +112,9 @@ public function testCloneEntityDisplay(): void {
        // Use the action to clone the default view displays to the `rss` view mode.
        /** @var \Drupal\Core\Config\Action\ConfigActionManager $manager */
        $manager = $this->container->get('plugin.manager.config_action');
        $manager->applyAction('cloneAs', 'core.entity_view_display.node.alpha.default', 'node.alpha.rss');
        $manager->applyAction('entity_method:core.entity_view_display:createCopy', 'core.entity_view_display.node.beta.default', 'rss');
        $manager->applyAction('cloneAs', 'core.entity_view_display.node.*.default', 'node.%.rss');
        $this->assertFalse($display_repository->getViewDisplay('node', 'alpha', 'rss')->isNew());
        $this->assertFalse($display_repository->getViewDisplay('node', 'beta', 'rss')->isNew());
        // Ensure that this also works with wildcards.
        $this->assertTrue($display_repository->getViewDisplay('node', 'alpha', 'search_result')->isNew());
        $this->assertTrue($display_repository->getViewDisplay('node', 'beta', 'search_result')->isNew());
        $manager->applyAction('entity_method:core.entity_view_display:createCopy', 'core.entity_view_display.node.*.default', 'search_result');
        $this->assertFalse($display_repository->getViewDisplay('node', 'alpha', 'search_result')->isNew());
        $this->assertFalse($display_repository->getViewDisplay('node', 'beta', 'search_result')->isNew());
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment