# |
May 26th 2016, 09:27 |
birdy247 |
@neon1024: thanks! |
# |
May 26th 2016, 09:26 |
birdy247 |
got there :slightly_smiling_face: |
# |
May 26th 2016, 09:26 |
birdy247 |
phew |
# |
May 26th 2016, 09:23 |
birdy247 |
so I simply need to return $entities; |
# |
May 26th 2016, 09:23 |
birdy247 |
ok |
# |
May 26th 2016, 09:23 |
neon1024 |
Beyond that, my brain has imploded :( |
# |
May 26th 2016, 09:22 |
neon1024 |
Specifically where $alteredData is set |
# |
May 26th 2016, 09:22 |
neon1024 |
Yep, now read the code above that |
# |
May 26th 2016, 09:21 |
birdy247 |
// Another listener callback public function doSomethingElse($event) { // ... $event->result['order'] = $alteredData; } |
# |
May 26th 2016, 09:21 |
bernat1 |
@birdy247, my guess is that $event->result is an Event object. |
# |
May 26th 2016, 09:21 |
neon1024 |
I agree that the code visually is misleading |
# |
May 26th 2016, 09:20 |
neon1024 |
If you look at the book it is returning the event data array, not the event object |
# |
May 26th 2016, 09:20 |
neon1024 |
Well that's wrong, check the book |
# |
May 26th 2016, 09:19 |
birdy247 |
and i get: Error: Cannot use object of type Cake\Event\Event as array |
# |
May 26th 2016, 09:18 |
birdy247 |
debug($event->result['timetable']); |
# |
May 26th 2016, 09:18 |
birdy247 |
and this is what I am doing after its dispatched |
# |
May 26th 2016, 09:18 |
birdy247 |
that is what I am returning |
# |
May 26th 2016, 09:18 |
birdy247 |
$event->result['timetable'] = $entities; $result = $event; return $result; |
# |
May 26th 2016, 09:18 |
neon1024 |
At least that's how it reads to me |
# |
May 26th 2016, 09:17 |
neon1024 |
Or the callback return ['data'] |
# |
May 26th 2016, 09:17 |
neon1024 |
When it should be $event->result['data'] |
# |
May 26th 2016, 09:17 |
neon1024 |
So the error you see sounds like $event['data'} |
# |
May 26th 2016, 09:16 |
neon1024 |
Event results can be altered either using the event object result property directly or returning the value in the callback itself: |
# |
May 26th 2016, 09:16 |
neon1024 |
I think this is relevant |
# |
May 26th 2016, 09:16 |
birdy247 |
Error: Cannot use object of type Cake\Event\Event as array |
# |
May 26th 2016, 09:13 |
birdy247 |
gd skill |
# |
May 26th 2016, 09:13 |
birdy247 |
:) |
# |
May 26th 2016, 09:13 |
birdy247 |
thats wat I have |
# |
May 26th 2016, 09:13 |
birdy247 |
I meant to write $event->result |
# |
May 26th 2016, 09:13 |
neon1024 |
I call it megatasking! |
# |
May 26th 2016, 09:13 |
birdy247 |
sorry, my bad |
# |
May 26th 2016, 09:13 |
neon1024 |
I'm in a mental muddle because my machine keeps crashing, I'm trying to do updates, upgrade php, talk on here and also update php storm |
# |
May 26th 2016, 09:12 |
neon1024 |
Would be how I'd think it works |
# |
May 26th 2016, 09:12 |
neon1024 |
$event->result // array('foo' => 123) |
# |
May 26th 2016, 09:12 |
birdy247 |
but the book talks about using the result |
# |
May 26th 2016, 09:12 |
neon1024 |
$event->data = ['foo' => $bar]; |
# |
May 26th 2016, 09:12 |
neon1024 |
Yeah $event->result != $event->data |
# |
May 26th 2016, 09:09 |
birdy247 |
after I dispatch, debug($event->data['timetable']); null |
# |
May 26th 2016, 09:08 |
rawroland |
Just learnt something new at Cakefest2016: cowsay |
# |
May 26th 2016, 09:08 |
birdy247 |
return $event; |
# |
May 26th 2016, 09:08 |
birdy247 |
$event->data['timetable'] = "123" |