Skip to content

Commit cd6eadf

Browse files
authored
Merge pull request #24 from lightSAML/maintenance
Remove service locator to support Symfony 4
2 parents 9b64b2e + fd418cd commit cd6eadf

33 files changed

+688
-506
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@
3838
/composer.lock
3939
/*.phar
4040
/*.cache
41+
42+
tests/LightSaml/SymfonyBridgeBundle/Tests/Functional/cache/*

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
},
2121
"require": {
2222
"php": ">=5.5.1",
23-
"symfony/framework-bundle": "~2.3|~3.0|~4.0",
24-
"symfony/dependency-injection": "~2.3|~3.0|~4.0",
25-
"symfony/yaml": "~2.3|~3.0|~4.0",
23+
"symfony/framework-bundle": "~2.7|~3.0|~4.0",
24+
"symfony/dependency-injection": "~2.7|~3.0|~4.0",
25+
"symfony/yaml": "~2.7|~3.0|~4.0",
2626
"lightsaml/lightsaml": "~1.1"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "~4.5",
30-
"satooshi/php-coveralls": "~0.6"
29+
"symfony/browser-kit": "~2.7|~3.0|~4.0",
30+
"symfony/finder": "~2.7|~3.0|~4.0",
31+
"symfony/filesystem": "~2.7|~3.0|~4.0",
32+
"symfony/routing": "~2.7|~3.0|~4.0",
33+
"phpunit/phpunit": "^5.7",
34+
"php-coveralls/php-coveralls": "~2.0"
3135
},
3236
"suggest": {
3337
"lightsaml/lightsamp-idp": "If you will be using IDP LightSAML services"

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/AbstractContainer.php

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

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/BuildContainer.php

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,78 +20,109 @@
2020
use LightSaml\Build\Container\StoreContainerInterface;
2121
use LightSaml\Build\Container\SystemContainerInterface;
2222

23-
class BuildContainer extends AbstractContainer implements BuildContainerInterface
23+
class BuildContainer implements BuildContainerInterface
2424
{
25-
/** @var AbstractContainer[] */
26-
private $containers = [];
25+
/** @var SystemContainerInterface */
26+
private $systemsystemContainer;
27+
28+
/** @var PartyContainerInterface */
29+
private $partypartyContainer;
30+
31+
/** @var StoreContainerInterface */
32+
private $storeContainer;
33+
34+
/** @var OwnContainerInterface */
35+
private $ownContainer;
36+
37+
/** @var ProviderContainerInterface */
38+
private $providerContainer;
39+
40+
/** @var ServiceContainerInterface */
41+
private $serviceContainer;
42+
43+
/** @var CredentialContainerInterface */
44+
private $credentialContainer;
45+
46+
/**
47+
* @param SystemContainerInterface $systemContainer
48+
* @param PartyContainerInterface $partyContainer
49+
* @param StoreContainerInterface $storeContainer
50+
* @param ProviderContainerInterface $providerContainer
51+
* @param CredentialContainerInterface $credentialContainer
52+
* @param ServiceContainerInterface $serviceContainer
53+
* @param OwnContainerInterface $ownContainer
54+
*/
55+
public function __construct(
56+
SystemContainerInterface $systemContainer,
57+
PartyContainerInterface $partyContainer,
58+
StoreContainerInterface $storeContainer,
59+
ProviderContainerInterface $providerContainer,
60+
CredentialContainerInterface $credentialContainer,
61+
ServiceContainerInterface $serviceContainer,
62+
OwnContainerInterface $ownContainer
63+
) {
64+
$this->systemsystemContainer = $systemContainer;
65+
$this->partypartyContainer = $partyContainer;
66+
$this->storeContainer = $storeContainer;
67+
$this->providerContainer = $providerContainer;
68+
$this->credentialContainer = $credentialContainer;
69+
$this->serviceContainer = $serviceContainer;
70+
$this->ownContainer = $ownContainer;
71+
}
2772

2873
/**
2974
* @return SystemContainerInterface
3075
*/
3176
public function getSystemContainer()
3277
{
33-
return $this->getContainer(SystemContainer::class);
78+
return $this->systemsystemContainer;
3479
}
3580

3681
/**
3782
* @return PartyContainerInterface
3883
*/
3984
public function getPartyContainer()
4085
{
41-
return $this->getContainer(PartyContainer::class);
86+
return $this->partypartyContainer;
4287
}
4388

4489
/**
4590
* @return StoreContainerInterface
4691
*/
4792
public function getStoreContainer()
4893
{
49-
return $this->getContainer(StoreContainer::class);
94+
return $this->storeContainer;
5095
}
5196

5297
/**
5398
* @return ProviderContainerInterface
5499
*/
55100
public function getProviderContainer()
56101
{
57-
return $this->getContainer(ProviderContainer::class);
102+
return $this->providerContainer;
58103
}
59104

60105
/**
61106
* @return CredentialContainerInterface
62107
*/
63108
public function getCredentialContainer()
64109
{
65-
return $this->getContainer(CredentialContainer::class);
110+
return $this->credentialContainer;
66111
}
67112

68113
/**
69114
* @return ServiceContainerInterface
70115
*/
71116
public function getServiceContainer()
72117
{
73-
return $this->getContainer(ServiceContainer::class);
118+
return $this->serviceContainer;
74119
}
75120

76121
/**
77122
* @return OwnContainerInterface
78123
*/
79124
public function getOwnContainer()
80125
{
81-
return $this->getContainer(OwnContainer::class);
82-
}
83-
84-
/**
85-
* @param string $class
86-
*
87-
* @return AbstractContainer
88-
*/
89-
private function getContainer($class)
90-
{
91-
if (false === isset($this->containers[$class])) {
92-
$this->containers[$class] = new $class($this->container);
93-
}
94-
95-
return $this->containers[$class];
126+
return $this->ownContainer;
96127
}
97128
}

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/CredentialContainer.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@
1414
use LightSaml\Build\Container\CredentialContainerInterface;
1515
use LightSaml\Store\Credential\CredentialStoreInterface;
1616

17-
class CredentialContainer extends AbstractContainer implements CredentialContainerInterface
17+
class CredentialContainer implements CredentialContainerInterface
1818
{
19+
/** @var CredentialStoreInterface */
20+
private $credentialStore;
21+
22+
/**
23+
* @param CredentialStoreInterface $credentialStore
24+
*/
25+
public function __construct(CredentialStoreInterface $credentialStore)
26+
{
27+
$this->credentialStore = $credentialStore;
28+
}
29+
1930
/**
2031
* @return CredentialStoreInterface
2132
*/
2233
public function getCredentialStore()
2334
{
24-
return $this->container->get('lightsaml.credential.credential_store');
35+
return $this->credentialStore;
2536
}
2637
}

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/OwnContainer.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,49 @@
1414
use LightSaml\Build\Container\OwnContainerInterface;
1515
use LightSaml\Credential\CredentialInterface;
1616
use LightSaml\Provider\EntityDescriptor\EntityDescriptorProviderInterface;
17+
use LightSaml\Store\Credential\CredentialStoreInterface;
1718

18-
class OwnContainer extends AbstractContainer implements OwnContainerInterface
19+
class OwnContainer implements OwnContainerInterface
1920
{
21+
/** @var EntityDescriptorProviderInterface */
22+
private $entityDescriptorProvider;
23+
24+
/** @var CredentialStoreInterface */
25+
private $credentialStore;
26+
27+
/** @var string */
28+
private $entityId;
29+
30+
/**
31+
* @param EntityDescriptorProviderInterface $entityDescriptorProvider
32+
* @param CredentialStoreInterface $credentialStore
33+
* @param string $entityId
34+
*/
35+
public function __construct(
36+
EntityDescriptorProviderInterface $entityDescriptorProvider,
37+
CredentialStoreInterface $credentialStore,
38+
$entityId
39+
) {
40+
$this->entityDescriptorProvider = $entityDescriptorProvider;
41+
$this->credentialStore = $credentialStore;
42+
$this->entityId = $entityId;
43+
}
44+
2045
/**
2146
* @return EntityDescriptorProviderInterface
2247
*/
2348
public function getOwnEntityDescriptorProvider()
2449
{
25-
return $this->container->get('lightsaml.own.entity_descriptor_provider');
50+
return $this->entityDescriptorProvider;
2651
}
2752

2853
/**
2954
* @return CredentialInterface[]
3055
*/
3156
public function getOwnCredentials()
3257
{
33-
return $this->container->get('lightsaml.own.credential_store')->getByEntityId(
34-
$this->container->getParameter('lightsaml.own.entity_id')
58+
return $this->credentialStore->getByEntityId(
59+
$this->entityId
3560
);
3661
}
3762
}

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/PartyContainer.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,53 @@
1515
use LightSaml\Store\EntityDescriptor\EntityDescriptorStoreInterface;
1616
use LightSaml\Store\TrustOptions\TrustOptionsStoreInterface;
1717

18-
class PartyContainer extends AbstractContainer implements PartyContainerInterface
18+
class PartyContainer implements PartyContainerInterface
1919
{
20+
/** @var EntityDescriptorStoreInterface */
21+
private $idpEntityDescriptorStore;
22+
23+
/** @var EntityDescriptorStoreInterface */
24+
private $spEntityDescriptorStore;
25+
26+
/** @var TrustOptionsStoreInterface */
27+
private $trustOptionsStore;
28+
29+
/**
30+
* @param EntityDescriptorStoreInterface $idpEntityDescriptorStore
31+
* @param EntityDescriptorStoreInterface $spEntityDescriptorStore
32+
* @param TrustOptionsStoreInterface $trustOptionsStore
33+
*/
34+
public function __construct(
35+
EntityDescriptorStoreInterface $idpEntityDescriptorStore,
36+
EntityDescriptorStoreInterface $spEntityDescriptorStore,
37+
TrustOptionsStoreInterface $trustOptionsStore
38+
) {
39+
$this->idpEntityDescriptorStore = $idpEntityDescriptorStore;
40+
$this->spEntityDescriptorStore = $spEntityDescriptorStore;
41+
$this->trustOptionsStore = $trustOptionsStore;
42+
}
43+
2044
/**
2145
* @return EntityDescriptorStoreInterface
2246
*/
2347
public function getIdpEntityDescriptorStore()
2448
{
25-
return $this->container->get('lightsaml.party.idp_entity_descriptor_store');
49+
return $this->idpEntityDescriptorStore;
2650
}
2751

2852
/**
2953
* @return EntityDescriptorStoreInterface
3054
*/
3155
public function getSpEntityDescriptorStore()
3256
{
33-
return $this->container->get('lightsaml.party.sp_entity_descriptor_store');
57+
return $this->spEntityDescriptorStore;
3458
}
3559

3660
/**
3761
* @return TrustOptionsStoreInterface
3862
*/
3963
public function getTrustOptionsStore()
4064
{
41-
return $this->container->get('lightsaml.party.trust_options_store');
65+
return $this->trustOptionsStore;
4266
}
4367
}

src/LightSaml/SymfonyBridgeBundle/Bridge/Container/ProviderContainer.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,53 @@
1616
use LightSaml\Provider\NameID\NameIdProviderInterface;
1717
use LightSaml\Provider\Session\SessionInfoProviderInterface;
1818

19-
class ProviderContainer extends AbstractContainer implements ProviderContainerInterface
19+
class ProviderContainer implements ProviderContainerInterface
2020
{
21+
/** @var AttributeValueProviderInterface */
22+
private $attributeValueProvider;
23+
24+
/** @var SessionInfoProviderInterface */
25+
private $sessionInfoProvider;
26+
27+
/** @var NameIdProviderInterface */
28+
private $nameIdProvider;
29+
30+
/**
31+
* @param AttributeValueProviderInterface $attributeValueProvider
32+
* @param SessionInfoProviderInterface $sessionInfoProvider
33+
* @param NameIdProviderInterface $nameIdProvider
34+
*/
35+
public function __construct(
36+
AttributeValueProviderInterface $attributeValueProvider,
37+
SessionInfoProviderInterface $sessionInfoProvider,
38+
NameIdProviderInterface $nameIdProvider
39+
) {
40+
$this->attributeValueProvider = $attributeValueProvider;
41+
$this->sessionInfoProvider = $sessionInfoProvider;
42+
$this->nameIdProvider = $nameIdProvider;
43+
}
44+
2145
/**
2246
* @return AttributeValueProviderInterface
2347
*/
2448
public function getAttributeValueProvider()
2549
{
26-
return $this->container->get('lightsaml.provider.attribute_value');
50+
return $this->attributeValueProvider;
2751
}
2852

2953
/**
3054
* @return SessionInfoProviderInterface
3155
*/
3256
public function getSessionInfoProvider()
3357
{
34-
return $this->container->get('lightsaml.provider.session_info');
58+
return $this->sessionInfoProvider;
3559
}
3660

3761
/**
3862
* @return NameIdProviderInterface
3963
*/
4064
public function getNameIdProvider()
4165
{
42-
return $this->container->get('lightsaml.provider.name_id');
43-
}
44-
45-
public function getAttributeNameProvider()
46-
{
47-
return $this->container->get('lightsaml.provider.attribute_name');
66+
return $this->nameIdProvider;
4867
}
4968
}

0 commit comments

Comments
 (0)