# |
Oct 18th 2019, 16:16 |
neothermic |
(I'm aware that there's a middelware for this, but that one needs cake 3.6 and PHP 7.1+... and yeah.) |
# |
Oct 18th 2019, 16:16 |
steinkel |
there's also a plugin for that I've used time ago... |
# |
Oct 18th 2019, 16:16 |
steinkel |
middleware after routing middleware would work |
# |
Oct 18th 2019, 16:16 |
steinkel |
because AppController happens now much deeper in the stack, Middleware sound like a good place for non cake stuff happening in the request |
# |
Oct 18th 2019, 16:16 |
neothermic |
I need to construct enough of a path to be able to name the transaction for newrelic |
# |
Oct 18th 2019, 16:15 |
noel |
Hi all |
# |
Oct 18th 2019, 16:14 |
steinkel |
what do you need to inject? |
# |
Oct 18th 2019, 16:14 |
daniel.upshaw |
Niiiice |
# |
Oct 18th 2019, 16:14 |
neothermic |
been using cake since 1.3 :) |
# |
Oct 18th 2019, 16:14 |
daniel.upshaw |
Lol I wish I could say that I've been a Cake dev that long.. PHP since v4, but I've only discovered the magic of Cake within the past year or so |
# |
Oct 18th 2019, 16:13 |
neothermic |
very dirty |
# |
Oct 18th 2019, 16:13 |
neothermic |
in 2.x I went into invokeAction() in Controller.php :) |
# |
Oct 18th 2019, 16:13 |
daniel.upshaw |
If you need the request object, seems like you found a good way to do it |
# |
Oct 18th 2019, 16:12 |
neothermic |
in cake2, I hijacked core code |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Ah |
# |
Oct 18th 2019, 16:12 |
neothermic |
so it can't be too high up |
# |
Oct 18th 2019, 16:12 |
neothermic |
I need the request object to be a thing :slightly_smiling_face: |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Oh, and `bootstrap()` in `Application.php` |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
`initialize()` seems a pretty clean way |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Ah there's also `bootstrap.php` |
# |
Oct 18th 2019, 16:12 |
neothermic |
if I find edge cases I'll look into a middleware |
# |
Oct 18th 2019, 16:11 |
neothermic |
I'm hoping that init is high enough for what I'm doing |
# |
Oct 18th 2019, 16:11 |
steinkel |
@neothermic webroot/index is the first one, the I would go to Application, but my first spot would be a Middleware added top of your stack |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
That sounds exactly right @neothermic |
# |
Oct 18th 2019, 16:10 |
neothermic |
went with initialize() in AppController in the end :slightly_smiling_face: |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
All 3 are params, yes |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
@ricksaccous it's routed to a custom class, e.g. `$routes->connect('/:article-type/:id/:slug', [], ['routeClass' => 'CustomRoute'])` |
# |
Oct 18th 2019, 16:01 |
neothermic |
I suppose I could be devilish and alter index.php in the webroot, but that feels dirty even though it's not in /vendor |
# |
Oct 18th 2019, 16:00 |
neothermic |
Hmm, what's the earliest function in the request stack that I can hook into without altering core in cake3? :slightly_smiling_face: |
# |
Oct 18th 2019, 15:33 |
ricksaccous |
you might have to put regular expression patterns on all three article-type id and slug |
# |
Oct 18th 2019, 15:32 |
ricksaccous |
you don't have the "action" in there? |
# |
Oct 18th 2019, 15:32 |
ricksaccous |
so are all three params? |
# |
Oct 18th 2019, 15:31 |
ricksaccous |
i see |
# |
Oct 18th 2019, 15:30 |
daniel.upshaw |
If I change it to `'/data/:id/:slug'` it does match though |
# |
Oct 18th 2019, 15:30 |
ricksaccous |
oh |
# |
Oct 18th 2019, 15:30 |
ricksaccous |
that won't match cause it has 3 params |
# |
Oct 18th 2019, 15:30 |
daniel.upshaw |
`'/:article-type/:id/:slug'` is the attempted |
# |
Oct 18th 2019, 15:30 |
daniel.upshaw |
`/data/37/article-title` would be the URL |
# |
Oct 18th 2019, 15:29 |
ricksaccous |
or are you saying you get no matches unless the first part is static |
# |
Oct 18th 2019, 15:29 |
ricksaccous |
out of curiosity |
# |
Oct 18th 2019, 15:29 |
ricksaccous |
what doesn't match |