diff --git a/composer.lock b/composer.lock index 413347c..bc5390e 100644 --- a/composer.lock +++ b/composer.lock @@ -411,12 +411,12 @@ "source": { "type": "git", "url": "https://github.com/RRZE-Webteam/FAU-Studium-Common.git", - "reference": "fc1f347cd46f7cca7588c8a5df274b1426dd77d2" + "reference": "d83e8ea07501f8ab93d52fd2de7c44020751ec1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/RRZE-Webteam/FAU-Studium-Common/zipball/fc1f347cd46f7cca7588c8a5df274b1426dd77d2", - "reference": "fc1f347cd46f7cca7588c8a5df274b1426dd77d2", + "url": "https://api.github.com/repos/RRZE-Webteam/FAU-Studium-Common/zipball/d83e8ea07501f8ab93d52fd2de7c44020751ec1d", + "reference": "d83e8ea07501f8ab93d52fd2de7c44020751ec1d", "shasum": "" }, "require": { @@ -489,7 +489,7 @@ "source": "https://github.com/RRZE-Webteam/FAU-Studium-Common/tree/dev", "issues": "https://github.com/RRZE-Webteam/FAU-Studium-Common/issues" }, - "time": "2024-07-03T10:40:43+00:00" + "time": "2024-07-16T06:54:30+00:00" }, { "name": "webmozart/assert", @@ -4339,16 +4339,16 @@ }, { "name": "vimeo/psalm", - "version": "5.24.0", + "version": "5.25.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "462c80e31c34e58cc4f750c656be3927e80e550e" + "reference": "01a8eb06b9e9cc6cfb6a320bf9fb14331919d505" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/462c80e31c34e58cc4f750c656be3927e80e550e", - "reference": "462c80e31c34e58cc4f750c656be3927e80e550e", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/01a8eb06b9e9cc6cfb6a320bf9fb14331919d505", + "reference": "01a8eb06b9e9cc6cfb6a320bf9fb14331919d505", "shasum": "" }, "require": { @@ -4445,7 +4445,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-05-01T19:32:08+00:00" + "time": "2024-06-16T15:08:35+00:00" }, { "name": "wp-coding-standards/wpcs", diff --git a/src/Infrastructure/Search/FilterableTermsUpdater.php b/src/Infrastructure/Search/FilterableTermsUpdater.php index e18246b..410bad3 100644 --- a/src/Infrastructure/Search/FilterableTermsUpdater.php +++ b/src/Infrastructure/Search/FilterableTermsUpdater.php @@ -335,10 +335,11 @@ private function retrieveParentTermId( array &$taxonomyCache ): int { - if (!$flatProperty instanceof Degree && !$flatProperty instanceof AdmissionRequirement) { + if (!$this->isHierarchicalProperty($flatProperty)) { return 0; } + /** @var AdmissionRequirement|Degree $flatProperty */ $parentProperty = $flatProperty->parent(); if (is_null($parentProperty)) { @@ -376,11 +377,12 @@ private function extendPropertiesWithParents(array $flatProperties): array $properties = []; foreach ($flatProperties as $flatProperty) { - if (!$flatProperty instanceof Degree && !$flatProperty instanceof AdmissionRequirement) { + if (!$this->isHierarchicalProperty($flatProperty)) { $properties[] = $flatProperty; continue; } + /** @var AdmissionRequirement|Degree $flatProperty */ $sequence = [$flatProperty]; $parent = $flatProperty->parent(); @@ -395,15 +397,11 @@ private function extendPropertiesWithParents(array $flatProperties): array return $properties; } - private function retrieveFirstLevelTerm(Degree|AdmissionRequirement $structure): Degree|AdmissionRequirement - { - $parent = $structure->parent(); - while ($parent) { - $structure = $parent; - $parent = $structure->parent(); - } + private function isHierarchicalProperty( + MultilingualString|MultilingualLink|AdmissionRequirement|Degree $flatProperty + ): bool { - return $structure; + return $flatProperty instanceof Degree || $flatProperty instanceof AdmissionRequirement; } private function createTerm(TermData $termData): ?int diff --git a/src/Infrastructure/Search/TermData.php b/src/Infrastructure/Search/TermData.php index fa2dcea..c11bbec 100644 --- a/src/Infrastructure/Search/TermData.php +++ b/src/Infrastructure/Search/TermData.php @@ -50,7 +50,6 @@ public function slug(): string public function termId(): int { - return $this->termId; }