diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/IdentityProviderEntity.php b/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/IdentityProviderEntity.php index 69241ccb3..13d028a03 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/IdentityProviderEntity.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/IdentityProviderEntity.php @@ -126,10 +126,10 @@ public function hasCompleteOrganizationData(string $locale): bool } /** - * @param $locale + * @param string $locale * @return Organization */ - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { switch (true) { case ($locale == 'nl'): diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/ServiceProviderEntity.php b/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/ServiceProviderEntity.php index ee7837189..2170eeab1 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/ServiceProviderEntity.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Adapter/ServiceProviderEntity.php @@ -128,10 +128,10 @@ public function hasCompleteOrganizationData(string $locale): bool } /** - * @param $locale + * @param string $locale * @return Organization */ - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { switch (true) { case ($locale == 'nl'): diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractIdentityProvider.php b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractIdentityProvider.php index 565cd0b8b..f3c43a428 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractIdentityProvider.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractIdentityProvider.php @@ -114,10 +114,10 @@ public function hasCompleteOrganizationData(string $locale): bool } /** - * @param $locale + * @param string $locale * @return Organization|null */ - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { return $this->entity->getOrganization($locale); } diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractServiceProvider.php b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractServiceProvider.php index 36326ec90..d83f4831c 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractServiceProvider.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/AbstractServiceProvider.php @@ -107,10 +107,10 @@ public function hasCompleteOrganizationData(string $locale): bool } /** - * @param $locale + * @param string $locale * @return Organization|null */ - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { return $this->entity->getOrganization($locale); } diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockIdentityProviderInformation.php b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockIdentityProviderInformation.php index d7d7e53b5..e315b00c0 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockIdentityProviderInformation.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockIdentityProviderInformation.php @@ -60,9 +60,9 @@ public function getLogo(): ?Logo return $this->engineBlockConfiguration->getLogo(); } - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { - return $this->engineBlockConfiguration->getOrganization(); + return $this->engineBlockConfiguration->getOrganization($locale); } /** diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockServiceProviderInformation.php b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockServiceProviderInformation.php index e5d15ccd3..d969ac571 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockServiceProviderInformation.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineBlockServiceProviderInformation.php @@ -60,9 +60,9 @@ public function getLogo(): ?Logo return $this->engineBlockConfiguration->getLogo(); } - public function getOrganization($locale): ?Organization + public function getOrganization(string $locale): ?Organization { - return $this->engineBlockConfiguration->getOrganization(); + return $this->engineBlockConfiguration->getOrganization($locale); } /** diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/IdentityProviderEntityInterface.php b/src/OpenConext/EngineBlock/Metadata/Factory/IdentityProviderEntityInterface.php index 713a5832f..99622c532 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/IdentityProviderEntityInterface.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/IdentityProviderEntityInterface.php @@ -71,10 +71,10 @@ public function getLogo(): ?Logo; public function hasCompleteOrganizationData(string $locale): bool; /** - * @param $locale + * @param string $locale * @return Organization|null */ - public function getOrganization($locale): ?Organization; + public function getOrganization(string $locale): ?Organization; /** * @param $locale diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/ServiceProviderEntityInterface.php b/src/OpenConext/EngineBlock/Metadata/Factory/ServiceProviderEntityInterface.php index 271390bac..925062a21 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/ServiceProviderEntityInterface.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/ServiceProviderEntityInterface.php @@ -63,10 +63,10 @@ public function getLogo(): ?Logo; public function hasCompleteOrganizationData(string $locale): bool; /** - * @param $locale + * @param string $locale * @return Organization|null */ - public function getOrganization($locale): ?Organization; + public function getOrganization(string $locale): ?Organization; /** * @param $locale diff --git a/src/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfiguration.php b/src/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfiguration.php index b6c43a0bb..4164ca0bc 100644 --- a/src/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfiguration.php +++ b/src/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfiguration.php @@ -30,6 +30,11 @@ */ class EngineBlockConfiguration { + /** + * @var \Symfony\Component\Translation\TranslatorInterface + */ + private $translator; + /** * @var string */ @@ -84,11 +89,12 @@ public function __construct( int $logoWidth, int $logoHeight ) { + $this->translator = $translator; $this->suiteName = $translator->trans('suite_name'); $this->engineHostName = $engineHostName; - $this->organizationName = $translator->trans('metadata_organization_name'); - $this->organizationDisplayName = $translator->trans('metadata_organization_displayname'); - $this->organizationUrl = $translator->trans('metadata_organization_url'); + $this->organizationName = 'metadata_organization_name'; + $this->organizationDisplayName = 'metadata_organization_displayname'; + $this->organizationUrl = 'metadata_organization_url'; $this->supportMail = $supportMail; $this->description = $description; @@ -101,9 +107,10 @@ public function __construct( $this->logo->height = $logoHeight; // Create the contact person data for the EB SP entity - $support = ContactPerson::from('support', $this->organizationName, 'Support', $this->supportMail); - $technical = ContactPerson::from('technical', $this->organizationName, 'Support', $this->supportMail); - $administrative = ContactPerson::from('administrative', $this->organizationName, 'Support', $this->supportMail); + $organizationName = $translator->trans('metadata_organization_name'); + $support = ContactPerson::from('support', $organizationName, 'Support', $this->supportMail); + $technical = ContactPerson::from('technical', $organizationName, 'Support', $this->supportMail); + $administrative = ContactPerson::from('administrative', $organizationName, 'Support', $this->supportMail); $this->contactPersons = [$support, $technical, $administrative]; } @@ -118,9 +125,12 @@ public function getHostname(): string return $this->engineHostName; } - public function getOrganization() : Organization + public function getOrganization(string $locale) : Organization { - return new Organization($this->organizationName, $this->organizationDisplayName, $this->organizationUrl); + $organizationName = $this->translator->trans($this->organizationName, [], null, $locale); + $organizationDisplayName = $this->translator->trans($this->organizationDisplayName, [], null, $locale); + $organizationUrl = $this->translator->trans($this->organizationUrl, [], null, $locale); + return new Organization($organizationName, $organizationDisplayName, $organizationUrl); } public function getLogo(): Logo diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php index f00a8c26e..1bc1da73d 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php @@ -42,23 +42,28 @@ public function test_methods() ->willReturn('configuredOrganizationName'); $translator->expects($this->at(2)) + ->method('trans') + ->with('metadata_organization_name') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(3)) ->method('trans') ->with('metadata_organization_displayname') ->willReturn('configuredOrganizationDisplayName'); - $translator->expects($this->at(3)) + $translator->expects($this->at(4)) ->method('trans') ->with('metadata_organization_url') ->willReturn('configuredOrganizationUrl'); $configuration = new EngineBlockConfiguration( $translator, - 'configuredSupportMail', - 'configuredDescription', - 'example.org', - '/configuredLogoUrl', - 1209, - 1009 + 'configuredSupportMail', + 'configuredDescription', + 'example.org', + '/configuredLogoUrl', + 1209, + 1009 ); $decorator = new EngineBlockIdentityProviderInformation($adapter, $configuration); diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php index b717e9cf7..42176d2f8 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php @@ -43,11 +43,16 @@ public function test_methods() ->willReturn('configuredOrganizationName'); $translator->expects($this->at(2)) + ->method('trans') + ->with('metadata_organization_name') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(3)) ->method('trans') ->with('metadata_organization_displayname') ->willReturn('configuredOrganizationDisplayName'); - $translator->expects($this->at(3)) + $translator->expects($this->at(4)) ->method('trans') ->with('metadata_organization_url') ->willReturn('configuredOrganizationUrl'); diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/ProxiedIdentityProviderTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/ProxiedIdentityProviderTest.php index 0b95e5579..148133d32 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/ProxiedIdentityProviderTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/ProxiedIdentityProviderTest.php @@ -111,16 +111,6 @@ private function createConfiguration(): EngineBlockConfiguration ->with('metadata_organization_name') ->willReturn('configuredOrganizationName'); - $translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); - $configuration = new EngineBlockConfiguration( $translator, 'configuredSupportMail', diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/IdentityProviderFactoryTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/IdentityProviderFactoryTest.php index 809ec179a..952a13170 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/IdentityProviderFactoryTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/IdentityProviderFactoryTest.php @@ -98,16 +98,6 @@ public function test_create_idp_entity_from_entity_properties() ->with('metadata_organization_name') ->willReturn('configuredOrganizationName'); - $this->translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $this->translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); - $this->configuration = new EngineBlockConfiguration( $this->translator, 'configuredSupportMail', diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php index b320f9dfc..1d2d96245 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php @@ -125,11 +125,16 @@ public function test_eb_properties() ->willReturn('configuredOrganizationName'); $this->translator->expects($this->at(2)) + ->method('trans') + ->with('metadata_organization_name') + ->willReturn('configuredOrganizationName'); + + $this->translator->expects($this->at(3)) ->method('trans') ->with('metadata_organization_displayname') ->willReturn('configuredOrganizationDisplayName'); - $this->translator->expects($this->at(3)) + $this->translator->expects($this->at(4)) ->method('trans') ->with('metadata_organization_url') ->willReturn('configuredOrganizationUrl'); @@ -295,16 +300,6 @@ public function test_stepup_properties() ->with('metadata_organization_name') ->willReturn('configuredOrganizationName'); - $this->translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $this->translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); - $this->configuration = new EngineBlockConfiguration( $this->translator, 'configuredSupportMail',