# |
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 |
# |
Oct 18th 2019, 15:29 |
ricksaccous |
what url are you hitting that matches |
# |
Oct 18th 2019, 15:28 |
daniel.upshaw |
Maybe it needs `setPatterns()` in addition to `setPass()`, I'll check that |
# |
Oct 18th 2019, 15:28 |
daniel.upshaw |
But yeah, the structure of the current URL does match, and if I change the first part to static, it'll catch it |
# |
Oct 18th 2019, 15:27 |
daniel.upshaw |
They are tricky |
# |
Oct 18th 2019, 15:27 |
ricksaccous |
i am kind of bad with routes tbh |
# |
Oct 18th 2019, 15:27 |
ricksaccous |
also if you have anything other than /somepart/otherpart it won't match ie /somepart/secondpart/third or /somepart/secondpart? though actually i'm not sure how get requests are handled i think they might actually still match |
# |
Oct 18th 2019, 15:26 |
ricksaccous |
pretty sure it is, but you would still need the :id for it to match |
# |
Oct 18th 2019, 15:25 |
daniel.upshaw |
Just seems that using a param as the `/:first-path-part` isn't supported for custom routes, which seems really strange |
# |
Oct 18th 2019, 15:24 |
ricksaccous |
oh |
# |
Oct 18th 2019, 15:24 |
daniel.upshaw |
Also tried making it first, yep |
# |
Oct 18th 2019, 15:24 |
ricksaccous |
is this the first route? |
# |
Oct 18th 2019, 15:24 |
ricksaccous |
route order matters |
# |
Oct 18th 2019, 15:24 |
daniel.upshaw |
It ought to catch anything that comes in, but it only does if the first path part is static... which is what leads me to believe that it isn't supported otherwise |