From 8fe223cf358a84ad623bf4a2ce115fd5d3403848 Mon Sep 17 00:00:00 2001 From: Ricardo Quintanilha Date: Wed, 18 Aug 2021 17:52:37 +0200 Subject: [PATCH 1/8] feat: Allow interface language to be overwritten in the BasicSession --- common/session/class.BasicSession.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/session/class.BasicSession.php b/common/session/class.BasicSession.php index 4396b3af4..ef43d9c9c 100644 --- a/common/session/class.BasicSession.php +++ b/common/session/class.BasicSession.php @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); + * Copyright (c) 2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * */ @@ -142,6 +142,10 @@ public function getDataLanguage() */ public function getInterfaceLanguage() { + if (PHPSession::singleton()->hasAttribute('overrideInterfaceLanguage')) { + return PHPSession::singleton()->getAttribute('overrideInterfaceLanguage'); + } + return $this->getServiceLocator()->get(UserLanguageServiceInterface::class)->getInterfaceLanguage($this->getUser()); } From be69ad74edc55e57058c990ae17b97deced8bab9 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Mon, 23 Aug 2021 12:58:17 +0000 Subject: [PATCH 2/8] feat: allow to save and get depends on property value --- core/GenerisRdf.php | 1 + core/kernel/classes/class.Property.php | 55 +++++++++++++++---- .../interface.PropertyInterface.php | 21 ++++--- .../persistence/smoothsql/class.Property.php | 22 ++++++-- core/ontology/generis.rdf | 7 +++ 5 files changed, 83 insertions(+), 23 deletions(-) diff --git a/core/GenerisRdf.php b/core/GenerisRdf.php index b58f16e4f..422412e48 100644 --- a/core/GenerisRdf.php +++ b/core/GenerisRdf.php @@ -60,6 +60,7 @@ interface GenerisRdf public const PROPERTY_MASK_SUBJECT = 'http://www.tao.lu/Ontologies/generis.rdf#MaskSubject'; public const PROPERTY_MASK_PREDICATE = 'http://www.tao.lu/Ontologies/generis.rdf#MaskPredicate'; public const PROPERTY_MASK_OBJECT = 'http://www.tao.lu/Ontologies/generis.rdf#MaskObject'; + public const PROPERTY_DEPENDS_ON_PROPERTY = 'http://www.tao.lu/Ontologies/generis.rdf#DependsOnProperty'; //@deprecated use UserRdf::CLASS_URI public const CLASS_GENERIS_USER = 'http://www.tao.lu/Ontologies/generis.rdf#User'; //@deprecated use UserRdf::PROPERTY_LOGIN diff --git a/core/kernel/classes/class.Property.php b/core/kernel/classes/class.Property.php index 71638898d..5526c1cc1 100644 --- a/core/kernel/classes/class.Property.php +++ b/core/kernel/classes/class.Property.php @@ -21,10 +21,11 @@ * */ -use oat\generis\model\data\ModelManager; +declare(strict_types=1); + +use oat\generis\model\WidgetRdf; use oat\generis\model\GenerisRdf; use oat\generis\model\OntologyRdfs; -use oat\generis\model\WidgetRdf; /** * uriProperty must be a valid property otherwis return false, add this as a @@ -88,6 +89,9 @@ class core_kernel_classes_Property extends core_kernel_classes_Resource */ public $multiple = false; + /** @var core_kernel_classes_Property|null */ + private $dependsOnProperty = null; + // --- OPERATIONS --- /** * @return core_kernel_persistence_PropertyInterface @@ -96,7 +100,7 @@ private function getImplementation() { return $this->getModel()->getRdfsInterface()->getPropertyImplementation(); } - + /** * constructor @@ -109,8 +113,8 @@ private function getImplementation() */ public function __construct($uri, $debug = '') { - parent::__construct($uri, $debug); + $this->lgDependent = null; $this->multiple = null; } @@ -145,7 +149,7 @@ public function getDomain() } } $returnValue = $this->domain; - + return $returnValue; } @@ -161,7 +165,7 @@ public function getDomain() public function setDomain(core_kernel_classes_Class $class) { $returnValue = (bool) false; - + if (!is_null($class)) { foreach ($this->getDomain()->getIterator() as $domainClass) { if ($class->equals($domainClass)) { @@ -190,7 +194,7 @@ public function setDomain(core_kernel_classes_Class $class) public function getRange() { $returnValue = null; - + if (is_null($this->range)) { $rangeProperty = $this->getProperty(OntologyRdfs::RDFS_RANGE); $rangeValues = $this->getPropertyValues($rangeProperty); @@ -222,6 +226,35 @@ public function setRange(core_kernel_classes_Class $class) return (bool) $returnValue; } + public function getDependsOnProperty(): ?core_kernel_classes_Property + { + if ($this->dependsOnProperty === null) { + $dependsOnProperty = $this->getProperty(GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY); + $dependsOnPropertyValue = $this->getOnePropertyValue($dependsOnProperty); + + if ( + $dependsOnPropertyValue !== null + && $dependsOnPropertyValue->getUri() !== GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY + ) { + $returnValue = $this->getProperty($dependsOnPropertyValue); + $this->dependsOnProperty = $returnValue; + } + } + + return $this->dependsOnProperty; + } + + public function setDependsOnProperty(core_kernel_classes_Property $property): bool + { + $numberOfUpdatedRows = $this->getImplementation()->setDependsOnProperty($this, $property); + + if ($numberOfUpdatedRows) { + $this->dependsOnProperty = $property; + } + + return (bool) $numberOfUpdatedRows; + } + /** * Get the Property object corresponding to the widget of this Property. * @@ -235,7 +268,7 @@ public function getWidget() if ($this->widget === false) { $this->widget = $this->getOnePropertyValue($this->getProperty(WidgetRdf::PROPERTY_WIDGET)); } - + return $this->widget; } @@ -282,7 +315,7 @@ public function isMultiple() if (is_null($this->multiple)) { $multipleProperty = $this->getProperty(GenerisRdf::PROPERTY_MULTIPLE); $multiple = $this->getOnePropertyValue($multipleProperty); - + if (is_null($multiple)) { $returnValue = false; } else { @@ -290,7 +323,7 @@ public function isMultiple() } $this->multiple = $returnValue; } - + $returnValue = $this->multiple; return (bool) $returnValue; } @@ -306,7 +339,7 @@ public function isMultiple() */ public function setMultiple($isMultiple) { - + $this->getImplementation()->setMultiple($this, $isMultiple); $this->multiple = $isMultiple; } diff --git a/core/kernel/persistence/interface.PropertyInterface.php b/core/kernel/persistence/interface.PropertyInterface.php index a5f3261c1..c5fd8c3d0 100644 --- a/core/kernel/persistence/interface.PropertyInterface.php +++ b/core/kernel/persistence/interface.PropertyInterface.php @@ -30,8 +30,8 @@ interface core_kernel_persistence_PropertyInterface { - - + + /** * Short description of method isLgDependent * @@ -41,7 +41,7 @@ interface core_kernel_persistence_PropertyInterface * @return boolean */ public function isLgDependent(core_kernel_classes_Resource $resource); - + /** * Short description of method isMultiple * @@ -51,7 +51,7 @@ public function isLgDependent(core_kernel_classes_Resource $resource); * @return boolean */ public function isMultiple(core_kernel_classes_Resource $resource); - + /** * Short description of method getRange * @@ -61,7 +61,7 @@ public function isMultiple(core_kernel_classes_Resource $resource); * @return core_kernel_classes_Class */ public function getRange(core_kernel_classes_Resource $resource); - + /** * Short description of method delete * @@ -72,7 +72,7 @@ public function getRange(core_kernel_classes_Resource $resource); * @return boolean */ public function delete(core_kernel_classes_Resource $resource, $deleteReference = false); - + /** * Short description of method setRange * @@ -83,7 +83,12 @@ public function delete(core_kernel_classes_Resource $resource, $deleteReference * @return core_kernel_classes_Class */ public function setRange(core_kernel_classes_Resource $resource, core_kernel_classes_Class $class); - + + public function setDependsOnProperty( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property + ): int; + /** * Short description of method setMultiple * @@ -94,7 +99,7 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla * @return void */ public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple); - + /** * Short description of method setLgDependent * diff --git a/core/kernel/persistence/smoothsql/class.Property.php b/core/kernel/persistence/smoothsql/class.Property.php index e4b67f4e4..7e502b86b 100644 --- a/core/kernel/persistence/smoothsql/class.Property.php +++ b/core/kernel/persistence/smoothsql/class.Property.php @@ -20,10 +20,12 @@ * 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); */ - + +declare(strict_types=1); + use oat\generis\model\GenerisRdf; use oat\generis\model\OntologyRdfs; - + /** * Short description of class core_kernel_persistence_smoothsql_Property * @@ -139,6 +141,18 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla return $returnValue; } + public function setDependsOnProperty( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property + ): int { + $dependsOnProperty = new core_kernel_classes_Property( + GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY, + __METHOD__ + ); + + return $this->setPropertyValue($resource, $dependsOnProperty, $property->getUri()); + } + /** * Short description of method setMultiple * @@ -150,7 +164,7 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla */ public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple) { - + $multipleProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_MULTIPLE); $value = ((bool)$isMultiple) ? GenerisRdf::GENERIS_TRUE : GenerisRdf::GENERIS_FALSE ; $this->removePropertyValues($resource, $multipleProperty); @@ -168,7 +182,7 @@ public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple) */ public function setLgDependent(core_kernel_classes_Resource $resource, $isLgDependent) { - + $lgDependentProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT, __METHOD__); $value = ((bool)$isLgDependent) ? GenerisRdf::GENERIS_TRUE : GenerisRdf::GENERIS_FALSE ; $this->removePropertyValues($resource, $lgDependentProperty); diff --git a/core/ontology/generis.rdf b/core/ontology/generis.rdf index 492a6c6f3..1ef62de21 100644 --- a/core/ontology/generis.rdf +++ b/core/ontology/generis.rdf @@ -366,4 +366,11 @@ + + + + + + + From 32ef68f489d5a23ffe6cec76d62cd42d80e26642 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Mon, 23 Aug 2021 13:11:37 +0000 Subject: [PATCH 3/8] refactor: move migration from tao-core to generis --- .../Version202108231309322348_generis.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 migrations/Version202108231309322348_generis.php diff --git a/migrations/Version202108231309322348_generis.php b/migrations/Version202108231309322348_generis.php new file mode 100644 index 000000000..fd3d7883d --- /dev/null +++ b/migrations/Version202108231309322348_generis.php @@ -0,0 +1,48 @@ +addReport(Report::createSuccess('Models were successfully synchronized')); + } + + public function down(Schema $schema): void + { + $this->throwIrreversibleMigrationException(); + } +} From 15fffce934c5a2159fd9183301960025039e3922 Mon Sep 17 00:00:00 2001 From: Ricardo Quintanilha Date: Mon, 23 Aug 2021 17:27:11 +0200 Subject: [PATCH 4/8] chore: Set `customInterfaceLanguage` in the UserLanguageService to keep logic cohesive --- common/oatbox/user/UserLanguageService.php | 15 +++++++ .../user/UserLanguageServiceInterface.php | 8 ++++ common/session/class.BasicSession.php | 12 ++++-- .../oatbox/user/UserLanguageServiceTest.php | 40 +++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/common/oatbox/user/UserLanguageService.php b/common/oatbox/user/UserLanguageService.php index 72d67e22a..aaf7d225d 100644 --- a/common/oatbox/user/UserLanguageService.php +++ b/common/oatbox/user/UserLanguageService.php @@ -29,6 +29,9 @@ class UserLanguageService extends ConfigurableService implements UserLanguageSer public const OPTION_LOCK_DATA_LANGUAGE = 'lock_data_language'; public const OPTION_AUTHORING_LANGUAGE = 'authoring_language'; + /** @var ?string */ + private $customInterfaceLanguage; + /** * {@inheritDoc} * @see \oat\oatbox\user\UserLanguageServiceInterface::getDefaultLanguage() @@ -56,6 +59,10 @@ public function getDataLanguage(User $user) */ public function getInterfaceLanguage(User $user) { + if (!empty($this->customInterfaceLanguage)) { + return $this->customInterfaceLanguage; + } + $lang = $user->getPropertyValues(GenerisRdf::PROPERTY_USER_UILG); return empty($lang) ? $this->getDefaultLanguage() : (string)current($lang); } @@ -72,4 +79,12 @@ public function getAuthoringLanguage(): string { return $this->getOption(self::OPTION_AUTHORING_LANGUAGE, $this->getDefaultLanguage()); } + + /** + * @inheritdoc + */ + public function setCustomInterfaceLanguage(?string $customInterfaceLanguage): void + { + $this->customInterfaceLanguage = $customInterfaceLanguage; + } } diff --git a/common/oatbox/user/UserLanguageServiceInterface.php b/common/oatbox/user/UserLanguageServiceInterface.php index 8e3949eab..81c948dd0 100644 --- a/common/oatbox/user/UserLanguageServiceInterface.php +++ b/common/oatbox/user/UserLanguageServiceInterface.php @@ -52,4 +52,12 @@ public function getInterfaceLanguage(User $user); * @return boolean */ public function isDataLanguageEnabled(); + + /** + * When a custom interface language is set, it overrides the interface language retrieved in the getInterfaceLanguage + * method. + * + * @param ?string $customInterfaceLanguage + */ + public function setCustomInterfaceLanguage(?string $customInterfaceLanguage): void; } diff --git a/common/session/class.BasicSession.php b/common/session/class.BasicSession.php index ef43d9c9c..f8c3e87f9 100644 --- a/common/session/class.BasicSession.php +++ b/common/session/class.BasicSession.php @@ -142,11 +142,17 @@ public function getDataLanguage() */ public function getInterfaceLanguage() { - if (PHPSession::singleton()->hasAttribute('overrideInterfaceLanguage')) { - return PHPSession::singleton()->getAttribute('overrideInterfaceLanguage'); + /** @var PHPSession $session */ + $session = PHPSession::singleton(); + + /** @var UserLanguageServiceInterface $userLanguageService */ + $userLanguageService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class); + + if ($session->hasAttribute('overrideInterfaceLanguage')) { + $userLanguageService->setCustomInterfaceLanguage($session->getAttribute('overrideInterfaceLanguage')); } - return $this->getServiceLocator()->get(UserLanguageServiceInterface::class)->getInterfaceLanguage($this->getUser()); + return $userLanguageService->getInterfaceLanguage($this->getUser()); } /** diff --git a/test/unit/common/oatbox/user/UserLanguageServiceTest.php b/test/unit/common/oatbox/user/UserLanguageServiceTest.php index 70446254b..3d3b1f9e1 100644 --- a/test/unit/common/oatbox/user/UserLanguageServiceTest.php +++ b/test/unit/common/oatbox/user/UserLanguageServiceTest.php @@ -22,8 +22,12 @@ namespace oat\generis\test\unit\common\oatbox\user; +use oat\generis\model\GenerisRdf; use oat\generis\test\TestCase; +use oat\oatbox\user\User; use oat\oatbox\user\UserLanguageService; +use Prophecy\Argument; +use Prophecy\Prophecy\ObjectProphecy; class UserLanguageServiceTest extends TestCase { @@ -50,4 +54,40 @@ public function testGetDefaultLanguageForAuthoringLanguage(): void $this->assertSame($this->subject->getDefaultLanguage(), $this->subject->getAuthoringLanguage()); } + + public function testGetInterfaceLanguageReturnsDefaultLanguageWhenUserDoesNotHaveItSet(): void + { + $user = $this->createUser(); + + $this->assertSame($this->subject->getDefaultLanguage(), $this->subject->getInterfaceLanguage($user)); + } + + public function testGetInterfaceLanguageReturnsLanguageFromUser(): void + { + $user = $this->createUser('en-US'); + + $this->assertSame('en-US', $this->subject->getInterfaceLanguage($user)); + } + + public function testGetInterfaceLanguageReturnsCustomInterfaceLanguage(): void + { + $this->subject->setCustomInterfaceLanguage('es-ES'); + + $user = $this->createUser(); + + $this->assertSame('es-ES', $this->subject->getInterfaceLanguage($user)); + } + + private function createUser(?string $withLanguage = null): User + { + /** @var User|ObjectProphecy $user */ + $user = $this->prophesize(User::class); + + if ($withLanguage !== null) { + $user->getPropertyValues(Argument::is(GenerisRdf::PROPERTY_USER_UILG)) + ->willReturn([$withLanguage]); + } + + return $user->reveal(); + } } From f34b1899e8811e2c42bd07ab55fa0b40c5654757 Mon Sep 17 00:00:00 2001 From: Ricardo Quintanilha Date: Mon, 23 Aug 2021 18:25:10 +0200 Subject: [PATCH 5/8] chore: Use year range in the copyright disclaimer in class.BasicSession.php Co-authored-by: Sergei Mikhailov --- common/session/class.BasicSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/session/class.BasicSession.php b/common/session/class.BasicSession.php index f8c3e87f9..9c158bb13 100644 --- a/common/session/class.BasicSession.php +++ b/common/session/class.BasicSession.php @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); + * Copyright (c) 2017-2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * */ From feb6dd43a31aa83785ed596c4fbe4b54f0e8a019 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Mon, 23 Aug 2021 23:07:56 +0000 Subject: [PATCH 6/8] refactor: change int and bool to void for setters --- core/kernel/classes/class.Property.php | 10 +++------- .../kernel/persistence/interface.PropertyInterface.php | 2 +- core/kernel/persistence/smoothsql/class.Property.php | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/kernel/classes/class.Property.php b/core/kernel/classes/class.Property.php index 5526c1cc1..18f95c466 100644 --- a/core/kernel/classes/class.Property.php +++ b/core/kernel/classes/class.Property.php @@ -244,15 +244,11 @@ public function getDependsOnProperty(): ?core_kernel_classes_Property return $this->dependsOnProperty; } - public function setDependsOnProperty(core_kernel_classes_Property $property): bool + public function setDependsOnProperty(core_kernel_classes_Property $property): void { - $numberOfUpdatedRows = $this->getImplementation()->setDependsOnProperty($this, $property); + $this->getImplementation()->setDependsOnProperty($this, $property); - if ($numberOfUpdatedRows) { - $this->dependsOnProperty = $property; - } - - return (bool) $numberOfUpdatedRows; + $this->dependsOnProperty = $property; } /** diff --git a/core/kernel/persistence/interface.PropertyInterface.php b/core/kernel/persistence/interface.PropertyInterface.php index c5fd8c3d0..4c5e8d079 100644 --- a/core/kernel/persistence/interface.PropertyInterface.php +++ b/core/kernel/persistence/interface.PropertyInterface.php @@ -87,7 +87,7 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla public function setDependsOnProperty( core_kernel_classes_Resource $resource, core_kernel_classes_Property $property - ): int; + ): void; /** * Short description of method setMultiple diff --git a/core/kernel/persistence/smoothsql/class.Property.php b/core/kernel/persistence/smoothsql/class.Property.php index 7e502b86b..34f80e54c 100644 --- a/core/kernel/persistence/smoothsql/class.Property.php +++ b/core/kernel/persistence/smoothsql/class.Property.php @@ -144,13 +144,13 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla public function setDependsOnProperty( core_kernel_classes_Resource $resource, core_kernel_classes_Property $property - ): int { + ): void { $dependsOnProperty = new core_kernel_classes_Property( GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY, __METHOD__ ); - return $this->setPropertyValue($resource, $dependsOnProperty, $property->getUri()); + $this->setPropertyValue($resource, $dependsOnProperty, $property->getUri()); } /** From ffa357bc9331bea7276f8999de8bb4fb6710a113 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Wed, 25 Aug 2021 08:33:26 +0000 Subject: [PATCH 7/8] refactor: change getter and setter to work with collection --- core/kernel/classes/class.Property.php | 42 +++++++++++-------- core/resource/DependsOnPropertyCollection.php | 33 +++++++++++++++ 2 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 core/resource/DependsOnPropertyCollection.php diff --git a/core/kernel/classes/class.Property.php b/core/kernel/classes/class.Property.php index 18f95c466..f6c5e6c16 100644 --- a/core/kernel/classes/class.Property.php +++ b/core/kernel/classes/class.Property.php @@ -26,6 +26,7 @@ use oat\generis\model\WidgetRdf; use oat\generis\model\GenerisRdf; use oat\generis\model\OntologyRdfs; +use oat\generis\model\resource\DependsOnPropertyCollection; /** * uriProperty must be a valid property otherwis return false, add this as a @@ -89,8 +90,8 @@ class core_kernel_classes_Property extends core_kernel_classes_Resource */ public $multiple = false; - /** @var core_kernel_classes_Property|null */ - private $dependsOnProperty = null; + /** @var DependsOnPropertyCollection */ + private $dependsOnPropertyCollection; // --- OPERATIONS --- /** @@ -117,6 +118,7 @@ public function __construct($uri, $debug = '') $this->lgDependent = null; $this->multiple = null; + $this->dependsOnPropertyCollection = new DependsOnPropertyCollection(); } /** @@ -226,29 +228,35 @@ public function setRange(core_kernel_classes_Class $class) return (bool) $returnValue; } - public function getDependsOnProperty(): ?core_kernel_classes_Property + /** + * @TODO Improve getter + */ + public function getDependsOnPropertyCollection(): DependsOnPropertyCollection { - if ($this->dependsOnProperty === null) { - $dependsOnProperty = $this->getProperty(GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY); - $dependsOnPropertyValue = $this->getOnePropertyValue($dependsOnProperty); - - if ( - $dependsOnPropertyValue !== null - && $dependsOnPropertyValue->getUri() !== GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY - ) { - $returnValue = $this->getProperty($dependsOnPropertyValue); - $this->dependsOnProperty = $returnValue; + $dependsOnProperty = $this->getProperty(GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY); + $dependsOnPropertyValues = $this->getPropertyValues($dependsOnProperty); + + foreach ($dependsOnPropertyValues as $dependsOnPropertyValue) { + if ($dependsOnPropertyValue !== GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY) { + $this->dependsOnPropertyCollection->append( + $this->getProperty($dependsOnPropertyValue) + ); } } - return $this->dependsOnProperty; + return $this->dependsOnPropertyCollection; } - public function setDependsOnProperty(core_kernel_classes_Property $property): void + /** + * @TODO Improve setter + */ + public function setDependsOnPropertyCollection(DependsOnPropertyCollection $dependsOnPropertyCollection): void { - $this->getImplementation()->setDependsOnProperty($this, $property); + foreach ($dependsOnPropertyCollection as $dependsOnProperty) { + $this->getImplementation()->setDependsOnProperty($this, $dependsOnProperty); + } - $this->dependsOnProperty = $property; + $this->dependsOnPropertyCollection = $dependsOnPropertyCollection; } /** diff --git a/core/resource/DependsOnPropertyCollection.php b/core/resource/DependsOnPropertyCollection.php new file mode 100644 index 000000000..66a9ca5e0 --- /dev/null +++ b/core/resource/DependsOnPropertyCollection.php @@ -0,0 +1,33 @@ + Date: Wed, 25 Aug 2021 12:29:59 +0200 Subject: [PATCH 8/8] chore: Remove custom language interface when `overrideInterfaceLanguage` doesn't exist or is removed --- common/session/class.BasicSession.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/session/class.BasicSession.php b/common/session/class.BasicSession.php index 9c158bb13..f1df3a6eb 100644 --- a/common/session/class.BasicSession.php +++ b/common/session/class.BasicSession.php @@ -150,6 +150,9 @@ public function getInterfaceLanguage() if ($session->hasAttribute('overrideInterfaceLanguage')) { $userLanguageService->setCustomInterfaceLanguage($session->getAttribute('overrideInterfaceLanguage')); + } else { + // Just to be sure the custom interface language is removed when the session attribute is gone + $userLanguageService->setCustomInterfaceLanguage(null); } return $userLanguageService->getInterfaceLanguage($this->getUser());