# |
May 29th 2017, 16:33 |
hmic |
the simple - and usual - thing to do, if *important* data on a user changes is just logging that user out! |
# |
May 29th 2017, 16:32 |
chris-andre |
Okay. Then we are on the same page. Can I ask, how should I update SessionsTable? By Auth->setUser()? Or is that considered wrong? |
# |
May 29th 2017, 16:29 |
chris-andre |
Allright. I misunderstood you. |
# |
May 29th 2017, 16:29 |
chris-andre |
Do you mean updating the user session (db) ? |
# |
May 29th 2017, 16:29 |
hmic |
updating the session data is about updating the session data, not the user data! |
# |
May 29th 2017, 16:28 |
chris-andre |
When I say updating user data, I mean updating data in the UsersTable |
# |
May 29th 2017, 16:28 |
chris-andre |
Wondering why data isn't changed when updating user data then :S |
# |
May 29th 2017, 16:28 |
hmic |
where else do you think the data would be stored? :d |
# |
May 29th 2017, 16:27 |
hmic |
yes |
# |
May 29th 2017, 16:26 |
chris-andre |
@hmic Are you sure database session reads user data upon each request? I can't see that it does. |
# |
May 29th 2017, 16:07 |
hmic |
so attach it to the controller, like i said instead (from the parent components initialize) and use like my code snipped above to make sure you don't miss any callbacks on your child component |
# |
May 29th 2017, 16:07 |
hmic |
last sentence! - no callbacks at all! |
# |
May 29th 2017, 16:07 |
hmic |
https://book.cakephp.org/3.0/en/controllers/components.html#using-other-components-in-your-component |
# |
May 29th 2017, 16:05 |
hmic |
additionally: missed callbacks will not be called as the docs state: https://book.cakephp.org/3.0/en/controllers/components.html#loading-components-on-the-fly |
# |
May 29th 2017, 16:01 |
hmic |
if you attach it to the controller, it will get initialized |
# |
May 29th 2017, 16:01 |
hmic |
so this is why |
# |
May 29th 2017, 16:00 |
thinkingmedia |
they are attached to the component. |
# |
May 29th 2017, 16:00 |
thinkingmedia |
no, it's a child component of a component |
# |
May 29th 2017, 16:00 |
hmic |
i have not used lazy loaded components. but they are attached to a controller, not another component, are they? :p |
# |
May 29th 2017, 15:59 |
hmic |
it should be $this->getController()->RestError->couldNotSave() IMHO |
# |
May 29th 2017, 15:59 |
thinkingmedia |
`$this->RestError->couldNotSave();` triggers lazy loading. |
# |
May 29th 2017, 15:59 |
hmic |
where do you load it? |
# |
May 29th 2017, 15:57 |
thinkingmedia |
https://gist.github.com/thinkingmedia/5a288e32b95dc78b54b26c9f170e7e07 |
# |
May 29th 2017, 15:56 |
hmic |
!tell thinkingmedia about gist |
# |
May 29th 2017, 15:56 |
slackebot |
$config) { // this is never called parent::initialize($config); $con = $this->getController(); $this->eventManager($con->eventManager()); } public function couldNotSave() { return "stuff"; } } ``` |
# |
May 29th 2017, 15:56 |
thinkingmedia |
``` class RestCreateComponent extends RestComponent { public $components = ['RestError']; public function initialize(array $config) { parent::initialize($config); $con = $this->getController(); $this->eventManager($con->eventManager()); } public function create() { return $this->RestError->couldNotSave(); } } class RestErrorComponent extends Component { public function initial |
# |
May 29th 2017, 15:55 |
thinkingmedia |
k |
# |
May 29th 2017, 15:54 |
hmic |
i want to see the code you use to lazy load it |
# |
May 29th 2017, 15:54 |
thinkingmedia |
Unless that component was already loaded by the controller with loadComponent() |
# |
May 29th 2017, 15:54 |
thinkingmedia |
well, if you set $component property to lazy load another component. That other component will not get initialized or startup invoked at all. |
# |
May 29th 2017, 15:51 |
hmic |
can you show code? |
# |
May 29th 2017, 15:50 |
thinkingmedia |
If a component lazy loads a child component the "startup" is not fired. Is this correct behavior? |
# |
May 29th 2017, 15:11 |
spriz |
I actually had deployed with my fork, but then reverted since I didn't know if it had unknown consequences :) |
# |
May 29th 2017, 15:11 |
spriz |
Yeah as long as I didn't know if it was intended :) It might introduce a ton of unwanted (untested) changes :P |
# |
May 29th 2017, 15:11 |
hmic |
you might want to learn some composer magic instead ;-) |
# |
May 29th 2017, 15:10 |
hmic |
instead of using your fixed fork of the Crud plugin till the fix is accepted? wow! |
# |
May 29th 2017, 15:09 |
spriz |
I'll let it be for now then, just added 1k lines for empty functions to our code base anyway :,) |
# |
May 29th 2017, 15:09 |
hmic |
i still think your PR is correct though! |
# |
May 29th 2017, 15:08 |
spriz |
but that doens't make it right |
# |
May 29th 2017, 15:08 |
spriz |
it worked without issues for years :P |
# |
May 29th 2017, 15:08 |
spriz |
aye |