0
votes

I have one entity that won't serialize with JMS Serializer. It throws no errors just a blank screen. If I expose this entity in any of it's related entities it responds with a blank page. I've been poking at this for over a day and it's become quite frustrating. What would keep an entity from being serialized JMS Serializer? Here's a snippet of the entity. I can provide any requested material to anyone willing to help me out here.

<?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;

//.....
1

1 Answers

1
votes

Try first to expose only your id to check if you have any response, then if you have no more error, I advise you to follow the documentation to check your configuration: http://jmsyst.com/bundles/JMSSerializerBundle