# |
Jan 16th 2020, 16:34 |
shoe |
But that won’t work when using the request authorization middleware, will it? |
# |
Jan 16th 2020, 16:33 |
ndm |
By default it uses the exception handler, which will just rethrow the catched exception |
# |
Jan 16th 2020, 16:32 |
ndm |
That is handled through the authorization middleware https://book.cakephp.org/authorization/2/en/middleware.html#handling-unauthorized-requests |
# |
Jan 16th 2020, 16:28 |
slackebot |
the Request Authorization, but I’m probably missing something really obvious :) |
# |
Jan 16th 2020, 16:28 |
shoe |
When using the Authorization plugin, and specifically using the Request Authorization Middleware is it possible to redirect the user if the user is unauthorized, rather than throwing the ForbiddenException error?The regular Authorization Middleware has an “unauthorizedHandler” which can be used to redirect, but I’m basically using a roles based authentication limiting access to various controllers / actions and see no similar option for |
# |
Jan 16th 2020, 15:39 |
rudy1976s |
@neon1024 nice idea I will try test and see what happens ! |
# |
Jan 16th 2020, 15:38 |
neon1024 |
Easier to read :point_right: https://api.cakephp.org/3.8/class-Cake.ORM.Table.html#_save |
# |
Jan 16th 2020, 15:37 |
neon1024 |
Not much in the docs though :thinking_face: https://book.cakephp.org/3/en/orm/table-objects.html#aftersave |
# |
Jan 16th 2020, 15:36 |
neon1024 |
https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php#L1744-L1747 |
# |
Jan 16th 2020, 15:36 |
neon1024 |
At least, that’s what I’d try first time |
# |
Jan 16th 2020, 15:35 |
neon1024 |
So quite possible you could do `$this->Examples->save($entity, ['doCron' => false])` |
# |
Jan 16th 2020, 15:35 |
neon1024 |
```Model.afterSave: Will be triggered after a successful insert or save, * listeners will receive the entity and the options array as arguments.``` |
# |
Jan 16th 2020, 15:35 |
neon1024 |
From the docblock |
# |
Jan 16th 2020, 15:34 |
neon1024 |
Sounds like you need to pass the ‘actor’ through with the save options, so your afterSave can know if it needs to process or not |
# |
Jan 16th 2020, 15:32 |
rudy1976s |
@neon1024 I have some action performed every time a post model save on afterSave. Then have a scheduled cron routine which save the post entity but in that case i don't want the aftersave event to be trigged |
# |
Jan 16th 2020, 15:29 |
neon1024 |
@rudy1976s Don’t you just return false or use `$event->stopPropagation()` ? https://book.cakephp.org/3/en/core-libraries/events.html#stopping-events |
# |
Jan 16th 2020, 15:21 |
rudy1976s |
good afternoon! is there a way to stop the propagation of the afterSave event of a modelClass ? |
# |
Jan 16th 2020, 15:20 |
neon1024 |
https://semver.mwl.be/#!?package=slevomat%2Fcoding-standardandversion=%5E5.0andminimum-stability=stable#%3Fpackage=cakephp%2Fcakephpandversion=%5E3.5.0andminimum-stability=stable |
# |
Jan 16th 2020, 15:20 |
neon1024 |
the slevomat/coding-standard seems to be on 6.0.8 latest, and the sniffer requires ^5.0 |
# |
Jan 16th 2020, 15:19 |
neon1024 |
Few merges for it, that I can find :) https://github.com/cakephp/cakephp-codesniffer/issues?utf8=%E2%9C%93andq=slevomat |
# |
Jan 16th 2020, 15:19 |
dereuromark |
Deps might be declared wrong on the sniffer |
# |
Jan 16th 2020, 15:18 |
neon1024 |
I wasn’t on Cake 4 though, so used 3.3.0 |
# |
Jan 16th 2020, 15:18 |
neon1024 |
This version requires the slevomat library, so installing or updating to that one should do it |
# |
Jan 16th 2020, 15:18 |
neon1024 |
https://packagist.org/packages/cakephp/cakephp-codesniffer#4.0.0 |
# |
Jan 16th 2020, 15:17 |
neon1024 |
What version are you using of the sniffer/ |
# |
Jan 16th 2020, 15:13 |
alexdd55976 |
this is was i did this morning already :( |
# |
Jan 16th 2020, 15:08 |
neon1024 |
Just updated using Composer and all was well |
# |
Jan 16th 2020, 15:06 |
neon1024 |
Ah, the search doesn’t find my message as it’s too old :( |
# |
Jan 16th 2020, 15:05 |
neon1024 |
When I got that message it was because my codesniffer version was stale |
# |
Jan 16th 2020, 15:05 |
alexdd55976 |
any idea how to get rid of this |
# |
Jan 16th 2020, 15:05 |
alexdd55976 |
since the update to 4.0.2 i getting annoying php storm message ```phpcs: ERROR: Referenced sniff "SlevomatCodingStandard.Arrays.TrailingArrayComma" does not exist Run "phpcs --help" for usage information Exclude UsersController.php from PHP_CodeSniffer analysis.``` |
# |
Jan 16th 2020, 15:05 |
alexdd55976 |
hey fellows |
# |
Jan 16th 2020, 14:54 |
javier.villanueva |
:thinking_face: i check it |
# |
Jan 16th 2020, 14:53 |
dereuromark |
@javier.villanueva At the time I also needed this small hack for the confirm info: https://github.com/dereuromark/cakephp-sandbox/blob/master/src/View/Helper/FormHelper.php#L21-L23 Not sure if still needed in cake4. |
# |
Jan 16th 2020, 14:52 |
dereuromark |
they might have improved. you might at least compare and see if things got better or worse^^ |
# |
Jan 16th 2020, 14:51 |
noel |
@dereuromark I tried PHPstorm years ago and really hated it. Can't go back. It took me about 3 days to configure xdebug for PHPstorm first time round :) Took me 5 min with vscode and stepping through is really quick. |
# |
Jan 16th 2020, 14:50 |
javier.villanueva |
the form action keep it |
# |
Jan 16th 2020, 14:50 |
javier.villanueva |
ok!! |
# |
Jan 16th 2020, 14:49 |
javier.villanueva |
but I need keep the onclick for enable again |
# |
Jan 16th 2020, 14:49 |
dereuromark |
@noel i wonder how that compares to phpstorm though |
# |
Jan 16th 2020, 14:47 |
javier.villanueva |
@dereuromark thanks I am seeing your snippet |