/** * Creates a new validation error object and adds it to $this->errors * * @param string $message The error message * @param integer $code The error code (a unix timestamp) * @param array $arguments Arguments to be replaced in message * @param string $title title of the error * @return void */ protected function addError($message, $code, array $arguments = array(), $title = '') { if ($this->result !== NULL) { // backwards compatibility before Extbase 1.4.0: we cannot expect the "result" object to be there. $this->result->addError(new \TYPO3\CMS\Extbase\Validation\Error($message, $code, $arguments, $title)); } // the following is @deprecated since Extbase 1.4.0: $this->errors[] = new \TYPO3\CMS\Extbase\Validation\Error($message, $code, $arguments, $title); }
/** * @test */ public function validateAddsErrorForMissingReservation() { $participant = new Person(); $participant->setType(Person::PERSON_TYPE_PARTICIPANT); $expectedResult = new Result(); $expectedError = new Error('Missing reservation.', 1465389725); $expectedResult->addError($expectedError); $this->assertEquals($expectedResult, $this->subject->validate($participant)); }
/** * Add an error with message and code to the property errors * * @param string $propertyName name of the property to add the error to * @param string $message Message to be shwon * @param string $code Error code to identify the error * @return void */ protected function ___addErrorForProperty($propertyName, $message, $code) { if (!$this->result->forProperty($propertyName)->hasErrors()) { /** @var $error \TYPO3\CMS\Extbase\Validation\PropertyError */ $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\PropertyError', $propertyName); $error->addErrors(array($this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', $message, $code))); $this->result->addError($error); } }
/** * Validation process * * @param Mail $mail * @return Result */ public function validate($mail) { $this->emailFieldMarkerArray = GeneralUtility::trimExplode(',', $this->configuration['emailMarker'], true); $this->confirmEmailFieldMarkerArray = GeneralUtility::trimExplode(',', $this->configuration['emailConfirmMarker'], true); $result = new Result(); foreach ($mail->getAnswers() as $answer) { if (in_array($answer->getField()->getMarker(), $this->emailFieldMarkerArray)) { $emailMarker = $answer->getField()->getMarker(); $email = $answer->getValue(); } if (in_array($answer->getField()->getMarker(), $this->confirmEmailFieldMarkerArray)) { $confirmEmailMarker = $answer->getField()->getMarker(); $confirmEmail = $answer->getValue(); } } if ($email && $confirmEmail && $emailMarker && $confirmEmailMarker && $email !== $confirmEmail) { $result->addError(new Error(LocalizationUtility::translate('validation_email_match', 't3ecom'), $confirmEmailMarker)); $result->addError(new Error(LocalizationUtility::translate('validation_email_match', 't3ecom'), $emailMarker)); } return $result; }
/** * Creates a new validation error object and adds it to $this->results * * @param string $message The error message * @param integer $code The error code (a unix timestamp) * @param array $arguments Arguments to be replaced in message * @param string $title title of the error * @return void */ protected function addError($message, $code, array $arguments = array(), $title = '') { $this->result->addError(new \TYPO3\CMS\Extbase\Validation\Error($message, $code, $arguments, $title)); }
protected function addError($msg, $key) { $error = new \TYPO3\CMS\Extbase\Error\Error($msg, $key); $this->messages->addError($error); }