【发布时间】:2021-03-19 15:57:15
【问题描述】:
我使用 api 平台,GET 和 POST 工作正常,我需要在我的实体中修补“isFinished”但我有一个错误: 请求未捕获的 PHP 异常 Symfony\Component\Serializer\Exception\NotEncodableValueException: "语法错误"
你认为我的实体有错误的配置吗? 谢谢你的帮助。
/**
* @ApiResource()
* @ORM\Entity(repositoryClass=CurrentJourneyRepository::class)
*
* @ApiResource(
* collectionOperations={
* "get",
* "post"={"access_control"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')"},
* "patch"
* },
* itemOperations={
* "get",
* "patch",
* "put",
* "delete"={"security"="is_granted('ROLE_ADMIN')"}
* },
* normalizationContext={"groups"={"journey:read"}},
* denormalizationContext={"groups"={"journey:write"}},
*
*
* )
* @ApiFilter(SearchFilter::class, properties={"user","isFinished","treasureWay"})
*/
class CurrentJourney
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"journey:read"})
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"journey:read", "journey:write"})
*/
private $try;
/**
* // * @ORM\ManyToOne(targetEntity=User::class, inversedBy="currentJourneys")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="waypoints")
*/
private $user;
/**
* // * @ORM\ManyToOne(targetEntity=Waypoint::class, inversedBy="currentJourneys")
* @ORM\ManyToOne(targetEntity=Waypoint::class, inversedBy="users")
*/
private $waypoint;
/**
* @ORM\Column(type="integer",options={"default":"0"}) // integer: 0=abandonned ,1= in progress, 2= finished
* @Groups({"journey:read", "journey:write"})
*/
private $isFinished;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=TreasureWay::class, inversedBy="currentJourneys")
*/
private $treasureWay;
【问题讨论】:
标签: php api symfony api-platform.com