Skip to content

Commit

Permalink
Add Symfony 5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Aug 10, 2020
1 parent 93259c6 commit 1ec04ff
Show file tree
Hide file tree
Showing 23 changed files with 628 additions and 82 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ matrix:
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.3'
env: SYMFONY=4.4.*
- php: '7.3'
env: SYMFONY=5.1.*
- php: '7.3'
env: SYMFONY='dev-master as 4.4.x-dev'
- php: '7.3'
Expand Down
52 changes: 26 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
"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",
"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",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/options-resolver": "^4.4",
"symfony/property-access": "^4.4",
"symfony/routing": "^4.4",
"symfony/expression-language": "^4.4 || ^5.1",
"symfony/form": "^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-foundation": "^4.4 || ^5.1",
"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 || ^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/validator": "^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 @@ -71,13 +71,13 @@
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"phpstan/phpstan": "^0.12.29",
"psr/event-dispatcher": "^1.0",
"sonata-project/intl-bundle": "^2.4",
"symfony/browser-kit": "^4.4",
"symfony/css-selector": "^4.4",
"symfony/filesystem": "^4.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",
"symfony/maker-bundle": "^1.17",
"symfony/phpunit-bridge": "^5.1.1",
"symfony/yaml": "^4.4"
"symfony/yaml": "^4.4 || ^5.1"
},
"suggest": {
"jms/translation-bundle": "Extract message keys from Admins",
Expand Down
19 changes: 16 additions & 3 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,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 <[email protected]>
Expand Down Expand Up @@ -309,7 +310,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 @@ -2455,8 +2456,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 @@ -2466,6 +2469,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

0 comments on commit 1ec04ff

Please sign in to comment.