@@ -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,26 @@ 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+ }
102+
78103}
0 commit comments