# |
Jun 7th 2021, 14:26 |
kevin.pfeifer |
I would put it above or bellow the already present use logic |
# |
Jun 7th 2021, 14:25 |
paolo.bragagni |
when I bake it via bin/cake bake all mycontroller -t mytemplateBake |
# |
Jun 7th 2021, 14:24 |
paolo.bragagni |
I'd like to put 'use Cake\Http\Cookie\Cookie; ' at the start of my controller |
# |
Jun 7th 2021, 14:22 |
paolo.bragagni |
sorry, I explain |
# |
Jun 7th 2021, 14:20 |
paolo.bragagni |
where I have to put "use .." If I want that when i bake with my template, it compares in my controller? |
# |
Jun 7th 2021, 12:50 |
admad |
We can't add methods which work only for some cases. |
# |
Jun 7th 2021, 12:49 |
admad |
The problem with that idea is there are multiple ways to add a middleware, it could be a classname string, an object or a callable, so the remove() would only work with class name strings. |
# |
Jun 7th 2021, 12:43 |
peter.harder |
@admad thanks, will check it out! I was thinking about a “remove”-method for the middleware queue, so if I add middleware that is used by 9/10 of my controllers in Application.php, I could call `$middleware->remove('HttpsEnforceMiddleware')` for that single one. Would that be a totally crazy way of handling it? |
# |
Jun 7th 2021, 12:10 |
admad |
@peter.harder a better way will be available in 4.3 https://github.com/cakephp/cakephp/pull/15558 |
# |
Jun 7th 2021, 12:09 |
kevin.pfeifer |
you mean a SQL `WHERE field IN [1,2,3,4]` ? ```$query = $articles ->find('list') ->where(['field IN' => [1,2,3,4]);``` |
# |
Jun 7th 2021, 11:46 |
etibor |
is there an easy way to use in_array function on a find('list') ? |
# |
Jun 7th 2021, 11:26 |
etibor |
hello everyone |
# |
Jun 7th 2021, 08:29 |
kevin.pfeifer |
https://book.cakephp.org/4/en/console-commands/commands.html#calling-other-commands |
# |
Jun 7th 2021, 08:06 |
turkles |
I have a bunch of Commands I use, and I want to run a different (single) command before each one, what's the best way to do this? |
# |
Jun 7th 2021, 06:47 |
slackebot |
“whiteList” array to pass to the constructor. It seem to work, but there might be a better way? |
# |
Jun 7th 2021, 06:47 |
peter.harder |
I want to redirect http to https and ```HttpsEnforcerMiddleware``` works excellent for that. But - I have one (1) controller that serves a legacy Windows-application that do not support https. Can I exclude this specific controller from being redirected? I can’t find any built in way for this, like the $csrf->skipCheckCallback. To solve it for now, I made my own copy of HttpsEnforcerMiddleware and added a |
# |
Jun 6th 2021, 21:02 |
haldiainftech01 |
hi, club room (Chat) application idea |
# |
Jun 6th 2021, 21:01 |
haldiainftech01 |
hi |
# |
Jun 6th 2021, 20:47 |
kevin.pfeifer |
ok, then i tested it wrong :,) |
# |
Jun 6th 2021, 20:45 |
kupe3b |
thanks ``` 'Error' => [ 'errorLevel' => E_ALL and ~E_NOTICE, ],``` in app_local.php is what i needed. |
# |
Jun 6th 2021, 20:34 |
kevin.pfeifer |
well, debug mode is meant to show you all that is either deprecated or if there are problems with your code. I am not aware that this is possible when debug mode is active. There is a line in your app.php (or app_local.php) where you can set the active error levels https://github.com/cakephp/app/blob/master/config/app.php#L183 but this doesn’t do what you want |
# |
Jun 6th 2021, 20:11 |
kupe3b |
and without switching debug to false |
# |
Jun 6th 2021, 20:11 |
kupe3b |
hi, anyone knows how can i disable PHP notices from cakephp (without changing php.ini)? |
# |
Jun 6th 2021, 18:12 |
slackebot |
'FtpLoginData.id' ] ) ->matching( 'ConnectionTypes', function( $q ) use ( $filter_connection_type ) { /** @var $q Query */ return $q->where( [ 'ConnectionTypes.id' => $filter_connection_type ] ); } ); }``` But if you use the friendsofcake/search plugin there are different ways how you adjust the query |
# |
Jun 6th 2021, 18:12 |
kevin.pfeifer |
well, as always, there are many ways you can do such a thing. I did it via a GET form (so the filter parameters are present in the URL) and check them in my controller/custom finder method via something like that ```$filter_connection_type = $current_request->getQuery( 'filter_connection_type' ); if( $filter_connection_type != 'all' andand !is_null( $filter_connection_type ) ) { $query->distinct( [ |
# |
Jun 6th 2021, 18:06 |
etibor |
okey thank you, @kevin.pfeifer so basically for a filter form page there is not necesserly to check the request method |
# |
Jun 6th 2021, 18:03 |
kevin.pfeifer |
therefore if you call `/categories/add` "normally" (= GET method) you get the add form and when the form is being submited via POST to the same URL it actually saves the data |
# |
Jun 6th 2021, 18:02 |
slackebot |
$this->redirect( [ 'action' => 'index' ] ); } $this->Flash->error( __( 'The category could not be saved. Please, try again.' ) ); } $this->set( compact( 'category' ) ); }``` |
# |
Jun 6th 2021, 18:02 |
kevin.pfeifer |
thats why e.g. the add function has only the save logic inside such an if ``` public function add() { $category = $this->Categories->newEmptyEntity(); if( $this->request->is( 'post' ) ) { $category = $this->Categories->patchEntity( $category, $this->request->getData() ); if( $this->Categories->save( $category ) ) { $this->Flash->success( __( 'The category has been saved.' ) ); return |
# |
Jun 6th 2021, 18:01 |
kevin.pfeifer |
controller functions basically don't care from which HTTP method they are called. You can restrict logic inside your controller functions with something like that ```if( $this->request->is( 'get' ) ) { // Code only executed on GET requests } if( $this->request->is( 'post' ) ) { // Code only executed on POST requests } // Code executed for ALL HTTP methods``` |
# |
Jun 6th 2021, 17:57 |
etibor |
is there a universal request method for handling post and get like the $_REQUEST in core php? |
# |
Jun 6th 2021, 17:10 |
kevin.pfeifer |
:wave: |
# |
Jun 6th 2021, 17:08 |
etibor |
hello everyone |
# |
Jun 6th 2021, 14:17 |
fresnel.brieuc |
Yup, thanks |
# |
Jun 6th 2021, 14:16 |
isvyas |
@fresnel.brieuc complication is handled by Laravel mix: https://laravel-mix.com/ Which you can find in package.json file. |
# |
Jun 6th 2021, 14:16 |
fresnel.brieuc |
I have no idea what I'm doing wow |
# |
Jun 6th 2021, 14:02 |
fresnel.brieuc |
Or does vue maybe does that automatically? |
# |
Jun 6th 2021, 14:01 |
fresnel.brieuc |
@isvyas Sorry to bother you again but I have a question concerning the repo you sent me yesterday https://github.com/ishanvyas22/cakephpvue-spa, does the config compile components css/scss ? How does it work ? (Not talking about the resources/css directory you made, talking about the css inside vue component files) |
# |
Jun 5th 2021, 19:24 |
etibor |
i think i made a fault by, adding a ```if($this->request->is('post')){ }else{//no form submit }``` |
# |
Jun 5th 2021, 19:18 |
kevin.pfeifer |
so your paginated table was only built when you click on a button which submits a form? |
# |
Jun 5th 2021, 19:08 |
etibor |
i haven properly definied the Form |