# |
Jul 10th 2017, 14:06 |
birdy247 |
Ok |
# |
Jul 10th 2017, 14:06 |
lorenzo |
but when doing what |
# |
Jul 10th 2017, 14:06 |
birdy247 |
It still think it should be static |
# |
Jul 10th 2017, 14:04 |
birdy247 |
@lorenzo Error: Fatal Error (1): Using $this when not in object context |
# |
Jul 10th 2017, 14:01 |
lorenzo |
I’m not following… what error do you get when doing what? |
# |
Jul 10th 2017, 13:57 |
birdy247 |
..or if you prefer move that to a function somewhere else you can import and put there as pure config instead of writing a function there.. |
# |
Jul 10th 2017, 13:57 |
birdy247 |
How would I do what you suggested? |
# |
Jul 10th 2017, 13:56 |
birdy247 |
So is this because I am reading it from config? |
# |
Jul 10th 2017, 13:56 |
birdy247 |
$handler = function (...$params) { return TableRegistry::get('Stripes')->webhookHandler(...$params); |
# |
Jul 10th 2017, 13:56 |
birdy247 |
@lorenzo even if I write this directly in the Middleware, it works |
# |
Jul 10th 2017, 13:54 |
birdy247 |
So it must be something to do with my callable |
# |
Jul 10th 2017, 13:54 |
birdy247 |
Its fine |
# |
Jul 10th 2017, 13:54 |
birdy247 |
$Stripes->webhookHandler($data); |
# |
Jul 10th 2017, 13:54 |
birdy247 |
$Stripes = TableRegistry::get('Stripes'); |
# |
Jul 10th 2017, 13:54 |
birdy247 |
If I add this into the Middleware |
# |
Jul 10th 2017, 13:51 |
birdy247 |
it thinks I am calling it statically |
# |
Jul 10th 2017, 13:49 |
birdy247 |
so refernecing $this |
# |
Jul 10th 2017, 13:49 |
birdy247 |
I am trying to dispatch an event from the webhookHandler function |
# |
Jul 10th 2017, 13:49 |
birdy247 |
I get that error |
# |
Jul 10th 2017, 13:49 |
birdy247 |
Using $this when not in object context |
# |
Jul 10th 2017, 13:48 |
lorenzo |
you don’t need to change that |
# |
Jul 10th 2017, 13:48 |
birdy247 |
thats what I was doing |
# |
Jul 10th 2017, 13:47 |
birdy247 |
$callable($events) |
# |
Jul 10th 2017, 13:47 |
lorenzo |
no idea, you were passing a callable there ¯\_(ツ)_/¯ |
# |
Jul 10th 2017, 13:47 |
birdy247 |
and then how would I call it? |
# |
Jul 10th 2017, 13:47 |
lorenzo |
or if you prefer move that to a function somewhere else you can import and put there as pure config instead of writing a function there |
# |
Jul 10th 2017, 13:46 |
lorenzo |
ok, put it there |
# |
Jul 10th 2017, 13:46 |
birdy247 |
I was writing that in a config file |
# |
Jul 10th 2017, 13:46 |
lorenzo |
you put that instead |
# |
Jul 10th 2017, 13:46 |
lorenzo |
wherever you were writing `[StripesTable::class, 'webhookHandler'],` |
# |
Jul 10th 2017, 13:46 |
birdy247 |
@lorenzo where would I put that? |
# |
Jul 10th 2017, 13:45 |
lorenzo |
You should maybe do something like this ```function (...$params) { return TableRegistry::get('Stripes')->webhookHandler(...$params); }``` |
# |
Jul 10th 2017, 13:45 |
spriz |
how do I define log levels when using monolog? :thinking_face: |
# |
Jul 10th 2017, 13:45 |
birdy247 |
Ok |
# |
Jul 10th 2017, 13:44 |
lorenzo |
your method is not static |
# |
Jul 10th 2017, 13:44 |
lorenzo |
`StripesTable::class, 'webhookHandler'],` is the syntax for static methods |
# |
Jul 10th 2017, 13:38 |
birdy247 |
or dispatch events from a static method (is that wrong)? |
# |
Jul 10th 2017, 13:37 |
birdy247 |
Can I keep it dynamic? |
# |
Jul 10th 2017, 13:32 |
birdy247 |
I dispatch events from this method, so not sure if it being static is correct |
# |
Jul 10th 2017, 13:31 |
birdy247 |
I get a strict error saying it needs to be static |
# |
Jul 10th 2017, 13:31 |
birdy247 |
but then when I do $callable($data) |