/** * @throws ReportException */ protected function throwInverseSideDefaultGetterMustReturnCollection() { $message = $this->getInverseSideClassName() . '::' . $this->getInverseSideGetter() . '()'; $message .= ' must return an instance of ' . Collection::class; $errorReport = new ErrorReport($message); $helpCollection = 'You should call $this->$' . $this->getInverseSideProperty(); $helpCollection .= ' = new ' . ArrayCollection::class . '() in '; $helpCollection .= $this->getInverseSideClassName() . '::__construct().'; $errorReport->addHelp($helpCollection); $helpReturn = $this->getInverseSideClassName() . '::' . $this->getInverseSideGetter() . '() should return '; $helpReturn .= $this->getInverseSideClassName() . '::$' . $this->getInverseSideProperty() . '.'; $errorReport->addHelp($helpReturn); $errorReport->addMethodCode($this->getInverseSideClassName(), '__construct'); $errorReport->addMethodCode($this->getInverseSideClassName(), $this->getInverseSideGetter()); throw new ReportException($this->getReport(), $errorReport); }
/** * @param ErrorReport $errorReport * @return $this */ protected function inverseSideAdderAddInverseSideEntityPersistError(ErrorReport $errorReport) { $propertyMetadata = $this->getManager()->getClassMetadata($this->getInverseSideClassName())->associationMappings[$this->getInverseSideProperty()]; if (in_array('persist', $propertyMetadata['cascade']) === false) { $help = 'You have to set "cascade: persist" on your mapping, '; $help .= 'or explicitly call ' . get_class($this->getManager()) . '::persist().'; $errorReport->addHelp($help); } return $this; }
/** * @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); }
/** * @throws ReportException */ protected function inverseSideSetterThrowDoesntSetProperty() { $message = $this->getInverseSideClassName() . '::' . $this->getInverseSideSetter() . '() doest not set '; $message .= $this->getInverseSideClassName() . '::$' . $this->getInverseSideProperty(); $errorReport = new ErrorReport($message); $help = 'This method should call $this->' . $this->getInverseSideClearer() . '(), '; $help .= $this->getInverseSideAdder() . '() for each ' . $this->getOwningSideClassName() . ' passed '; $help .= 'then ' . $this->getInverseSideProperty() . '->clear() to reset Collection keys.'; $errorReport->addHelp($help); $errorReport->addMethodCode($this->getInverseSideClassName(), $this->getInverseSideSetter()); throw new ReportException($this->getReport(), $errorReport); }
/** * @param string $className * @param string $method * @param array $parameters * @throws ReportException */ protected function throwMethodSignatureIsWrong($className, $method, array $parameters) { $message = $className . '::' . $method . '() signature is wrong.'; $errorReport = new ErrorReport($message); $help = $className . '::' . $method . '() must have at least this '; $help .= count($parameters) === 1 ? 'parameter: ' : 'parameters: '; $helpParameters = []; foreach ($parameters as $name => $types) { switch (count($types)) { case 0: $helpParameters[] = '$' . $name; break; case 1: $helpParameters[] = $types[0] . ' $' . $name; break; case 2: $helpParameters[] = $types[0] . ' $' . $name . ' = ' . $types[1]; break; } } $help .= implode(', ', $helpParameters) . '.'; $errorReport->addHelp($help); $errorReport->addMethodCode($className, $method); throw new ReportException($this->getReport(), $errorReport); }