Tuesday, August 26, 2014

Re: CakePHP 3.0 - Get data from event subject

Thanks $event->data does the trick, $entity as second argument does not appear with Id hydrated.

Cheers
Tarique


On Tue, Aug 26, 2014 at 6:08 PM, José Lorenzo <jose.zap@gmail.com> wrote:
You probably want to use $event->data instead. Also, remember that listeners get the data as arguments, so if you want the entity Id add the $entity as the second argument of the function.


On Tuesday, August 26, 2014 2:00:49 PM UTC+2, Dr. Tarique Sani wrote:
Trying something very simple here 

In my Listener I am trying to get 

$event->subject()->id

but I keep getting  Table "App\Model\Table\PostsTable" is not associated with "id"

What am I missing here?

Tarique


--
=============================================================
Hire a CakePHP dev team : http://sanisoft.com
=============================================================

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
=============================================================
Hire a CakePHP dev team : http://sanisoft.com
=============================================================

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: