I have some weird things going on and I was wondering whether they are PHP or Symfony related. Basically, from my form, an ajax request is made and the form data posted to my controller.
Now I need to do some work with the entity that has just been persisted to the database, so to get this to where it needs to go, I have an EventListener and I do
protected $alertEntity;
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof AvailabilityAlert) {
$this->alertEntity = $entity;
}
}
public function postFlush(PostFlushEventArgs $args)
{
$this->api_service->addFlightsAction($this->alertEntity);
}
So I get the entity in postPersist, and then pass it to where it needs to go in the postFlush.
This is all fine, no problems here. The weird part is this
public function addFlightsAction($alert){
print_r($alert);
}
If I have the above in a print_r, it goes on forever until it eventually gives the error allocation size overflow.
If I do the above in a var_dump, it prints out the alert for me, but its in an unreadable format e.g. (short extract)
<pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Ontro\AlertBundle\Entity\AvailabilityAlert</i>)[<i>284</i>]
<i>private</i> 'id' <font color='#888a85'>=></font> <small>int</small> <font color='#4e9a06'>39</font>
<i>private</i> 'searchCommand' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'A20APRLONLAX'</font> <i>(length=12)</i>
<i>private</i> 'isConnecting' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'no'</font> <i>(length=2)</i>
<i>private</i> 'lastUpdated' <font color='#888a85'>=></font>
<b>object</b>(<i>DateTime</i>)[<i>288</i>]
<i>public</i> 'date' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'2015-02-19 10:54:54'</font> <i>(length=19)</i>
<i>public</i> 'timezone_type' <font color='#888a85'>=></font> <small>int</small> <font color='#4e9a06'>3</font>
<i>public</i> 'timezone' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'Europe/London'</font> <i>(length=13)</i>
<i>private</i> 'isDeleted' <font color='#888a85'>=></font> <small>int</small> <font color='#4e9a06'>0</font>
<i>private</i> 'alertStatus' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'Active'</font> <i>(length=6)</i>
<i>private</i> 'bookingClass' <font color='#888a85'>=></font>
<b>object</b>(<i>Doctrine\ORM\PersistentCollection</i>)[<i>372</i>]
<i>private</i> 'snapshot' <font color='#888a85'>=></font>
So why would it be doing this? Is there any way I can print it out nicely so I can see it? I dont mind the above output as long as it got rid of all the html tags.
Thanks