Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Twig and Doctrine extensions 2.0 #1520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"doctrine/persistence": "^2.1 || ^3.0",
"sonata-project/admin-bundle": "^4.15",
"sonata-project/block-bundle": "^4.16",
"sonata-project/doctrine-extensions": "^1.8",
"sonata-project/doctrine-extensions": "^1.8 || ^2.0",
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"sonata-project/form-extensions": "^1.4",
"sonata-project/seo-bundle": "^3.0",
"sonata-project/twig-extensions": "^1.3",
"sonata-project/twig-extensions": "^1.3 || ^2.0",
"symfony-cmf/routing-bundle": "^2.1 || ^3.0",
"symfony/config": "^4.4 || ^5.4 || ^6.0",
"symfony/console": "^4.4 || ^5.4 || ^6.0",
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CloneSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$this->pageManager->save($page, true);
$this->pageManager->save($page);
}

$output->writeln('Fixing block parents');
Expand All @@ -183,7 +183,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$block->setParent(null);
}

$this->blockManager->save($block, true);
$this->blockManager->save($block);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Entity/PageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public function fixUrl(PageInterface $page): void
}
}

public function save($entity, $andFlush = true)
/**
* TODO: Add tyephinting once sonata-project/doctrine-extensions < 2 is dropped.
*/
public function save($entity, $andFlush = true): void
{
if (!$entity->isHybrid()) {
$this->fixUrl($entity);
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateBlockContainerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testCreateBlock(): void

$page = new Page();
$pageManager->method('findBy')->with(['templateCode' => 'foo'])->willReturn([$page]);
$pageManager->method('save')->with($page)->willReturn($page);
$pageManager->method('save')->with($page);

$command = new CreateBlockContainerCommand($pageManager, $blockInteractor);

Expand Down
10 changes: 7 additions & 3 deletions tests/Route/RoutePageGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ private function getRoutePageGenerator(): RoutePageGenerator

$pageManager->expects(static::atLeastOnce())
->method('findOneBy')
->willReturnMap([
[['routeName' => 'test_hybrid_page_with_bad_host', 'site' => 1], null, $hybridPageWithBadHost],
]);
->willReturnCallback(static function ($criteria) use ($hybridPageWithBadHost) {
if ($criteria === ['routeName' => 'test_hybrid_page_with_bad_host', 'site' => 1]) {
return $hybridPageWithBadHost;
}

return null;
});

$pageManager
->method('getHybridPages')
Expand Down