Skip to content

Commit

Permalink
Add support for Symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Oct 18, 2024
1 parent 8eaec5e commit 5a7b3a3
Show file tree
Hide file tree
Showing 61 changed files with 158 additions and 152 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"

steps:
- name: Checkout
Expand Down
52 changes: 26 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,47 @@
"sonata-project/seo-bundle": "^3.4",
"sonata-project/twig-extensions": "^1.3 || ^2.0",
"symfony-cmf/routing-bundle": "^2.1 || ^3.0",
"symfony/config": "^5.4 || ^6.2",
"symfony/console": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/form": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/intl": "^5.4 || ^6.2",
"symfony/options-resolver": "^5.4 || ^6.2",
"symfony/process": "^5.4 || ^6.2",
"symfony/property-access": "^5.4 || ^6.2",
"symfony/property-info": "^5.4 || ^6.2",
"symfony/routing": "^5.4 || ^6.2",
"symfony/runtime": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/security-http": "^5.4 || ^6.2",
"symfony/serializer": "^5.4.24 || ^6.2.11",
"symfony/validator": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/console": "^5.4 || ^6.2 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/form": "^5.4 || ^6.2 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
"symfony/intl": "^5.4 || ^6.2 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.2 || ^7.0",
"symfony/process": "^5.4 || ^6.2 || ^7.0",
"symfony/property-access": "^5.4 || ^6.2 || ^7.0",
"symfony/property-info": "^5.4 || ^6.2 || ^7.0",
"symfony/routing": "^5.4 || ^6.2 || ^7.0",
"symfony/runtime": "^5.4 || ^6.2 || ^7.0",
"symfony/security-core": "^5.4 || ^6.2 || ^7.0",
"symfony/security-http": "^5.4 || ^6.2 || ^7.0",
"symfony/serializer": "^5.4.24 || ^6.2.11 || ^7.0",
"symfony/validator": "^5.4 || ^6.2 || ^7.0",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
"require-dev": {
"dama/doctrine-test-bundle": "^7.0",
"dama/doctrine-test-bundle": "^8.0",
"friendsofphp/php-cs-fixer": "^3.4",
"masterminds/html5": "^2.7",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.1 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-phpunit": "^0.19",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^1.1",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/css-selector": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
"symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.2 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.2 || ^7.0",
"symfony/panther": "^2.0.1",
"symfony/phpunit-bridge": "^6.2",
"symfony/yaml": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^7.0",
"symfony/yaml": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "^5.0"
},
"conflict": {
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/BlockAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class BlockAdmin extends BaseBlockAdmin
*/
public function __construct(
BlockServiceManagerInterface $blockManager,
private array $blocks = []
private array $blocks = [],
) {
parent::__construct($blockManager);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ private function configureBlockFields(FormMapper $form, BlockInterface $block):
$service = $this->blockManager->get($block);

if (!$service instanceof EditableBlockService) {
throw new \RuntimeException(sprintf(
throw new \RuntimeException(\sprintf(
'The block "%s" must implement %s',
$blockType,
EditableBlockService::class
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/PageAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class PageAdmin extends AbstractAdmin

public function __construct(
private PageManagerInterface $pageManager,
private SiteManagerInterface $siteManager
private SiteManagerInterface $siteManager,
) {
parent::__construct();
}
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function alterNewInstance(object $object): void
protected function configurePersistentParameters(): array
{
$parameters = [];
$key = sprintf('%s.current_site', $this->getCode());
$key = \sprintf('%s.current_site', $this->getCode());

if (!$this->hasRequest()) {
return $parameters;
Expand Down Expand Up @@ -192,7 +192,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
$builder = $queryBuilder->getQueryBuilder();

if (\in_array($data->getValue(), ['hybrid', 'cms'], true)) {
$builder->andWhere(sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
$builder->andWhere(\sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
$builder->setParameter('routeName', PageInterface::PAGE_ROUTE_CMS_NAME);

return true;
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/SharedBlockAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ final class SharedBlockAdmin extends BaseBlockAdmin

protected function generateBaseRoutePattern(bool $isChildAdmin = false): string
{
return sprintf('%s/%s', parent::generateBaseRoutePattern($isChildAdmin), 'shared');
return \sprintf('%s/%s', parent::generateBaseRoutePattern($isChildAdmin), 'shared');
}

protected function generateBaseRouteName(bool $isChildAdmin = false): string
{
return sprintf('%s_%s', parent::generateBaseRouteName($isChildAdmin), 'shared');
return \sprintf('%s_%s', parent::generateBaseRouteName($isChildAdmin), 'shared');
}

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ private function configureBlockFields(FormMapper $form, BlockInterface $block):
$service = $this->blockManager->get($block);

if (!$service instanceof EditableBlockService) {
throw new \RuntimeException(sprintf(
throw new \RuntimeException(\sprintf(
'The block "%s" is not a valid %s',
$blockType,
EditableBlockService::class
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/SnapshotAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class SnapshotAdmin extends AbstractAdmin
public function __construct(
private TransformerInterface $transformer,
private PageManagerInterface $pageManager,
private SnapshotManagerInterface $snapshotManager
private SnapshotManagerInterface $snapshotManager,
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/BreadcrumbBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class BreadcrumbBlockService extends BaseBreadcrumbMenuBlockService implem
public function __construct(
Environment $twig,
FactoryInterface $factory,
private CmsManagerSelectorInterface $cmsSelector
private CmsManagerSelectorInterface $cmsSelector,
) {
parent::__construct($twig, $factory);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/ChildrenPagesBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
Environment $twig,
private SiteSelectorInterface $siteSelector,
private CmsManagerSelectorInterface $cmsManagerSelector,
private AdminInterface $pageAdmin
private AdminInterface $pageAdmin,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/PageListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class PageListBlockService extends AbstractBlockService implements Editabl
{
public function __construct(
Environment $twig,
private PageManagerInterface $pageManager
private PageManagerInterface $pageManager,
) {
parent::__construct($twig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Block/SharedBlockBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class SharedBlockBlockService extends AbstractBlockService implements Edit
public function __construct(
Environment $twig,
private ManagerInterface $blockManager,
private AdminInterface $sharedBlockAdmin
private AdminInterface $sharedBlockAdmin,
) {
parent::__construct($twig);
}
Expand Down
4 changes: 2 additions & 2 deletions src/CmsManager/CmsManagerSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
private CmsSnapshotManager $cmsSnapshotManager,
private AdminInterface $pageAdmin,
private TokenStorageInterface $tokenStorage,
private RequestStack $requestStack
private RequestStack $requestStack,
) {
}

Expand Down Expand Up @@ -76,7 +76,7 @@ public function onLoginSuccess(LoginSuccessEvent $event): void
*/
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event): void
{
@trigger_error(sprintf(
@trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7.0 and will be removed in 5.0.'
.' Use "%s()" instead.',
__METHOD__,
Expand Down
10 changes: 5 additions & 5 deletions src/CmsManager/CmsPageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class CmsPageManager extends BaseCmsPageManager

public function __construct(
private PageManagerInterface $pageManager,
private BlockInteractorInterface $blockInteractor
private BlockInteractorInterface $blockInteractor,
) {
}

Expand All @@ -73,18 +73,18 @@ public function getPage(SiteInterface $site, $page): PageInterface
public function getInternalRoute(SiteInterface $site, string $routeName): PageInterface
{
if (str_starts_with($routeName, 'error')) {
throw new \RuntimeException(sprintf('Illegal internal route name : %s, an internal page cannot start with `error`', $routeName));
throw new \RuntimeException(\sprintf('Illegal internal route name : %s, an internal page cannot start with `error`', $routeName));
}

$routeName = sprintf('_page_internal_%s', $routeName);
$routeName = \sprintf('_page_internal_%s', $routeName);

try {
$page = $this->getPageByRouteName($site, $routeName);
} catch (PageNotFoundException) {
$page = $this->pageManager->createWithDefaults([
'url' => null,
'routeName' => $routeName,
'name' => sprintf('Internal Page : %s', $routeName),
'name' => \sprintf('Internal Page : %s', $routeName),
'decorate' => false,
]);

Expand Down Expand Up @@ -151,7 +151,7 @@ protected function getPageBy(?SiteInterface $site, string $fieldName, $value): P
$page = $this->pageManager->findOneBy($parameters);

if (null === $page) {
throw new PageNotFoundException(sprintf('Unable to find the page : %s = %s', $fieldName, $value));
throw new PageNotFoundException(\sprintf('Unable to find the page : %s = %s', $fieldName, $value));
}

$this->loadBlocks($page);
Expand Down
4 changes: 2 additions & 2 deletions src/CmsManager/CmsSnapshotManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class CmsSnapshotManager extends BaseCmsPageManager

public function __construct(
private SnapshotManagerInterface $snapshotManager,
private TransformerInterface $transformer
private TransformerInterface $transformer,
) {
}

Expand All @@ -75,7 +75,7 @@ public function getPage(SiteInterface $site, $page): PageInterface

public function getInternalRoute(SiteInterface $site, string $routeName): PageInterface
{
return $this->getPageByRouteName($site, sprintf('_page_internal_%s', $routeName));
return $this->getPageByRouteName($site, \sprintf('_page_internal_%s', $routeName));
}

public function findContainer(string $name, PageInterface $page, ?PageBlockInterface $parentContainer = null): ?PageBlockInterface
Expand Down
6 changes: 3 additions & 3 deletions src/CmsManager/DecoratorStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class DecoratorStrategy implements DecoratorStrategyInterface
public function __construct(
private array $ignoreRoutes,
private array $ignoreRoutePatterns,
private array $ignoreUriPatterns
private array $ignoreUriPatterns,
) {
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public function isRouteNameDecorable(string $routeName): bool
}

foreach ($this->ignoreRoutePatterns as $routePattern) {
if (1 === preg_match(sprintf('#%s#', $routePattern), $routeName)) {
if (1 === preg_match(\sprintf('#%s#', $routePattern), $routeName)) {
return false;
}
}
Expand All @@ -91,7 +91,7 @@ public function isRouteNameDecorable(string $routeName): bool
public function isRouteUriDecorable(string $uri): bool
{
foreach ($this->ignoreUriPatterns as $uriPattern) {
if (1 === preg_match(sprintf('#%s#', $uriPattern), $uri)) {
if (1 === preg_match(\sprintf('#%s#', $uriPattern), $uri)) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CleanupSnapshotsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class CleanupSnapshotsCommand extends Command
{
public function __construct(
private CleanupSnapshotBySiteInterface $cleanupSnapshotBySite,
private SiteManagerInterface $siteManager
private SiteManagerInterface $siteManager,
) {
parent::__construct();
}
Expand All @@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$keepSnapshots = $input->getOption('keep-snapshots');

foreach ($this->getSites($siteOption) as $site) {
$output->write(sprintf('<info>%s</info> - Cleaning up snapshots ...', $site->getName() ?? ''));
$output->write(\sprintf('<info>%s</info> - Cleaning up snapshots ...', $site->getName() ?? ''));

$this->cleanupSnapshotBySite->cleanupBySite($site, (int) $keepSnapshots);

Expand Down
14 changes: 7 additions & 7 deletions src/Command/CloneSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class CloneSiteCommand extends Command
public function __construct(
private SiteManagerInterface $siteManager,
private PageManagerInterface $pageManager,
private BlockManagerInterface $blockManager
private BlockManagerInterface $blockManager,
) {
parent::__construct();
}
Expand Down Expand Up @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$parent = $page->getParent();

$output->writeln(sprintf(
$output->writeln(\sprintf(
' % 4s - % -70s - % 4s',
$pageId,
$page->getTitle() ?? '',
Expand All @@ -117,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$blockId = $block->getId();
\assert(null !== $blockId);

$output->writeln(sprintf(' cloning block % 4s ', $blockId));
$output->writeln(\sprintf(' cloning block % 4s ', $blockId));

$newBlock = clone $block;
$newBlock->setPage($newPage);
Expand All @@ -140,7 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
\assert(null !== $parentId);

if (\array_key_exists($parentId, $pageClones)) {
$output->writeln(sprintf(
$output->writeln(\sprintf(
'new parent: % 4s - % -70s - % 4s -> % 4s',
$page->getId() ?? '',
$page->getTitle() ?? '',
Expand All @@ -167,7 +167,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
\assert(null !== $parentBlockId);

if (\array_key_exists($parentBlockId, $blockClones)) {
$output->writeln(sprintf(
$output->writeln(\sprintf(
'new block parent: % 4s - % 4s',
$block->getId() ?? '',
$blockClones[$parentBlockId]->getId() ?? ''
Expand All @@ -189,12 +189,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function listAllSites(OutputInterface $output): void
{
$output->writeln(sprintf(' % 5s - % -30s - %s', 'ID', 'Name', 'Url'));
$output->writeln(\sprintf(' % 5s - % -30s - %s', 'ID', 'Name', 'Url'));

$sites = $this->siteManager->findAll();

foreach ($sites as $site) {
$output->writeln(sprintf(
$output->writeln(\sprintf(
' % 5s - % -30s - %s',
$site->getId() ?? '',
$site->getName() ?? '',
Expand Down
Loading

0 comments on commit 5a7b3a3

Please sign in to comment.