我想存储一些物品,我通过我的参数但是setter没有工作
我的实体看起来像这样:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JMS\DiExtraBundle\Annotation\Inject;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* Project
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="AppBundle\Entity\ProjectRepository")
*/
class Project
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"Project"})
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=45)
* @Groups({"Project"})
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Project", cascade={"remove"})
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
* @Groups({"Project"})
*/
private $parent;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Status")
* @ORM\JoinColumn(nullable=true)
* @Groups({"Project"})
*/
private $status;
我的service.yml:
resource.project.search_filter:
parent: "api.doctrine.orm.search_filter"
arguments: [ { id: "exact", name: "partial", parent: ~ } ]
resource.project.order_filter:
parent: "api.doctrine.orm.order_filter"
arguments: [ { "id": ~, "name": ~ } ]
resource.project:
parent: "api.resource"
arguments: [ "AppBundle\\Entity\\Project" ]
calls:
- method: initNormalizationContext
arguments: [ { groups: [ Project ] } ]
- method: "initFilters"
arguments: [ [ "@resource.project.search_filter", "@resource.project.order_filter"] ]
tags: [ { name: "api.resource" } ]
我不了解POST请求的工作原理,因为我的实体属性都没有定义。
它适用于演示实体,但不适用于我的,我是否错过了一些注释?或者我的配置不完整?
答案 0 :(得分:0)
尝试按以下方式传递您的实体:
带一个斜杠
arguments: [ "AppBundle\Entity\Project" ]
或者如果您将实体传递给存储库传递,如下所示。
论点:[" AppBundle:Project" ]
并将以下注释放入您的存储库
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProjectRepository")