Skip to content
Snippets Groups Projects
Verified Commit 43717fbb authored by Dave Long's avatar Dave Long
Browse files

Issue #3488664 by phenaproxima: The PlaceBlock config action breaks when...

Issue #3488664 by phenaproxima: The PlaceBlock config action breaks when placing a block in an empty region
parent 4c9cd84e
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 #346991 passed with warnings
Pipeline: drupal

#347015

    Pipeline: drupal

    #347004

      Pipeline: drupal

      #346997

        ......@@ -73,15 +73,17 @@ public function apply(string $configName, mixed $value): void {
        'theme' => $theme,
        'region' => $value['region'],
        ]);
        // Sort the blocks by weight. Don't use \Drupal\block\Entity\Block::sort()
        // here because it seems to be intended to sort blocks in the UI, where
        // we really just want to get the weights right in this situation.
        uasort($blocks, fn (BlockInterface $a, BlockInterface $b) => $a->getWeight() <=> $b->getWeight());
        if ($blocks) {
        // Sort the blocks by weight. Don't use \Drupal\block\Entity\Block::sort()
        // here because it seems to be intended to sort blocks in the UI, where
        // we really just want to get the weights right in this situation.
        uasort($blocks, fn (BlockInterface $a, BlockInterface $b) => $a->getWeight() <=> $b->getWeight());
        $value['weight'] = match ($value['position']) {
        'first' => reset($blocks)->getWeight() - 1,
        'last' => end($blocks)->getWeight() + 1,
        };
        $value['weight'] = match ($value['position']) {
        'first' => reset($blocks)->getWeight() - 1,
        'last' => end($blocks)->getWeight() + 1,
        };
        }
        }
        // Remove values that are not valid properties of block entities.
        unset($value['position'], $value['default_region']);
        ......
        ......@@ -180,4 +180,28 @@ public function testPlaceBlockAtPosition(): void {
        $this->assertSame('last', end($blocks));
        }
        /**
        * Tests using the PlaceBlock action in an empty region.
        */
        public function testPlaceBlockInEmptyRegion(): void {
        /** @var \Drupal\Core\Entity\Query\QueryInterface $query */
        $query = $this->container->get(EntityTypeManagerInterface::class)
        ->getStorage('block')
        ->getQuery()
        ->count()
        ->condition('theme', 'olivero')
        ->condition('region', 'footer_top');
        $this->assertSame(0, $query->execute());
        // Place a block in that region.
        $this->configActionManager->applyAction('placeBlockInDefaultTheme', 'block.block.test', [
        'plugin' => 'system_powered_by_block',
        'region' => [
        'olivero' => 'footer_top',
        ],
        'position' => 'first',
        ]);
        $this->assertSame(1, $query->execute());
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment