Skip to content

Commit

Permalink
Fix phpstan (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
eerison committed Dec 12, 2023
1 parent f10a9fa commit 13e5c1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
34 changes: 12 additions & 22 deletions src/CmsManager/CmsPageManager.php
Expand Up @@ -96,38 +96,28 @@ public function getInternalRoute(SiteInterface $site, string $routeName): PageIn
return $page;
}

public function findContainer(string $name, PageInterface $page, ?PageBlockInterface $parentContainer = null): ?PageBlockInterface
public function findContainer(string $name, PageInterface $page, ?PageBlockInterface $parentContainer = null): PageBlockInterface
{
$container = null;

if (null !== $parentContainer) {
// parent container is set, nothing to find, don't need to loop across the
// name to find the correct container (main template level)
$container = $parentContainer;
return $parentContainer;
}

// first level blocks are containers
if (null === $container) {
foreach ($page->getBlocks() as $block) {
if ($block->getSetting('code') === $name) {
$container = $block;

break;
}
foreach ($page->getBlocks() as $block) {
if ($block->getSetting('code') === $name) {
return $block;
}
}

if (null === $container) {
$container = $this->blockInteractor->createNewContainer([
'enabled' => true,
'page' => $page,
'code' => $name,
'position' => 1,
'parent' => $parentContainer,
]);
}

return $container;
return $this->blockInteractor->createNewContainer([
'enabled' => true,
'page' => $page,
'code' => $name,
'position' => 1,
'parent' => $parentContainer,
]);
}

public function getBlock($id): ?PageBlockInterface
Expand Down
1 change: 0 additions & 1 deletion tests/CmsManager/CmsPageManagerTest.php
Expand Up @@ -60,7 +60,6 @@ public function testFindExistingContainer(): void

$container = $this->manager->findContainer('findme', $page);

static::assertNotNull($container);
static::assertSame(
spl_object_hash($block),
spl_object_hash($container),
Expand Down

0 comments on commit 13e5c1d

Please sign in to comment.