我有一个不会使用JMS Serializer序列化的实体。它只会在空白屏幕上引发错误。如果我在任何相关实体中公开该实体,它将以空白页面进行响应。我一直在戳这一天超过一天,这变得非常令人沮丧。什么会阻止实体序列化JMS Serializer?这是实体的片段。我可以向愿意帮助我的人提供任何要求的材料。
<?php
namespace TMG\Api\ApiBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* Property
*
* @ORM\Table(name="Properties")
* @ORM\Entity(repositoryClass="TMG\Api\ApiBundle\Entity\Repository\PropertyRepository")
* @ORM\HasLifecycleCallbacks()
*
* @Serializer\ExclusionPolicy("all")
*/
class Property
{
public function __construct()
{
$this->featuredAmenities = [];
$this->users = new ArrayCollection();
$this->amenities = new ArrayCollection();
$this->contracts = new ArrayCollection();
$this->rates = new ArrayCollection();
$this->photos = new ArrayCollection();
$this->tollFrees = new ArrayCollection();
$this->favorites = new ArrayCollection();
}
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Expose
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="hash", type="string", length=8)
*
* @Serializer\Expose
*/
private $hash;
/**
* @var string
*
* @ORM\Column(name="ax_number", type="string", length=40, unique=true)
*
* @Serializer\Expose
*/
private $axNumber;
/**
* @var string
*
* @ORM\Column(name="property_number", type="string", length=40, nullable=true)
*
* @Serializer\Expose
*/
private $propertyNumber;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*
* @Serializer\Expose
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
*
* @Serializer\Expose
*/
private $contactName;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*
* @Serializer\Expose
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
*
* @Serializer\Expose
*/
private $fax;
//.....
答案 0 :(得分:1)
首先尝试公开您的ID以检查您是否有任何回复,如果您没有更多错误,我建议您按照文档检查您的配置:http://jmsyst.com/bundles/JMSSerializerBundle