symfony 3 프로젝트가 있습니다. 나는 2 개의 날짜를 포함하여 몇몇 정보를 배치하는 것을 시도하고있다.boolean에 멤버 함수 format()을 호출합니까?
/**
* @Route("/LegoPieces")
* @METHOD("POST")
* @View()
*
* @Annotations\QueryParam(
* name="piece", nullable=false, description="piece"
*)
* @Annotations\QueryParam(
* name="type", nullable=false, description="type"
*)
* @Annotations\QueryParam(
* name="startDate", nullable=false, description="Start Date YYYY-MM-DD HH:MM:SS (Should be in the future)"
*)
* @Annotations\QueryParam(
* name="endDate", nullable=false, description="End Date YYYY-MM-DD HH:MM:SS (Should be no more than 3 weeks in the future)"
*)
*/
public function postAction(ParamFetcherInterface $paramFetcher)
{
$piece = $paramFetcher->get('piece');
$type = $paramFetcher->get('type');
$start = $paramFetcher->get('startDate');
$end = $paramFetcher->get('endDate');
$startDate = DateTime::createFromFormat(' Y-m-d H:i:s', $start);
var_dump($startDate);
$endDate = DateTime::createFromFormat(' Y-m-d H:i:s', $end);
$em = $this->getDoctrine()->getManager('default');
$data = new LegoPieces();
$data->setPiece($piece);
$data->setType($type);
$data->setStartDate($startDate);
$data->setEndDate($endDate);
$em->persist($data);
$em->flush();
return new JsonResponse("LegoPieces Added Successfully", 200);
}
세터는 다음과 같이 :
"message": "Call to a member function format() on boolean",
"class": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
I :
/**
* Set startDate
*
* @param \DateTime $startDate
*
* @return LegoPiece
*/
public function setStartDate($startDate)
{
$this->startDate = $startDate;
return $this;
}
그러나 때마다 나는 다음과 같은 오류 메시지를받을 데이터를 게시하려고하는 방법은 다음과 같습니다 모든 것을 시도했지만 아무 것도 작동하지 않습니다! 도와 주셔서 감사합니다!
게시 한 코드 어디서나 'format()'을 (를) 호출 할 필요가 없습니다. 오류가 발생한 곳이 확실합니까? – Barmar