# |
May 18th 2021, 14:30 |
etibor |
however when i tried to use element insted of layout it was only good for side menu, because the default top menu is the default layout |
# |
May 18th 2021, 14:29 |
etibor |
okey i now i a little more familiar with the concept |
# |
May 18th 2021, 14:24 |
ndm |
You could use subfolders in the default layout folder though? Sure, it's separate from the prefix template subfolders then, but still properly separated and in a place where it makes sense. |
# |
May 18th 2021, 14:22 |
ndm |
You can't just use that anywhere, it's tied to the view's internals. As you noticed, changing the layout path only changes where things point to inside of the default layout folder, more drastic changes can only be applied on view level. |
# |
May 18th 2021, 14:20 |
etibor |
i have just could not figured out how can i use that costumViews's functions |
# |
May 18th 2021, 14:19 |
etibor |
https://github.com/cakephp/cakephp/issues/3907 |
# |
May 18th 2021, 14:19 |
etibor |
the real issue is coming by the setLayyoutPath can not point out the prefixed layout directory path |
# |
May 18th 2021, 14:18 |
etibor |
my problem in short, i have different prefixes for different roles, i have non prefixed Controllers for commonly used function when i navigate to the non prefixed Controller, the page is look for the non prefixed layout directory, and con not change it by set Layout Path in my case layout are difinied two times, first in the prefixed layout directory, secondly by the non prefixed layout directory - this is simple not DRY |
# |
May 18th 2021, 14:02 |
ndm |
Why even in the first place? I don't really know what problem exactly that snippet there is trying to fix, but layouts for prefixes should work out of the box IIRC. |
# |
May 18th 2021, 13:59 |
etibor |
how can i use an element insted of a layout ? |
# |
May 18th 2021, 13:41 |
etibor |
this could solve my issue: https://gist.github.com/TamiasSibiricus/a1010fc95839f79e9e8a however i dont really knows how to use view's function in Controller |
# |
May 18th 2021, 13:40 |
etibor |
with layouts, i have a lot of issues, when i have multiple prefixes |
# |
May 18th 2021, 13:38 |
etibor |
its the first time that i try to work with elements, using insted of layouts |
# |
May 18th 2021, 13:37 |
etibor |
thank you @ndm |
# |
May 18th 2021, 13:32 |
ndm |
@etibor Use `disableAutoLayout()` instead. On 3.x you could also set the layout to `false` instead of an empty string, but that won't work in 4.x anymore. |
# |
May 18th 2021, 13:17 |
etibor |
using : $this->viewBuilder()->setLayout(''); will disable the rest of the template too not just the layout |
# |
May 18th 2021, 13:16 |
etibor |
hello how can i disable the default layout |
# |
May 18th 2021, 11:19 |
neon1024 |
Ah, it is still there. What an odd bug |
# |
May 18th 2021, 11:14 |
neon1024 |
Is the `Model.initialize` event not a thing any more? I can only see DebugKit calling it in my listener |
# |
May 18th 2021, 09:57 |
ndm |
Not necessarily, you can also do a find after using `saveAssociated()`, and then use the query model id for one last separate save that updates the order. |
# |
May 18th 2021, 09:50 |
rightscoreanalysis |
thanks @ndm - so the way to go would be to use seperate saves and then use $this->Model->Id to seed the foreign keys manually? |
# |
May 18th 2021, 09:39 |
ndm |
But even if it were generally possible, it would not be practical with a "to many" association, as the saving logic wouldn't which of the possibly many addresses should be associated with the order. |
# |
May 18th 2021, 09:37 |
ndm |
@rightscoreanalysis That's not possible no, only directly association models can be automatically decorated with a foreign key. |
# |
May 18th 2021, 09:32 |
rightscoreanalysis |
my question about saving back through a relationship better explained here, I am sure those most knowledgeable will know if what I am attempting is possible or not: https://stackoverflow.com/questions/67582761/cakephp-saving-fk-back-through-data-in-a-multiple-relation-structure |
# |
May 18th 2021, 09:21 |
neon1024 |
Thanks for the tips everyone :bow: |
# |
May 18th 2021, 09:21 |
slackebot |
I bet that will fill in my mental gaps :) |
# |
May 18th 2021, 09:21 |
neon1024 |
Oh right that does make sense. The main thing was that we have a custom RoleAuthorize class, which I wanted to keep. So I can refactor to Policies in another PR. The request middleware looked a good spot to just call an instance of that class and return it’s `authenticate()`. Which does seem to work, but now I know I need to massage it a bit :thumbsup: Although I’m going to read through the bits that @steinkel linked, as |
# |
May 18th 2021, 09:15 |
slackebot |
generally you can as well manually check the request (if you actually _want_ to use a request policy) on controller level and take actions into account that do not require authentication. ```$action = $this->request->getParam('action'); if (in_array($action, $this->Authentication->getUnauthenticatedActions(), true)) { $this->Authorization->skipAuthorization(); } else { $this->Authorization->authorize($this->request, 'access'); }``` |
# |
May 18th 2021, 09:15 |
ndm |
@neon1024 That's just how the request authorization middleware works, it unconditionally applies to every request, acting as a simple, early entry point for stuff like RBAC, ACL, etc., and if you don't want to duplicate config, then you should store it in a central point instead where both your policies as well as your controllers can look it up. Also, you don't necessarily _have_ to use the middleware to authorize requests, |
# |
May 18th 2021, 09:01 |
erwane |
So yes, we have to define it twice :) |
# |
May 18th 2021, 09:00 |
erwane |
In my AuthController (page with no authorization and not yet authenticated), i have to write ``` public function initialize() { parent::initialize(); $this->Authentication->allowUnauthenticated([ 'login', 'logout', 'passwordAsk', 'passwordRenew', ]); $this->skipAuthorization();``` |
# |
May 18th 2021, 09:00 |
neon1024 |
I’ll get my reading done this morning :thumbsup: |
# |
May 18th 2021, 08:59 |
neon1024 |
I' |
# |
May 18th 2021, 08:59 |
neon1024 |
..adn good old method called `can()` :) |
# |
May 18th 2021, 08:59 |
neon1024 |
Services, but not from a DI container! :p\ |
# |
May 18th 2021, 08:58 |
neon1024 |
Maps, Resolvers, Policies, Identities, Services |
# |
May 18th 2021, 08:58 |
neon1024 |
But hey, this is my first attempt at these plugins, so I have lots to learn :) |
# |
May 18th 2021, 08:57 |
erwane |
Why Authorization check if no Authentication ? |
# |
May 18th 2021, 08:57 |
erwane |
You're right. |
# |
May 18th 2021, 08:57 |
neon1024 |
..and, do correct me here, but Authentication provides the indentity |
# |
May 18th 2021, 08:56 |
neon1024 |
Yes, I’m just confused why Authorization would be called when there is no identity |