Skip to content
Snippets Groups Projects
Unverified Commit fef85c9a 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

(cherry picked from commit 3de28c0f)
parent d2cfad9c
No related branches found
No related tags found
22 merge requests!11636Draft: Issue #3515643 by macsim: fieldNameExists method is inconsistent,!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11281Use Drupal Core Leadership terminology in MAINTAINERS.txt,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator,!10570Issue #3494197: Convert Twig engine hooks,!10567Issue #3494154: Index is not added if entity doesn't support revisions,!10548Revert "Issue #3478621 by catch, longwave, nicxvan: Add filecache to OOP hook attribute parsing",!10404Margin has been added,!10391Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10388Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10376Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...
Pipeline #350402 canceled
Pipeline: drupal

#350403

    ......@@ -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.
    Finish editing this message first!
    Please register or to comment