File tree Expand file tree Collapse file tree
public/modules/custom/helfi_kasko_content
src/Plugin/search_api/processor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ class AdditionalFilters extends ProcessorPluginBase {
2828
2929 use SupportsUnitIndexTrait;
3030
31+ const ENGLISH_EDUCATION_TERM_IDS = [149 , 150 ];
32+
3133 /**
3234 * {@inheritdoc}
3335 */
@@ -65,6 +67,7 @@ public function addFieldValues(ItemInterface $item): void {
6567 'grades_7_9 ' => UnitCategoryUtility::entityHasCategory ($ object , UnitCategoryUtility::GRADES_7_9 ),
6668 'finnish_education ' => UnitCategoryUtility::entityHasCategory ($ object , UnitCategoryUtility::FINNISH_BASIC_EDUCATION ),
6769 'swedish_education ' => UnitCategoryUtility::entityHasCategory ($ object , UnitCategoryUtility::SWEDISH_BASIC_EDUCATION ),
70+ 'english_education ' => $ this ->hasEnglishEducation ($ object ),
6871 ];
6972
7073 $ itemFields = $ item ->getFields ();
@@ -75,4 +78,25 @@ public function addFieldValues(ItemInterface $item): void {
7578 }
7679 }
7780
81+ /**
82+ * Check if entity has English education category.
83+ *
84+ * @param \Drupal\helfi_tpr\Entity\TprEntityBase $entity
85+ * The TPR entity.
86+ *
87+ * @return bool
88+ * TRUE if entity has English education category, FALSE otherwise.
89+ */
90+ private function hasEnglishEducation (TprEntityBase $ entity ): bool {
91+ if (!$ entity ->hasField ('ontologyword_ids ' )) {
92+ return FALSE ;
93+ }
94+
95+ foreach ($ entity ->get ('ontologyword_ids ' )->getValue () as $ term ) {
96+ if (in_array ($ term ['value ' ], self ::ENGLISH_EDUCATION_TERM_IDS )) {
97+ return TRUE ;
98+ }
99+ }
100+ return FALSE ;
101+ }
78102}
Original file line number Diff line number Diff line change @@ -66,10 +66,6 @@ msgctxt "TPR Ontologyword details schools"
6666msgid "Weighted curriculum education starting in 7th grade"
6767msgstr "7. luokalta alkava painotettu opetus"
6868
69- msgctxt "TPR Ontologyword details schools"
70- msgid "Teaching in English"
71- msgstr "Englanninkielinen opetus"
72-
7369msgctxt "TPR Ontologyword details schools"
7470msgid "Finnish-English"
7571msgstr "suomi-englanti"
Original file line number Diff line number Diff line change @@ -66,10 +66,6 @@ msgctxt "TPR Ontologyword details schools"
6666msgid "Weighted curriculum education starting in 7th grade"
6767msgstr "Intensifierad undervisning som börjar i åk 7"
6868
69- msgctxt "TPR Ontologyword details schools"
70- msgid "Teaching in English"
71- msgstr "Undervisning på engelska"
72-
7369msgctxt "TPR Ontologyword details schools"
7470msgid "Finnish-English"
7571msgstr "finska-engelska"
You can’t perform that action at this time.
0 commit comments