Typo3 흐름의 유효성 검사에 문제가 있습니다.Typo3 흐름 유효성 검사 오류
내가 REST에 대한 POST 요청을하고 있는데, 컨트롤러에 대한 조치입니다.
/**
* Create Customer
*
*
* @param int $clientId
* @param string $name
* @param string $phone
* @param string $mail
* @param string $zip
* @param string $city
* @param int countryId
* @return string
*/
public function createAction($clientId, $name, $phone, $mail, $zip, $city, $countryId) {
try{
$this->checkAccessArgs();
$client = $this->clientCustomerRepository->getReference('\Shopbox\API\Domain\Model\Client',$clientId);
$country = $this->clientCustomerRepository->getReference('\Shopbox\API\Domain\Model\Country',$countryId);
$newCustomer = new ClientCustomer();
$newCustomer->setClient($client);
$newCustomer->setCountry($country);
$newCustomer->setName($name);
$newCustomer->setPhone($phone);
$newCustomer->setMail($mail);
$newCustomer->setZip($zip);
$newCustomer->setCity($city);
$newCustomer->setCrdate(time());
$newCustomer->setTstamp(time());
$newCustomer->setDeleted(0);
$newCustomer->setHidden(0);
$customerValidator = $this->validatorResolver->getBaseValidatorConjunction('\Shopbox\API\Domain\Model\ClientCustomer');
$result = $customerValidator->validate($newCustomer);
if($result->hasErrors()){
throw new \Exception($result->getFirstError()->getMessage() ,$result->getFirstError()->getCode());
}
$this->clientCustomerRepository->add($newCustomer);
$this->persistenceManager->persistAll();
$this->response->setStatus(201);
$this->view->setVariablesToRender(array(self::JSON_RESPONSE_ROOT_SINGLE));
$this->view->assign(self::JSON_RESPONSE_ROOT_SINGLE,
array(self::JSON_RESPONSE_ROOT_SINGLE=> $newCustomer)
);
}
catch(\Exception $e){
$this->response->setStatus($e->getCode());
return $this->assignError($e->getMessage());
}
}
이것은 모델에서 유효성을 검사하는 방법입니다.
/**
* @var string
* @Flow\Validate(type="EmailAddress")
*/
protected $mail;
/**
* @var string
* @Flow\Validate(type="StringLength", options={ "minimum"=8, "maximum"=8 })
*/
protected $phone;
오류가 발생했습니다. 나는 액션 함수 내에서 유효성 검사를 넣지 않으면
Fatal error: Call to a member function getMessage() on a non-object in /path_to_project/flow2/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/path_to_Controller.php on line 87
는 내가 확인 메시지가하지만 그것을하지 말아야 할 무엇을 데이터베이스에 저장합니다.