Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3a2141

Browse files
committed
[FrameworkBundle] Add more autowiring aliases
1 parent 2e13d4e commit c3a2141

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

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

109110
</services>
110111
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

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

69+
public function testAccessDecisionManagerAutowiring()
70+
{
71+
static::bootKernel(array('debug' => false));
72+
$container = static::$kernel->getContainer();
73+
74+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
75+
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');
76+
77+
static::bootKernel(array('debug' => true));
78+
$container = static::$kernel->getContainer();
79+
80+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
81+
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
82+
}
83+
84+
public function testCacheAutowiring()
85+
{
86+
static::bootKernel();
87+
$container = static::$kernel->getContainer();
88+
89+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
90+
$this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool());
91+
}
92+
6693
protected static function createKernel(array $options = array())
6794
{
6895
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
1313

1414
use Doctrine\Common\Annotations\Reader;
15+
use Psr\Cache\CacheItemPoolInterface;
1516
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
17+
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
1618
use Symfony\Component\Templating\EngineInterface;
1719
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1820

@@ -22,13 +24,17 @@ class AutowiredServices
2224
private $frameworkBundleEngine;
2325
private $engine;
2426
private $dispatcher;
27+
private $accessDecisionManager;
28+
private $cachePool;
2529

26-
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher)
30+
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, AccessDecisionManagerInterface $accessDecisionManager, CacheItemPoolInterface $cachePool)
2731
{
2832
$this->annotationReader = $annotationReader;
2933
$this->frameworkBundleEngine = $frameworkBundleEngine;
3034
$this->engine = $engine;
3135
$this->dispatcher = $dispatcher;
36+
$this->accessDecisionManager = $accessDecisionManager;
37+
$this->cachePool = $cachePool;
3238
}
3339

3440
public function getAnnotationReader()
@@ -50,4 +56,14 @@ public function getDispatcher()
5056
{
5157
return $this->dispatcher;
5258
}
59+
60+
public function getAccessDecisionManager()
61+
{
62+
return $this->accessDecisionManager;
63+
}
64+
65+
public function getCachePool()
66+
{
67+
return $this->cachePool;
68+
}
5369
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
1313
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
14+
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1415

1516
return array(
1617
new FrameworkBundle(),
18+
new SecurityBundle(),
1719
new TestBundle(),
1820
);

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ services:
88
framework:
99
templating:
1010
engines: ['php']
11+
security:
12+
providers:
13+
dummy:
14+
memory: ~
15+
firewalls:
16+
dummy:
17+
security: false

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"symfony/css-selector": "~2.8|~3.0",
4141
"symfony/dom-crawler": "~2.8|~3.0",
4242
"symfony/polyfill-intl-icu": "~1.0",
43-
"symfony/security": "~2.8|~3.0",
43+
"symfony/security": "~3.3",
4444
"symfony/form": "~2.8.16|~3.1.9|^3.2.2",
4545
"symfony/expression-language": "~2.8|~3.0",
4646
"symfony/process": "~2.8|~3.0",
@@ -55,7 +55,8 @@
5555
"doctrine/annotations": "~1.0",
5656
"phpdocumentor/reflection-docblock": "^3.0",
5757
"twig/twig": "~1.26|~2.0",
58-
"sensio/framework-extra-bundle": "^3.0.2"
58+
"sensio/framework-extra-bundle": "^3.0.2",
59+
"symfony/security-bundle": "~3.3"
5960
},
6061
"conflict": {
6162
"phpdocumentor/reflection-docblock": "<3.0",

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<service id="security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\AccessDecisionManager" public="false">
6868
<argument type="collection" />
6969
</service>
70+
<service id="Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface" alias="security.access.decision_manager" public="false" />
7071

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

0 commit comments

Comments
 (0)