protected function applyValues(EmbeddedEntityEventInterface $event) { if (!is_callable([$event, 'getData'])) { throw new RuntimeError('Event instance is not support due to lack of a getData method.'); } $this->setValues($event->getData()); if (!$this->isValid()) { foreach ($this->getValidationResults() as $validation_result) { foreach ($validation_result->getViolatedRules() as $violated_rule) { foreach ($violated_rule->getIncidents() as $incident) { $errors[] = PHP_EOL . $validation_result->getSUbject()->getName() . ' - ' . $violated_rule->getName() . ' > ' . $incident->getName() . ', params: ' . var_export($incident->getParameters(), true); } } } error_log(sprintf("Corrupt event data given to %s through event %s.\nErrors:%s", $this->getType()->getPrefix(), $event->getType(), implode(PHP_EOL, $errors))); } $embedded_entity_events = new EmbeddedEntityEventList(); foreach ($event->getEmbeddedEntityEvents() as $embedded_event) { $embedded_entity_events->push($this->applyEmbeddedEntityEvent($embedded_event)); } $source_event = $event; $recorded_changes = $this->getRecordedChanges(); if (!empty($recorded_changes)) { $source_event = $event->createCopyWith(['data' => $recorded_changes, 'embedded_entity_events' => $embedded_entity_events]); } return $source_event; }