# |
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" |
# |
May 26th 2016, 09:08 |
birdy247 |
in my listener |
# |
May 26th 2016, 09:06 |
birdy247 |
@neon1024: I cant seem to get anything from $event->result |
# |
May 26th 2016, 09:03 |
neon1024 |
I don't know / didn't look to see if there was an irc equivalent |
# |
May 26th 2016, 09:03 |
neon1024 |
The cool kids here are doing advanced workshops in the #cakefest channel in slack |
# |
May 26th 2016, 09:03 |
neon1024 |
Well I have an account through php south coast conference green room from when I was speaking |
# |
May 26th 2016, 09:03 |
birdy247 |
what do you think |
# |
May 26th 2016, 09:03 |
birdy247 |
@neon1024: why the use of slack :slightly_smiling_face: |
# |
May 26th 2016, 09:00 |
birdy247 |
I will try |
# |
May 26th 2016, 09:00 |
birdy247 |
or perhaps $result = $event; return $result |