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 Symfony 5 compatibility #6263

Closed
wants to merge 2 commits into from
Closed
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
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@
"sonata-project/exporter": "^1.11 || ^2.0",
"sonata-project/form-extensions": "^0.1.1 || ^1.4",
"sonata-project/twig-extensions": "^0.1.1 || ^1.3",
"symfony/asset": "^4.4",
"symfony/config": "^4.4",
"symfony/console": "^4.4",
"symfony/dependency-injection": "^4.4.3",
"symfony/doctrine-bridge": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/asset": "^4.4 || ^5.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for ^4.4 || ^5.1 on Symfony packages rather than ^4.4 || ^5.0? Is there something hard to support in 5.0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony 5.0 is EOL (not supported anymore). See https://symfony.com/releases

So does not really make sense to support it here I believe 😊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is, sorry 🤦

"symfony/config": "^4.4 || ^5.1",
"symfony/console": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4.3 || ^5.1",
"symfony/doctrine-bridge": "^4.4 || ^5.1",
"symfony/event-dispatcher": "^4.4 || ^5.1",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0",
"symfony/expression-language": "^4.4 || ^5.1",
"symfony/form": "^4.4.12",
"symfony/framework-bundle": "^4.4",
"symfony/form": "^4.4.12 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-foundation": "^4.4 || ^5.1",
"symfony/http-kernel": "^4.4",
"symfony/http-kernel": "^4.4 || ^5.1",
"symfony/options-resolver": "^4.4 || ^5.1",
"symfony/property-access": "^4.4 || ^5.1",
"symfony/routing": "^4.4",
"symfony/routing": "^4.4 || ^5.1",
"symfony/security-acl": "^3.1",
"symfony/security-bundle": "^4.4",
"symfony/security-core": "^4.4",
"symfony/security-csrf": "^4.4",
"symfony/security-bundle": "^4.4 || ^5.1",
"symfony/security-core": "^4.4 || ^5.1",
"symfony/security-csrf": "^4.4 || ^5.1",
"symfony/string": "^5.1",
"symfony/translation": "^4.4",
"symfony/twig-bridge": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/translation": "^4.4 || ^5.1",
"symfony/twig-bridge": "^4.4 || ^5.1",
"symfony/twig-bundle": "^4.4 || ^5.1",
"symfony/validator": "^4.4 || ^5.1",
"twig/string-extra": "^3.0",
"twig/twig": "^2.12.1 || ^3.0"
Expand All @@ -75,7 +75,7 @@
"phpstan/phpstan": "^0.12.29",
"psalm/plugin-symfony": "^1.4",
"psr/event-dispatcher": "^1.0",
"sonata-project/intl-bundle": "^2.4",
"sonata-project/intl-bundle": "^2.9",
"symfony/browser-kit": "^4.4 || ^5.1",
"symfony/css-selector": "^4.4 || ^5.1",
"symfony/filesystem": "^4.4 || ^5.1",
Expand Down
19 changes: 16 additions & 3 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface as RoutingUrlGeneratorInterface;
use Symfony\Component\Security\Acl\Model\DomainObjectInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\TranslatorInterface as DeprecatedTranslatorInterface;
use Symfony\Component\Validator\Mapping\GenericMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
Expand Down Expand Up @@ -311,7 +312,7 @@ abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, A
*
* NEXT_MAJOR: remove this property
*
* @var \Symfony\Component\Translation\TranslatorInterface
* @var DeprecatedTranslatorInterface|TranslatorInterface
*
* @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0
*/
Expand Down Expand Up @@ -2475,8 +2476,10 @@ public function getTranslationDomain()
* NEXT_MAJOR: remove this method
*
* @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0
*
* @param DeprecatedTranslatorInterface|TranslatorInterface $translator
*/
public function setTranslator(TranslatorInterface $translator)
public function setTranslator($translator)
{
$args = \func_get_args();
if (isset($args[1]) && $args[1]) {
Expand All @@ -2486,6 +2489,16 @@ public function setTranslator(TranslatorInterface $translator)
), E_USER_DEPRECATED);
}

if (!$translator instanceof DeprecatedTranslatorInterface && !$translator instanceof TranslatorInterface) {
throw new \TypeError(sprintf(
'Argument 1 passed to "%s()" must be an instance of "%s" or "%s", %s given.',
__METHOD__,
DeprecatedTranslatorInterface::class,
TranslatorInterface::class,
\is_object($translator) ? 'instance of '.\get_class($translator) : \gettype($translator)
));
}

$this->translator = $translator;
}

Expand Down
1 change: 0 additions & 1 deletion src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Sonata\AdminBundle\Templating\TemplateRegistryInterface;
use Sonata\AdminBundle\Util\AdminObjectAclData;
use Sonata\AdminBundle\Util\AdminObjectAclManipulator;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down
Loading