Skip to content

Commit 1caa10e

Browse files
committed
Translatable configurable metadata
1 parent 7580c3a commit 1caa10e

14 files changed

+58
-63
lines changed

src/OpenConext/EngineBlock/Metadata/Factory/Adapter/IdentityProviderEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public function hasCompleteOrganizationData(string $locale): bool
126126
}
127127

128128
/**
129-
* @param $locale
129+
* @param string $locale
130130
* @return Organization
131131
*/
132-
public function getOrganization($locale): ?Organization
132+
public function getOrganization(string $locale): ?Organization
133133
{
134134
switch (true) {
135135
case ($locale == 'nl'):

src/OpenConext/EngineBlock/Metadata/Factory/Adapter/ServiceProviderEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ public function hasCompleteOrganizationData(string $locale): bool
128128
}
129129

130130
/**
131-
* @param $locale
131+
* @param string $locale
132132
* @return Organization
133133
*/
134-
public function getOrganization($locale): ?Organization
134+
public function getOrganization(string $locale): ?Organization
135135
{
136136
switch (true) {
137137
case ($locale == 'nl'):

src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractIdentityProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ public function hasCompleteOrganizationData(string $locale): bool
114114
}
115115

116116
/**
117-
* @param $locale
117+
* @param string $locale
118118
* @return Organization|null
119119
*/
120-
public function getOrganization($locale): ?Organization
120+
public function getOrganization(string $locale): ?Organization
121121
{
122122
return $this->entity->getOrganization($locale);
123123
}

src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ public function hasCompleteOrganizationData(string $locale): bool
107107
}
108108

109109
/**
110-
* @param $locale
110+
* @param string $locale
111111
* @return Organization|null
112112
*/
113-
public function getOrganization($locale): ?Organization
113+
public function getOrganization(string $locale): ?Organization
114114
{
115115
return $this->entity->getOrganization($locale);
116116
}

src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockIdentityProviderInformation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public function getLogo(): ?Logo
6060
return $this->engineBlockConfiguration->getLogo();
6161
}
6262

63-
public function getOrganization($locale): ?Organization
63+
public function getOrganization(string $locale): ?Organization
6464
{
65-
return $this->engineBlockConfiguration->getOrganization();
65+
return $this->engineBlockConfiguration->getOrganization($locale);
6666
}
6767

6868
/**

src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockServiceProviderInformation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public function getLogo(): ?Logo
6060
return $this->engineBlockConfiguration->getLogo();
6161
}
6262

63-
public function getOrganization($locale): ?Organization
63+
public function getOrganization(string $locale): ?Organization
6464
{
65-
return $this->engineBlockConfiguration->getOrganization();
65+
return $this->engineBlockConfiguration->getOrganization($locale);
6666
}
6767

6868
/**

src/OpenConext/EngineBlock/Metadata/Factory/IdentityProviderEntityInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public function getLogo(): ?Logo;
7171
public function hasCompleteOrganizationData(string $locale): bool;
7272

7373
/**
74-
* @param $locale
74+
* @param string $locale
7575
* @return Organization|null
7676
*/
77-
public function getOrganization($locale): ?Organization;
77+
public function getOrganization(string $locale): ?Organization;
7878

7979
/**
8080
* @param $locale

src/OpenConext/EngineBlock/Metadata/Factory/ServiceProviderEntityInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ public function getLogo(): ?Logo;
6363
public function hasCompleteOrganizationData(string $locale): bool;
6464

6565
/**
66-
* @param $locale
66+
* @param string $locale
6767
* @return Organization|null
6868
*/
69-
public function getOrganization($locale): ?Organization;
69+
public function getOrganization(string $locale): ?Organization;
7070

7171
/**
7272
* @param $locale

src/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfiguration.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
*/
3131
class EngineBlockConfiguration
3232
{
33+
/**
34+
* @var \Symfony\Component\Translation\TranslatorInterface
35+
*/
36+
private $translator;
37+
3338
/**
3439
* @var string
3540
*/
@@ -84,11 +89,12 @@ public function __construct(
8489
int $logoWidth,
8590
int $logoHeight
8691
) {
92+
$this->translator = $translator;
8793
$this->suiteName = $translator->trans('suite_name');
8894
$this->engineHostName = $engineHostName;
89-
$this->organizationName = $translator->trans('metadata_organization_name');
90-
$this->organizationDisplayName = $translator->trans('metadata_organization_displayname');
91-
$this->organizationUrl = $translator->trans('metadata_organization_url');
95+
$this->organizationName = 'metadata_organization_name';
96+
$this->organizationDisplayName = 'metadata_organization_displayname';
97+
$this->organizationUrl = 'metadata_organization_url';
9298
$this->supportMail = $supportMail;
9399
$this->description = $description;
94100

@@ -101,9 +107,10 @@ public function __construct(
101107
$this->logo->height = $logoHeight;
102108

103109
// Create the contact person data for the EB SP entity
104-
$support = ContactPerson::from('support', $this->organizationName, 'Support', $this->supportMail);
105-
$technical = ContactPerson::from('technical', $this->organizationName, 'Support', $this->supportMail);
106-
$administrative = ContactPerson::from('administrative', $this->organizationName, 'Support', $this->supportMail);
110+
$organizationName = $translator->trans('metadata_organization_name');
111+
$support = ContactPerson::from('support', $organizationName, 'Support', $this->supportMail);
112+
$technical = ContactPerson::from('technical', $organizationName, 'Support', $this->supportMail);
113+
$administrative = ContactPerson::from('administrative', $organizationName, 'Support', $this->supportMail);
107114

108115
$this->contactPersons = [$support, $technical, $administrative];
109116
}
@@ -118,9 +125,12 @@ public function getHostname(): string
118125
return $this->engineHostName;
119126
}
120127

121-
public function getOrganization() : Organization
128+
public function getOrganization(string $locale) : Organization
122129
{
123-
return new Organization($this->organizationName, $this->organizationDisplayName, $this->organizationUrl);
130+
$organizationName = $this->translator->trans($this->organizationName, [], null, $locale);
131+
$organizationDisplayName = $this->translator->trans($this->organizationDisplayName, [], null, $locale);
132+
$organizationUrl = $this->translator->trans($this->organizationUrl, [], null, $locale);
133+
return new Organization($organizationName, $organizationDisplayName, $organizationUrl);
124134
}
125135

126136
public function getLogo(): Logo

tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,28 @@ public function test_methods()
4242
->willReturn('configuredOrganizationName');
4343

4444
$translator->expects($this->at(2))
45+
->method('trans')
46+
->with('metadata_organization_name')
47+
->willReturn('configuredOrganizationName');
48+
49+
$translator->expects($this->at(3))
4550
->method('trans')
4651
->with('metadata_organization_displayname')
4752
->willReturn('configuredOrganizationDisplayName');
4853

49-
$translator->expects($this->at(3))
54+
$translator->expects($this->at(4))
5055
->method('trans')
5156
->with('metadata_organization_url')
5257
->willReturn('configuredOrganizationUrl');
5358

5459
$configuration = new EngineBlockConfiguration(
5560
$translator,
56-
'configuredSupportMail',
57-
'configuredDescription',
58-
'example.org',
59-
'/configuredLogoUrl',
60-
1209,
61-
1009
61+
'configuredSupportMail',
62+
'configuredDescription',
63+
'example.org',
64+
'/configuredLogoUrl',
65+
1209,
66+
1009
6267
);
6368

6469
$decorator = new EngineBlockIdentityProviderInformation($adapter, $configuration);

0 commit comments

Comments
 (0)