DenormalizerInterface denormalize Cache key包含保留字符{}()/ \ @:具有关联的实体

时间:2018-04-17 11:14:04

标签: php symfony caching doctrine denormalization

尝试将数组转换为具有关联的对象时,我有此异常。 在Contact实体中使用公司实体构建。

异常

  

缓存键“pAppBundle \ Entity \ Companyid”包含保留字符{}()/ \ @:

控制器:

class ContactController extends AbstractController
{
    public function newAction(Request $request, Company $company, DenormalizerInterface $denormalizer)
    {
        $data = $request->get('contact');

        $data['company'] = $company;

        $denormalizer->denormalize($data, Contact::class);
    }
}

实体公司:

class Company {
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    /**
     * @ORM\Column(type="string", name="name")
     */
    private $name;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Contact", mappedBy="company", cascade={"ALL"})
     */
    private $contacts;
}

实体联系:

class Contact {
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    /**
     * @ORM\Column(type="string", name="text")
     */
    private $text;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Company", inversedBy="contacts")
     * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
     */
    private $company;

    public function __construct(Company $company)
    {
        $this->company = $company;
        $this->files = new \Doctrine\Common\Collections\ArrayCollection();
    }
}

0 个答案:

没有答案