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

Symfony 4.0 patch #309

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions Annotation/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ final class Service
/** @var bool */
public $public;

/** @var string */
public $scope;

/** @var bool */
public $shared;

Expand Down
4 changes: 2 additions & 2 deletions HttpKernel/ControllerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions Metadata/MetadataConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<argument type="service" id="service_container" />
<argument>jms_di_extra.metadata_driver</argument>
</service>
<service id="jms_di_extra.metadata_driver" alias="jms_di_extra.metadata.driver.configured_controller_injections" />
<service id="jms_di_extra.metadata_driver" alias="jms_di_extra.metadata.driver.configured_controller_injections" public="true"/>

<!-- Metadata Factory -->
<service id="jms_di_extra.metadata.cache.file_cache" class="%jms_di_extra.metadata.cache.file_cache.class%" public="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
Expand Down
11 changes: 2 additions & 9 deletions Tests/Fixture/NullLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
3 changes: 0 additions & 3 deletions Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -30,7 +30,7 @@ class AnotherSecuredController
{
/**
* @Route("/secure-action")
* @Secure("ROLE_FOO")
* @Security("hash_role('ROLE_FOO')")
*/
public function secureAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -29,7 +29,7 @@ class SecuredController
{
/**
* @Route("/lookup-method-and-aop")
* @Secure("ROLE_FOO")
* @Security("has_role('ROLE_FOO')")
*/
public function secureAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -30,7 +30,7 @@ class AnotherSecuredController
{
/**
* @Route("/secure-action")
* @Secure("ROLE_FOO")
* @Security("has_role('ROLE_FOO')")
*/
public function secureAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -29,7 +29,7 @@ class SecuredController
{
/**
* @Route("/lookup-method-and-aop")
* @Secure("ROLE_FOO")
* @Security("has_role('ROLE_FOO')")
*/
public function secureAction()
{
Expand Down
10 changes: 7 additions & 3 deletions Tests/Functional/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
42 changes: 21 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is quite restrictive, we should keep supporting 3.x for now imo. Could you instead use 4.0 classes only if they're available?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe you can create a new branch for 4.x, and mark release version as 2.0.x.
Supporting 3.x and 4.x both needs some workarounds.

"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\\": "" }
Expand Down