getData(); if ($this->mustUpdateItemRelation($data)) { $this->getItemRelationUpdateService() ->updateByTargetId($event->getItemUri(), $this->getAggregatedMediaIds($data)); } } private function mustUpdateItemRelation(array $data): bool { return array_key_exists(self::INCLUDE_ELEMENT_REFERENCES_KEY, $data) || array_key_exists(self::OBJECT_ELEMENT_REFERENCES_KEY, $data) || array_key_exists(self::IMG_ELEMENT_REFERENCES_KEY, $data); } private function getAggregatedMediaIds(array $data): array { return $this->getIdDiscoverService()->discover( array_merge( $data[self::INCLUDE_ELEMENT_REFERENCES_KEY] ?? [], $data[self::OBJECT_ELEMENT_REFERENCES_KEY] ?? [], $data[self::IMG_ELEMENT_REFERENCES_KEY] ?? [] ) ); } private function getItemRelationUpdateService(): ItemRelationUpdateService { return $this->getServiceLocator()->get(ItemRelationUpdateService::class); } private function getIdDiscoverService(): IdDiscoverService { return $this->getServiceLocator()->get(IdDiscoverService::class); } }