diff --git a/Annotation/Service.php b/Annotation/Service.php index 8b8b0de..abb01e0 100644 --- a/Annotation/Service.php +++ b/Annotation/Service.php @@ -33,9 +33,6 @@ final class Service /** @var bool */ public $public; - /** @var string */ - public $scope; - /** @var bool */ public $shared; diff --git a/HttpKernel/ControllerResolver.php b/HttpKernel/ControllerResolver.php index 71e7366..67d4eb0 100644 --- a/HttpKernel/ControllerResolver.php +++ b/HttpKernel/ControllerResolver.php @@ -28,7 +28,7 @@ use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass; -use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; +use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -152,7 +152,7 @@ private function prepareContainer($cache, $containerFilename, $metadata, $classN $config = $container->getCompilerPassConfig(); $config->setOptimizationPasses(array()); $config->setRemovingPasses(array()); - $config->addPass(new ResolveDefinitionTemplatesPass()); + $config->addPass(new ResolveChildDefinitionsPass()); $config->addPass(new PointcutMatchingPass($this->container->get('jms_aop.pointcut_container')->getPointcuts())); $config->addPass(new InlineServiceDefinitionsPass()); $container->compile(); diff --git a/Metadata/Driver/AnnotationDriver.php b/Metadata/Driver/AnnotationDriver.php index c8ecd9a..3a448cc 100644 --- a/Metadata/Driver/AnnotationDriver.php +++ b/Metadata/Driver/AnnotationDriver.php @@ -233,7 +233,6 @@ private function parseServiceAnnotation(Service $annot, ClassMetadata $metadata, $metadata->parent = $annot->parent; $metadata->public = $annot->public; - $metadata->scope = $annot->scope; $metadata->shared = $annot->shared; $metadata->abstract = $annot->abstract; $metadata->decorates = $annot->decorates; diff --git a/Metadata/MetadataConverter.php b/Metadata/MetadataConverter.php index d8f5269..3cfed28 100644 --- a/Metadata/MetadataConverter.php +++ b/Metadata/MetadataConverter.php @@ -20,6 +20,7 @@ use JMS\DiExtraBundle\Exception\InvalidAnnotationException; use Metadata\ClassHierarchyMetadata; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Reference; @@ -75,15 +76,16 @@ private function convertMetadata(ClassMetadata $classMetadata, ClassMetadata $pr if (null === $previous && null === $classMetadata->parent) { $definition = new Definition(); } else { - $definition = new DefinitionDecorator( + $definition = new ChildDefinition( $classMetadata->parent ?: $previous->id ); } - $definition->setClass($classMetadata->name); - if (null !== $classMetadata->scope) { - $definition->setScope($classMetadata->scope); - } + $definition + ->setClass($classMetadata->name) + ->setPublic(true) + ->setPrivate(false) + ; if (null !== $classMetadata->shared) { $definition->setShared($classMetadata->shared); } diff --git a/Resources/config/services.xml b/Resources/config/services.xml index b321e96..5830268 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -35,7 +35,7 @@ jms_di_extra.metadata_driver - + diff --git a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php b/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php index 1fd021d..b9517c4 100644 --- a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php +++ b/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php @@ -22,6 +22,7 @@ use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass; use JMS\DiExtraBundle\DependencyInjection\JMSDiExtraExtension; use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Reference; @@ -83,7 +84,8 @@ public function testConstructorWithInheritance() $this->assertTrue($container->hasDefinition('concrete_class')); $this->assertTrue($container->hasDefinition('abstract_class')); - $def = new DefinitionDecorator('abstract_class'); + $def = new ChildDefinition('abstract_class'); + $def->setPublic(true); $def->setClass('JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\ConcreteClass'); $def->addArgument(new Reference('foo')); $def->addArgument(new Reference('bar')); diff --git a/Tests/Fixture/NullLogger.php b/Tests/Fixture/NullLogger.php index f73d158..2106fda 100644 --- a/Tests/Fixture/NullLogger.php +++ b/Tests/Fixture/NullLogger.php @@ -19,14 +19,7 @@ namespace JMS\DiExtraBundle\Tests\Fixture; use Psr\Log\NullLogger as PsrNullLogger; -use Symfony\Component\HttpKernel\Log\NullLogger as SfNullLogger; -if (class_exists('JMS\SecurityExtraBundle\DependencyInjection\Compiler\SecurityCompatibilityPass')) { - class NullLogger extends PsrNullLogger - { - } -} else { - class NullLogger extends SfNullLogger - { - } +class NullLogger extends PsrNullLogger +{ } diff --git a/Tests/Functional/AppKernel.php b/Tests/Functional/AppKernel.php index e9e1dd8..b38529f 100644 --- a/Tests/Functional/AppKernel.php +++ b/Tests/Functional/AppKernel.php @@ -75,11 +75,8 @@ public function registerBundles() new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new \JMS\AopBundle\JMSAopBundle(), - version_compare(PHP_VERSION, '7.0.0', '<')? - new \JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\JMSDiExtraTestBundle(): new \JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\JMSDiExtraTestBundle(), new \JMS\DiExtraBundle\JMSDiExtraBundle(), - new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), ); } diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php index a359847..5fca4b4 100644 --- a/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php @@ -18,8 +18,8 @@ namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; -use JMS\SecurityExtraBundle\Annotation\Secure; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; /** * Secured Controller. @@ -30,7 +30,7 @@ class AnotherSecuredController { /** * @Route("/secure-action") - * @Secure("ROLE_FOO") + * @Security("hash_role('ROLE_FOO')") */ public function secureAction() { diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php index 0498951..01760e9 100644 --- a/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php @@ -19,8 +19,8 @@ namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; use JMS\DiExtraBundle\Annotation as DI; -use JMS\SecurityExtraBundle\Annotation\Secure; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; /** * @author Johannes M. Schmitt @@ -29,7 +29,7 @@ class SecuredController { /** * @Route("/lookup-method-and-aop") - * @Secure("ROLE_FOO") + * @Security("has_role('ROLE_FOO')") */ public function secureAction() { diff --git a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php b/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php index 97ed1a1..d4d3ada 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php +++ b/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php @@ -18,8 +18,8 @@ namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller; -use JMS\SecurityExtraBundle\Annotation\Secure; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; /** * Secured Controller. @@ -30,7 +30,7 @@ class AnotherSecuredController { /** * @Route("/secure-action") - * @Secure("ROLE_FOO") + * @Security("has_role('ROLE_FOO')") */ public function secureAction() { diff --git a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php b/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php index d895e72..bfdd4b3 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php +++ b/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php @@ -19,8 +19,8 @@ namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller; use JMS\DiExtraBundle\Annotation as DI; -use JMS\SecurityExtraBundle\Annotation\Secure; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; /** * @author Johannes M. Schmitt @@ -29,7 +29,7 @@ class SecuredController { /** * @Route("/lookup-method-and-aop") - * @Secure("ROLE_FOO") + * @Security("has_role('ROLE_FOO')") */ public function secureAction() { diff --git a/Tests/Functional/config/default.yml b/Tests/Functional/config/default.yml index 8daa730..8ba7b1d 100644 --- a/Tests/Functional/config/default.yml +++ b/Tests/Functional/config/default.yml @@ -6,10 +6,14 @@ imports: jms_di_extra: locations: bundles: [JMSDiExtraTestBundle] - + services: - foo: { class: stdClass } - bar: { class: stdClass } + foo: + class: stdClass + public: true + bar: + class: stdClass + public: true controller.hello: class: JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller\ServiceController arguments: [ "@router" ] diff --git a/composer.json b/composer.json index beeb94a..90c2ee0 100644 --- a/composer.json +++ b/composer.json @@ -12,34 +12,34 @@ } ], "require": { - "php": "~5.3|~7.0", - "symfony/framework-bundle": "~2.3|~3.0", - "symfony/routing": "~2.3|~3.0", - "symfony/http-kernel": "^2.3.24|~3.0", - "symfony/dependency-injection": "~2.3|~3.0", - "symfony/process": "~2.3|~3.0", - "symfony/finder": "~2.3|~3.0", + "php": "^7.1.3", + "symfony/framework-bundle": "~4.0", + "symfony/routing": "~4.0", + "symfony/http-kernel": "~4.0", + "symfony/dependency-injection": "~4.0", + "symfony/process": "~4.0", + "symfony/finder": "~4.0", "jms/aop-bundle": "~1.1", - "jms/metadata": "~1.0" + "jms/metadata": "~1.0", + "doctrine/annotations": "~1.0" }, "require-dev": { - "symfony/validator": "~2.3|~3.0", - "symfony/form": "~2.3|~3.0", - "symfony/class-loader": "~2.3|~3.0", - "symfony/yaml": "~2.3|~3.0", - "symfony/browser-kit": "~2.3|~3.0", - "symfony/security-bundle": "~2.3|^3.0", - "symfony/expression-language": "~2.6|~3.0", - "symfony/twig-bundle": "~2.3|~3.0", - "sensio/framework-extra-bundle": "~2.0|~3.0", - "jms/security-extra-bundle": "~1.0", + "symfony/validator": "~4.0", + "symfony/form": "~4.0", + "symfony/class-loader": "~4.0", + "symfony/yaml": "~4.0", + "symfony/browser-kit": "~4.0", + "symfony/security-bundle": "~4.0", + "symfony/expression-language": "~4.0", + "symfony/twig-bundle": "~4.0", + "sensio/framework-extra-bundle": "~4.0", "doctrine/doctrine-bundle": "~1.5", "doctrine/orm": "~2.3", "phpcollection/phpcollection": ">=0.2,<0.3-dev", - "symfony/phpunit-bridge": "~3.3", + "symfony/phpunit-bridge": "~4.0", "phpunit/phpunit": "^4.8.35|^5.4.4|^6.0.0", - "symfony/asset": "~2.3|^3.3", - "symfony/templating": "~2.3|^3.3" + "symfony/asset": "~4.0", + "symfony/templating": "~4.0" }, "autoload": { "psr-4": { "JMS\\DiExtraBundle\\": "" }