Permalink
Browse files

feature #21517 [FrameworkBundle] Add missing autowiring aliases for c…

…ommon interfaces (chalasr)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Add missing autowiring aliases for common interfaces

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | n/a

Commits
-------

c3a2141 [FrameworkBundle] Add more autowiring aliases
  • Loading branch information...
2 parents 23ba912 + c3a2141 commit da2710e4008ab81a39bc7344eae1b074d054e3ee @fabpot fabpot committed Feb 3, 2017
@@ -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>
@@ -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;
@@ -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);
@@ -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;
@@ -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()
@@ -50,4 +56,14 @@ public function getDispatcher()
{
return $this->dispatcher;
}
+
+ public function getAccessDecisionManager()
+ {
+ return $this->accessDecisionManager;
+ }
+
+ public function getCachePool()
+ {
+ return $this->cachePool;
+ }
}
@@ -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(),
new TestBundle(),
);
@@ -8,3 +8,10 @@ services:
framework:
templating:
engines: ['php']
+security:
+ providers:
+ dummy:
+ memory: ~
+ firewalls:
+ dummy:
+ security: false
@@ -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",
@@ -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",
@@ -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>

0 comments on commit da2710e

Please sign in to comment.