/** * @param EntityManagerInterface $manager * @param string $owningSideClassName * @param string $property * @return Report */ public function validate(EntityManagerInterface $manager, $owningSideClassName, $property) { $this->manager = $manager; $this->owningSideClassName = $owningSideClassName; $this->owningSideProperty = $property; $this->report = new Report(); $this->validationReport = new ValidationReport(); $success = true; try { $this->assertIsManyToOne($manager, $owningSideClassName, $property)->defineInverseSideFields($manager, $owningSideClassName, $property)->defineMethodNames()->doValidate(); } catch (ReportException $e) { $success = false; } catch (\Exception $e) { $success = false; $errorReport = new ErrorReport($e->getMessage()); $errorReport->addCodeLinePreview($e->getFile(), $e->getLine()); $this->getReport()->addError($errorReport); } if ($success) { $this->getReport()->addValidation($this->getValidationReport()); } return $this->getReport(); }
/** * @param NotNullConstraintViolationException $exception * @throws ReportException */ protected function throwExceptionOccuredWhileRemovingRightEntity(NotNullConstraintViolationException $exception) { $message = get_class($exception) . ' occurend while removing ' . $this->rightEntityClass . '.'; $errorReport = new ErrorReport($message); $help = 'You have to set "orphanRemoval: true" on your mapping, '; $help .= 'or explicitly call ' . $this->managerClass . '::remove().'; $errorReport->addHelp($help); $errorReport->addError($exception->getMessage()); $errorReport->addCodeLinePreview($exception->getFile(), $exception->getLine()); $errorReport->addMethodCode($this->leftEntity, $this->leftEntityRemover); throw new ReportException($this->getReport(), $errorReport); }