# |
Jun 29th 2017, 13:40 |
neon1024 |
No problem, hope you figure it out :slightly_smiling_face: |
# |
Jun 29th 2017, 13:40 |
neon1024 |
https://github.com/cakephp/cakephp/blob/master/src/Routing/Middleware/RoutingMiddleware.php#L48 |
# |
Jun 29th 2017, 13:39 |
glanceded |
Wow, thanks a lot. Never thought about it. I will first try in my routes.php. If the request object isn't available, I will go with a middleware, since for now I don't have hundreds of routes. Thanks again for your time |
# |
Jun 29th 2017, 13:38 |
neon1024 |
So it stands to reason that it should |
# |
Jun 29th 2017, 13:38 |
neon1024 |
Well the routing needs to read the request to know where to route the request to right? ;) |
# |
Jun 29th 2017, 13:37 |
glanceded |
even in routes.php? |
# |
Jun 29th 2017, 13:37 |
glanceded |
the $this->request object is available global? |
# |
Jun 29th 2017, 13:37 |
neon1024 |
Then if that didn’t work out, I might refactor and try with a middleware |
# |
Jun 29th 2017, 13:37 |
neon1024 |
Personally I’d start by checking the request in the routing, if that’s possible, and building my routing around that |
# |
Jun 29th 2017, 13:36 |
neon1024 |
Perhaps Middleware is too soon in the stack |
# |
Jun 29th 2017, 13:35 |
neon1024 |
Although I think in your application, anywhere you have access to the request, you should be able to get the domain with `$this->request->getUri()` |
# |
Jun 29th 2017, 13:35 |
neon1024 |
Well your Application.php has `->add(new RoutingMiddleware())` so you could pass the domain into the routing middleware perhaps, or roll your own, which then could pass the domain into the routing, perhaps as a parameter |
# |
Jun 29th 2017, 13:31 |
glanceded |
Or how to load the correct set of rules? |
# |
Jun 29th 2017, 13:31 |
glanceded |
@neon1024 Thanks for your answer. Yes, never thought at middlewares. So I create a middleware, I check the getHost() [domain]. But how to change the routes? |
# |
Jun 29th 2017, 13:29 |
neon1024 |
@josexato Well I just check it `if (!empty($this->_properties['association']) {` |
# |
Jun 29th 2017, 13:28 |
josexato |
@neon1024 thanks, I'll do some more tests because the child entity is contained when I serialize, can you please suggest me how can I check that the association exist or how can I recalculate again after query and before serialize? |
# |
Jun 29th 2017, 13:28 |
neon1024 |
But if you’re using PSR7, the domain should be in the request, which you could use in your application |
# |
Jun 29th 2017, 13:27 |
neon1024 |
@glanceded That sounds to me like it could be a good case for middleware |
# |
Jun 29th 2017, 13:24 |
glanceded |
What I mean. Same application. Three different domains. Three different routes. |
# |
Jun 29th 2017, 13:23 |
glanceded |
I need to make the routes depend on the domain. Is there a Cake way to achive this? |
# |
Jun 29th 2017, 13:23 |
glanceded |
Hi guys. I'm facing a problem and I don't know how to manage it. |
# |
Jun 29th 2017, 13:17 |
neon1024 |
@josexato Yes you can, but the associated entity will need to be contained when getting the parent entity, then you can access it as you would any other property in your virtual field method. You might want to check, inside the virtual property method, to ensure the association exists before you try and use it though, to prevent errors |
# |
Jun 29th 2017, 13:15 |
josexato |
I'm using virtual variables now, but when I want to create a virtual variable based on a "sub-entity" attribute it say it null |
# |
Jun 29th 2017, 13:14 |
josexato |
good morning, one question is it possible to get a virtual variable from an entity to do something like $article->authorname ? |
# |
Jun 29th 2017, 12:58 |
jarard |
params were wrong :) |
# |
Jun 29th 2017, 12:54 |
jarard |
and this beforeFind() must be an instance of Cake\ORM\Query :) |
# |
Jun 29th 2017, 12:50 |
cake-novice |
Admad if you can also ans me.. :) please |
# |
Jun 29th 2017, 12:50 |
cake-novice |
hmic, if you are aroun, can you ans " hmic, one thing i applied HABTM and can see raw mysql query . its like " ON (`LeadSalePersons`.`lead_id` IN (4228, 4229, 4230, 4231, 4232, 4233....and so on......) ; " |
# |
Jun 29th 2017, 12:39 |
jarard |
use Cake\ORM\Query; at the top of my PropertiesTable |
# |
Jun 29th 2017, 12:39 |
jarard |
is that Cake\ORM\Table; |
# |
Jun 29th 2017, 12:36 |
admad |
you forgot to add "use" statment |
# |
Jun 29th 2017, 12:35 |
jarard |
have I set my query up wrong? |
# |
Jun 29th 2017, 12:34 |
jarard |
I'm getting beforeFind() must be an instance of Cake\ORM\Query, |
# |
Jun 29th 2017, 12:34 |
jarard |
I'm trying to add an active=1 condition to my beforeFind: https://gist.github.com/spacebiscuit/87cf19c79215b753e054c9f1b2bc7f23 |
# |
Jun 29th 2017, 12:33 |
cake-novice |
now its not a Cakephp 2 question :P |
# |
Jun 29th 2017, 12:32 |
cake-novice |
is this HABTM will give me ? |
# |
Jun 29th 2017, 12:32 |
cake-novice |
hmic, one thing i applied HABTM and can see raw mysql query . its like " ON (`LeadSalePersons`.`lead_id` IN (4228, 4229, 4230, 4231, 4232, 4233....and so on......) ; |
# |
Jun 29th 2017, 12:29 |
cake-novice |
enjoy |
# |
Jun 29th 2017, 12:28 |
hmic |
thanks for the props, but i might only be the chan troll := |
# |
Jun 29th 2017, 12:27 |
cake-novice |
*than |
# |
Jun 29th 2017, 12:27 |
cake-novice |
you are expert then me :D |