Skip to content

Commit 53fde2e

Browse files
authored
Merge pull request #23 from OpenClassrooms/improve_sf6_compatibility
Improve sf6 compatibility
2 parents 4ffc1da + 3bc0b85 commit 53fde2e

File tree

6 files changed

+6
-64
lines changed

6 files changed

+6
-64
lines changed

.coveralls.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<call method="setReader">
88
<argument type="service" id="annotation_reader"/>
99
</call>
10+
<argument type="service" id="security.authorization_checker"/>
1011
</service>
1112
<service id="openclassrooms.use_case.security_factory" class="OpenClassrooms\Bundle\UseCaseBundle\Services\Security\Impl\SecurityFactoryImpl" public="true"/>
1213
<service id="openclassrooms.use_case.transaction_factory" class="OpenClassrooms\Bundle\UseCaseBundle\Services\Transaction\Impl\TransactionFactoryImpl" public="true"/>

Services/Proxy/Impl/UseCaseProxyFactoryImpl.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class UseCaseProxyFactoryImpl implements UseCaseProxyFactory
4848
*/
4949
private $builder;
5050

51-
public function __construct()
51+
public function __construct(
52+
private readonly AuthorizationCheckerInterface $authorizationChecker
53+
)
5254
{
5355
$this->builder = new UseCaseProxyBuilderImpl();
5456
}
@@ -114,15 +116,7 @@ private function buildSecurity(array $tagParameters)
114116
if (isset($tagParameters['security'])) {
115117
$security = $this->container->get($tagParameters['security']);
116118
} else {
117-
$defaultSecurityContextId = $this->container->getParameter(
118-
'openclassrooms.use_case.default_authorization_checker'
119-
);
120-
if (!$this->container->has($defaultSecurityContextId)) {
121-
throw new SecurityIsNotDefinedException('Default security context: \''.$defaultSecurityContextId.'\' is not defined.');
122-
}
123-
$security = $this->container->get(
124-
$this->container->getParameter('openclassrooms.use_case.default_authorization_checker')
125-
);
119+
$security = $this->authorizationChecker;
126120
}
127121
if ($security instanceof AuthorizationCheckerInterface) {
128122
/** @var SecurityFactory $securityFactory */

Tests/DependencyInjection/Fixtures/Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<parameter key="openclassrooms.tests.use_cases.event_use_case_stub.class">OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub</parameter>
1717
</parameters>
1818
<services>
19+
<service id="security.authorization_checker" class="OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util\AuthorizationCheckerSpy"/>
1920
<service id="annotation_reader" class="Doctrine\Common\Annotations\AnnotationReader"/>
2021
<service id="openclassrooms.tests.util.security_stub" class="%openclassrooms.tests.util.security_stub.class%" public="true"/>
2122
<service id="openclassrooms.tests.util.authorization_checker_stub" class="%openclassrooms.tests.util.authorization_checker_stub.class%" public="true"/>

Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,6 @@
1111
*/
1212
class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase
1313
{
14-
/**
15-
* @test
16-
*/
17-
public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException()
18-
{
19-
$this->expectException(SecurityIsNotDefinedException::class);
20-
21-
$this->configLoader->load('SecurityConfiguration.php');
22-
$this->container->compile();
23-
24-
$this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub');
25-
}
26-
27-
/**
28-
* @test
29-
*/
30-
public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException()
31-
{
32-
$this->expectException(SecurityIsNotDefinedException::class);
33-
34-
$this->configLoader->load('DefaultConfiguration.php');
35-
$this->container->compile();
36-
37-
$this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub');
38-
}
39-
4014
/**
4115
* @test
4216
*/

0 commit comments

Comments
 (0)