Skip to content

Commit

Permalink
refactor: remove redundant taxonomy param
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyian committed Dec 26, 2024
1 parent e6b07b0 commit 7d49552
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Infrastructure/Repository/BilingualRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@ final protected function bilingualOption(string $key): MultilingualString
);
}

final protected function bilingualLinkFromTerm(?WP_Term $term, string $taxonomy): MultilingualLink
final protected function bilingualLinkFromTerm(?WP_Term $term): MultilingualLink
{
$parentTerm = $term instanceof WP_Term && $term->parent ? get_term($term->parent, $taxonomy) : null;
$parentTerm = $term instanceof WP_Term && $term->parent ? get_term($term->parent, $term->taxonomy) : null;

return MultilingualLink::new(
$term instanceof WP_Term ? $this->idGenerator->generateTermId($term) : '',
name: $this->bilingualTermName($term),
linkText: $this->bilingualTermMeta($term, MultilingualLink::LINK_TEXT),
linkUrl: $this->bilingualTermMeta($term, MultilingualLink::LINK_URL),
parent: $parentTerm instanceof WP_Term ? $this->bilingualLinkFromTerm($parentTerm, $taxonomy) : null,
parent: $parentTerm instanceof WP_Term ? $this->bilingualLinkFromTerm($parentTerm) : null,
);
}

Expand All @@ -147,7 +147,7 @@ final protected function bilingualTermLinks(WP_Post $post, string $taxonomy): Mu

$links = [];
foreach ($terms as $term) {
$links[] = $this->bilingualLinkFromTerm($term, $taxonomy);
$links[] = $this->bilingualLinkFromTerm($term);
}

return MultilingualLinks::new(...$links);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,18 @@ public function getById(DegreeProgramId $degreeProgramId): DegreeProgram
$post,
BachelorOrTeachingDegreeAdmissionRequirementTaxonomy::KEY,
),
BachelorOrTeachingDegreeAdmissionRequirementTaxonomy::KEY,
),
teachingDegreeHigherSemester: $this->admissionRequirement(
$this->firstTerm(
$post,
TeachingDegreeHigherSemesterAdmissionRequirementTaxonomy::KEY,
),
TeachingDegreeHigherSemesterAdmissionRequirementTaxonomy::KEY,
),
master: $this->admissionRequirement(
$this->firstTerm(
$post,
MasterDegreeAdmissionRequirementTaxonomy::KEY,
),
MasterDegreeAdmissionRequirementTaxonomy::KEY,
),
),
contentRelatedMasterRequirements: $this->bilingualPostMeta(
Expand Down Expand Up @@ -189,13 +186,11 @@ public function getById(DegreeProgramId $degreeProgramId): DegreeProgram
$post,
GermanLanguageSkillsForInternationalStudentsTaxonomy::KEY,
),
GermanLanguageSkillsForInternationalStudentsTaxonomy::KEY,
),
startOfSemester: $this->bilingualLinkFromOption(DegreeProgram::START_OF_SEMESTER),
semesterDates: $this->bilingualLinkFromOption(DegreeProgram::SEMESTER_DATES),
examinationsOffice: $this->bilingualLinkFromTerm(
$this->firstTerm($post, ExaminationsOfficeTaxonomy::KEY),
ExaminationsOfficeTaxonomy::KEY,
),
examinationRegulations: (string) get_post_meta(
$postId,
Expand All @@ -212,7 +207,6 @@ public function getById(DegreeProgramId $degreeProgramId): DegreeProgram
studentAdvice: $this->bilingualLinkFromOption(DegreeProgram::STUDENT_ADVICE),
subjectSpecificAdvice: $this->bilingualLinkFromTerm(
$this->firstTerm($post, SubjectSpecificAdviceTaxonomy::KEY),
SubjectSpecificAdviceTaxonomy::KEY,
),
serviceCenters: $this->bilingualLinkFromOption(DegreeProgram::SERVICE_CENTERS),
infoBrochure: (string) get_post_meta(
Expand Down Expand Up @@ -241,7 +235,6 @@ public function getById(DegreeProgramId $degreeProgramId): DegreeProgram
),
applyNowLink: $this->bilingualLinkFromTerm(
$this->firstTerm($post, ApplyNowLinkTaxonomy::KEY),
ApplyNowLinkTaxonomy::KEY,
),
combinations: $this->idsFromPostMeta($postId, DegreeProgram::COMBINATIONS),
limitedCombinations: $this->idsFromPostMeta(
Expand Down Expand Up @@ -303,7 +296,7 @@ private function degreeFromTerm(WP_Term $term): Degree
);
}

private function admissionRequirement(?WP_Term $term, string $taxonomy): AdmissionRequirement
private function admissionRequirement(?WP_Term $term): AdmissionRequirement
{
if (!$term instanceof WP_Term) {
return AdmissionRequirement::empty();
Expand All @@ -312,8 +305,8 @@ private function admissionRequirement(?WP_Term $term, string $taxonomy): Admissi
$parent = $term->parent ? get_term($term->parent) : null;

return AdmissionRequirement::new(
$this->bilingualLinkFromTerm($term, $taxonomy),
$parent instanceof WP_Term ? $this->admissionRequirement($parent, $taxonomy) : null,
$this->bilingualLinkFromTerm($term),
$parent instanceof WP_Term ? $this->admissionRequirement($parent) : null,
$term->slug
);
}
Expand Down

0 comments on commit 7d49552

Please sign in to comment.