DateTime::__construct() expects parameter 1 to be string, array given
thorau opened this issue · 0 comments
thorau commented
My entity has:
/**
* @var \DateTime $createdAt
* @ApiProperty
* @Groups("read")
*/
private $createdAt;
/**
* @var \DateTime $updatedAt
* @ApiProperty
* @Groups("read")
*/
private $updatedAt;
/**
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
}
/**
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
}
I added to services.yaml:
class: 'Symfony\Component\Serializer\Serializer'
arguments:
- ['@serializer.normalizer.datetime', '@dunglas_doctrine_json_odm.normalizer.object']
- ['@serializer.encoder.json']
public: true
But I get the error message:
DateTime::__construct() expects parameter 1 to be string, array given
How to fix this?