I am trying to write toArray() method in object class. This is class
Collection
class Collection{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="MyMini\CollectionBundle\Entity\CollectionObject", mappedBy="collection", cascade={"all"})
* @ORM\OrderBy({"date_added" = "desc"})
*/
private $collection_objects;
/*getter and setter*/
public function toArray()
{
return [
'id' => $this->getId(),
'name' => $this->name,
'collection_objects' => [
]
];
}
}
How do I get array of collection_objects properties, if type of collection_objects is \Doctrine\Common\Collections\Collection