Skip to content

[FrameworkBundle] Add missing autowiring aliases for common interfaces #21517

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

Merged
merged 1 commit into from
Feb 3, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@

<service id="cache.global_clearer" parent="cache.default_clearer" />
<service id="cache.app_clearer" alias="cache.default_clearer" />
<service id="Psr\Cache\CacheItemPoolInterface" alias="cache.app" public="false" />

</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
Expand Down Expand Up @@ -63,6 +66,30 @@ public function testEventDispatcherAutowiring()
$this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled');
}

public function testAccessDecisionManagerAutowiring()
{
static::bootKernel(array('debug' => false));
$container = static::$kernel->getContainer();

$autowiredServices = $container->get('test.autowiring_types.autowired_services');
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');

static::bootKernel(array('debug' => true));
$container = static::$kernel->getContainer();

$autowiredServices = $container->get('test.autowiring_types.autowired_services');
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
}

public function testCacheAutowiring()
{
static::bootKernel();
$container = static::$kernel->getContainer();

$autowiredServices = $container->get('test.autowiring_types.autowired_services');
$this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool());
}

protected static function createKernel(array $options = array())
{
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;

use Doctrine\Common\Annotations\Reader;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

Expand All @@ -22,13 +24,17 @@ class AutowiredServices
private $frameworkBundleEngine;
private $engine;
private $dispatcher;
private $accessDecisionManager;
private $cachePool;

public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher)
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, AccessDecisionManagerInterface $accessDecisionManager, CacheItemPoolInterface $cachePool)
{
$this->annotationReader = $annotationReader;
$this->frameworkBundleEngine = $frameworkBundleEngine;
$this->engine = $engine;
$this->dispatcher = $dispatcher;
$this->accessDecisionManager = $accessDecisionManager;
$this->cachePool = $cachePool;
}

public function getAnnotationReader()
Expand All @@ -50,4 +56,14 @@ public function getDispatcher()
{
return $this->dispatcher;
}

public function getAccessDecisionManager()
{
return $this->accessDecisionManager;
}

public function getCachePool()
{
return $this->cachePool;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;

return array(
new FrameworkBundle(),
new SecurityBundle(),
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test located in the FrameworkBundle and not in the SecurityBundle?

Copy link
Member Author

Choose a reason for hiding this comment

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

@xabbuh I thought about that but it was simpler to integrate a new test here than duplicating the whole test case on the SecurityBundle. Does it hurt?

Copy link
Member

Choose a reason for hiding this comment

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

I missed that, but indeed, that's not good. @chalasr Can you move it to SecurityBundle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I'll do

Copy link
Member Author

Choose a reason for hiding this comment

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

See #21522

new TestBundle(),
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ services:
framework:
templating:
engines: ['php']
security:
providers:
dummy:
memory: ~
firewalls:
dummy:
security: false
5 changes: 3 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"symfony/css-selector": "~2.8|~3.0",
"symfony/dom-crawler": "~2.8|~3.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/security": "~2.8|~3.0",
"symfony/security": "~3.3",
"symfony/form": "~2.8.16|~3.1.9|^3.2.2",
"symfony/expression-language": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0",
Expand All @@ -55,7 +55,8 @@
"doctrine/annotations": "~1.0",
"phpdocumentor/reflection-docblock": "^3.0",
"twig/twig": "~1.26|~2.0",
"sensio/framework-extra-bundle": "^3.0.2"
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/security-bundle": "~3.3"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<service id="security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\AccessDecisionManager" public="false">
<argument type="collection" />
</service>
<service id="Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface" alias="security.access.decision_manager" public="false" />

<service id="security.role_hierarchy" class="Symfony\Component\Security\Core\Role\RoleHierarchy" public="false">
<argument>%security.role_hierarchy.roles%</argument>
Expand Down