# |
May 26th 2017, 11:43 |
obinoob |
hmic: I've only wrote a component because I've found that I can only validate controller action on crud methods under buildRules, but I can't validate business rules within validation so... now i need to retrieve a response from my component which requires Flash component I'm sure I'm doing something terrible wrong |
# |
May 26th 2017, 11:36 |
NeoTherm1c|Work |
custom validation function? |
# |
May 26th 2017, 11:35 |
inoas |
on save |
# |
May 26th 2017, 11:35 |
inoas |
how do I best validate if field = FOO another field must be BAR |
# |
May 26th 2017, 11:33 |
hmic |
so load it there - you can do so from the component scope by accessing the controller it is attached to |
# |
May 26th 2017, 11:33 |
hmic |
not the component needs the flashcomponent, but the controller |
# |
May 26th 2017, 11:32 |
obinoob |
hmic: I've converted my trait to a component, I need Flash in my new component is that possible? If yes how can I load it? |
# |
May 26th 2017, 11:31 |
eax |
Good point! Thanks :) |
# |
May 26th 2017, 11:31 |
hmic |
if not, provide a testcase - based on the one thats there - that does and fails |
# |
May 26th 2017, 11:30 |
hmic |
you should check the testcase mark has added for the issue and if that fits your case |
# |
May 26th 2017, 11:25 |
eax |
That's the "old" issue, which I can still reproduce :) |
# |
May 26th 2017, 11:24 |
eax |
hmic: https://github.com/cakephp/cakephp/issues/10633 |
# |
May 26th 2017, 11:24 |
hmic |
eax: post a link to the issue please |
# |
May 26th 2017, 11:24 |
eax |
Thanks! :) |
# |
May 26th 2017, 11:24 |
hmic |
of course |
# |
May 26th 2017, 11:23 |
cleptric |
Both ^^ |
# |
May 26th 2017, 11:23 |
eax |
Okay, thanks cleptric! Should I refer to the original issue and pr, or? :) |
# |
May 26th 2017, 11:23 |
hmic |
does not need to be in the initialize method |
# |
May 26th 2017, 11:23 |
hmic |
obinoob, from any controller context. not from a table context of course where a behavior would get attached |
# |
May 26th 2017, 11:22 |
obinoob |
hmic: I think I would have to use initialize method right? |
# |
May 26th 2017, 11:22 |
cleptric |
@eax Simply open another issue :slightly_smiling_face: |
# |
May 26th 2017, 11:22 |
eax |
rchavik: It is a bit above my level to fix it, sadly :) |
# |
May 26th 2017, 11:22 |
obinoob |
hmic yes behaviour stupid observation... how can I load $this->loadComponent('Flash'); in my new component is that possible? |
# |
May 26th 2017, 11:21 |
rchavik |
submit a PR that really fix it with a test case :) |
# |
May 26th 2017, 11:17 |
eax |
Hey folks! I reported an issue in Cake3 a while back (about 2.5 weeks); which got fixed with a pr that was merged and released in 3.4.7 - However, the solution doesn't actually fix the bug I found :( (In other words, I can still reproduce it in 3.4.7) - What is the correct/most polite way of informing of this? :) |
# |
May 26th 2017, 11:12 |
hmic |
you said you are doing sql queries, so i would think it fits the category of a behavior |
# |
May 26th 2017, 11:08 |
obinoob |
hmic: ;) so my custom class would fit in category of Helpers I believe... |
# |
May 26th 2017, 11:04 |
hmic |
thats the cake way you have asked for |
# |
May 26th 2017, 11:03 |
hmic |
with a registry! |
# |
May 26th 2017, 11:03 |
obinoob |
hmic: let me expose my ideia with a small code example I think it can clear up things a bit, this is a stupid argument probably but I just want to find a way I can reuse a custom object instance in my code ;) |
# |
May 26th 2017, 11:01 |
hmic |
you could easily utilize the generic objectregistry to load and get your custom class when-/whereever |
# |
May 26th 2017, 11:01 |
hmic |
there are more registries uses in cake than the tableregistry |
# |
May 26th 2017, 11:00 |
hmic |
if thats not what you want, you can use a registry to get the instance whenever and whereever you need it. exactly like the table class you get from the tableregistry |
# |
May 26th 2017, 10:59 |
hmic |
why every method? if the trait is attached to a class, you can add the instance to that class |
# |
May 26th 2017, 10:59 |
obinoob |
available for trait and all the classes that use trait's codes |
# |
May 26th 2017, 10:59 |
hmic |
but still: i'd add the functionality to te table, from what you have said. |
# |
May 26th 2017, 10:58 |
obinoob |
I just want to have one instance |
# |
May 26th 2017, 10:58 |
obinoob |
but I've found I need a new instance in every method on the trait |
# |
May 26th 2017, 10:58 |
hmic |
use a registry! |
# |
May 26th 2017, 10:58 |
hmic |
and you need a way to access it |
# |
May 26th 2017, 10:58 |
obinoob |
the custom class instance is being used in trait |