function onFlush(OnFlushEventArgs $args) { foreach ($this->getEntitiesToValidate($args->getEntityManager()) as $entity) { if (count($violations = $this->validator->validate($entity))) { $message = "Invalid entity {$this->objectToString($entity)}:\n"; $message .= implode("\n", Collection::map($violations, function ($violation) { return "- {$violation->getPropertyPath()}: {$violation->getMessage()}"; })); throw new \InvalidArgumentException($message); } } }
private function dictionaryToString($dictionary) { return String::indent(Yaml::dump(Collection::toArray($dictionary), 1)); }
private function getWorstRecord(array $records) { return Collection::wrap($records)->sort(array('getValue' => function ($record) { return -$record['level']; }, 'sorting' => SORT_NUMERIC))->first(); }
private function isAMissingIgnoredFile(GetResponseForExceptionEvent $event) { return $event->getException() instanceof NotFoundHttpException && Collection::any($this->ignoredFilesRegexes, function ($regex) use($event) { return preg_match($regex, $event->getRequest()->getPathInfo()); }); }