Logs for #cakephp

Page 6 of 36,922, showing 100 records out of 3,692,143 total, starting on record 501, ending on 600

# At Username Text
# Jul 21st 2021, 14:31 Guest481 but if i imagine my class is in src:
# Jul 21st 2021, 14:29 Guest481 hmm okay i'll give it a try
# Jul 21st 2021, 14:27 cnizzardini You can create that class anywhere in `src/` that makes sense to you. You may also want to look at making this a configuration: https://book.cakephp.org/4/en/development/configuration.html
# Jul 21st 2021, 14:26 Guest481 or maybe in Entity
# Jul 21st 2021, 14:25 Guest481 any help would be apreciated
# Jul 21st 2021, 14:25 Guest481 nothing found in the doc
# Jul 21st 2021, 14:25 Guest481 i don't have any idea on where to create that class file (folder, etc)
# Jul 21st 2021, 14:25 Guest481 by example, containing the following : CustomRole::SYSTEM_ADMIN
# Jul 21st 2021, 14:24 Guest481 i would like to create a class which would have only the aim to provide constants
# Jul 21st 2021, 14:23 Guest481 Hi everybody ! i have a doubt
# Jul 21st 2021, 12:36 paolo.bragagni Tomorrow Ill try (today ->beach). I hope it works.. allowClear didnt worked...
# Jul 21st 2021, 11:23 kevin.pfeifer or that :)
# Jul 21st 2021, 11:22 dereuromark its in the docs
# Jul 21st 2021, 11:21 dereuromark dont you just need a `allowClear: true` on top of the JS config for select2 to allow this?
# Jul 21st 2021, 11:12 kevin.pfeifer as far as I know `'empty' => true` only adds an empty `<option>` This empty option is present in the select2 dropdown, but you barely can see/select it because it has no height (because it has no text) Try setting `'empty' => __( 'No selection' ),`
# Jul 21st 2021, 11:07 paolo.bragagni In view I havent option to select empty.
# Jul 21st 2021, 09:44 slackebot2 race conditions that like to happen there.
# Jul 21st 2021, 09:44 ndm Maybe... it could also be that rector is broken once again. Try running the rector command that the upgrade tool generates manually. You could also try a debugger like xdebug to log traces to maybe get an idea where things possibly halt. If you already have a debugger installed and enabled, also try disabling it. Also when running in a VM, try placing the code outside of the shared folder to avoid possible file locking related
# Jul 21st 2021, 07:04 Guest45 ok thanks for the ocnfirmation
# Jul 21st 2021, 07:03 dereuromark controllers share the same model usually :)
# Jul 21st 2021, 07:03 dereuromark models are always in one spot
# Jul 21st 2021, 06:53 Guest45 do i need to create them too ?
# Jul 21st 2021, 06:53 Guest45 yes ands regarding the models
# Jul 21st 2021, 06:52 dereuromark you can reuse templates if you want. it is just simpler sometimes to have them separated, as e.g. admin actions usually offer different/more fields
# Jul 21st 2021, 06:52 Guest45 yes but new habits hihi
# Jul 21st 2021, 06:52 Guest45 grrr that means associated template i suppose
# Jul 21st 2021, 06:52 dereuromark You dont have to go too crazy like Laravel that every action now has its own class. So I think having a class per routing/prefix makes a good compromise :)
# Jul 21st 2021, 06:51 dereuromark yes, nowadays those are separate controllers in /Admin namespace etc
# Jul 21st 2021, 06:50 Guest45 does it means a dedicated controller should be created ?
# Jul 21st 2021, 06:50 Guest45 it seems that it's not possible to have prefixed actions with routing as previous versions of cake eg admin_view, admin_edit
# Jul 21st 2021, 06:50 Guest45 Hi all
# Jul 21st 2021, 06:47 dereuromark this is usually the default of bake templates if your DB has the field to "default NULL"
# Jul 21st 2021, 06:46 dereuromark `'empty' => true` ?
# Jul 21st 2021, 06:43 paolo.bragagni How to allow user to make the field blank?
# Jul 21st 2021, 06:42 paolo.bragagni But I have some problem in edit view
# Jul 21st 2021, 06:41 paolo.bragagni Ive integrated select2 via ajax
# Jul 21st 2021, 05:10 brandon @ndm ^
# Jul 21st 2021, 05:09 brandon Brand new VM, installed PHP, Composer, all that good stuff. Checked out my repo and ran the same rector command. It still hangs in the same spot. So it has to be something with my code then, right? I fixed all the issues with cs - comes back clean. Not sure what else to look at.
# Jul 20th 2021, 21:25 jadelbe418 Yup, I was just doing that. That one is pretty useful!
# Jul 20th 2021, 21:24 kevin.pfeifer you should also look into the https://github.com/cakephp/cakephp/blob/084963bd27984e50174fadcbdee91048112231a0/src/Http/Middleware/BodyParserMiddleware.php if you wanna see how the body of the request can be adjusted if e.g. the content-type is json or xml
# Jul 20th 2021, 21:15 jadelbe418 Cool, I have never written any either but my project is at a point where it could really use it so I am attempting to figure it out. I appreciate the help!
# Jul 20th 2021, 21:12 slackebot2 helper function bellow)
# Jul 20th 2021, 21:12 kevin.pfeifer I never looked that deep into these things because I never had to write a custom middleware so sorry :man-shrugging: I have already told you pretty much everything I know about middlewares ^^ But looking at https://github.com/cakephp/cakephp/blob/084963bd27984e50174fadcbdee91048112231a0/src/Http/Middleware/CsrfProtectionMiddleware.php#L120 you can see here, that this middleware adds a cookie to the response object (in a
# Jul 20th 2021, 20:58 jadelbe418 But it should be able to edit a response or a request at any position? I am just am not super familiar with the concept and am wonder how the application determines at what stage in the request or the response building process to stop and fire these. Or does where the middle ware get added not effect the functionality on that level? I might be over complicating the issue in my understanding of it.
# Jul 20th 2021, 20:53 kevin.pfeifer well these functions would only allow you to insert your middleware at a specific position in the middleware queue (e.g. if you would be in a plugin where you don't have direct access to the other middleware addition code) If you are happy with the position your middleware gets added inside your Application.php then sure, ->add() is totally fine
# Jul 20th 2021, 20:50 jadelbe418 @kevin.pfeifer Would the way I am just using ->add(new CustomFieldsMiddleware()) in the base application be sufficient? I am looking at other ways to add middleware like prepend(), insertAt(), etc. in the docs. Would these allow me to control the stage of the request handling or response building logic the middleware would be fired at?
# Jul 20th 2021, 20:43 jadelbe418 Cool, I will look at how that works. Thanks
# Jul 20th 2021, 20:41 kevin.pfeifer well maybe you can check something from the 3.X version of the CsrfProtectionMiddleware https://github.com/cakephp/cakephp/blob/3.x/src/Http/Middleware/CsrfProtectionMiddleware.php
# Jul 20th 2021, 20:41 jadelbe418 I am going based off on these instructions: https://book.cakephp.org/3/en/controllers/middleware.html
# Jul 20th 2021, 20:41 jadelbe418 Yup
# Jul 20th 2021, 20:41 kevin.pfeifer thats why you used the __invoke method
# Jul 20th 2021, 20:40 jadelbe418 The middlware interface seems to be used on the 4.x docs and not 3.x
# Jul 20th 2021, 20:40 kevin.pfeifer ah ok, cakephp 3 didn’t have that interface yet
# Jul 20th 2021, 20:40 kevin.pfeifer oh ok
# Jul 20th 2021, 20:39 jadelbe418 @kevin.pfeifer I am sorry, I should have mentioned the version number of cake I am working with. The application I am on is on 3
# Jul 20th 2021, 20:37 jadelbe418 I will play with that and see how it works.
# Jul 20th 2021, 20:37 jadelbe418 Great, thanks!
# Jul 20th 2021, 20:36 kevin.pfeifer see e.g. https://github.com/cakephp/cakephp/blob/master/src/Http/Middleware/CsrfProtectionMiddleware.php each middleware should at least implement the `MiddlewareInterface` and therefore the `process($request, $handler)` funciton
# Jul 20th 2021, 20:35 jadelbe418 I assume that I am not putting it in the middle ware que in the right spot.
# Jul 20th 2021, 20:34 slackebot2 route caching // pass null as cacheConfig, example: `new RoutingMiddleware($this)` // you might want to disable this cache in case your routing is extremely simple ->add(new RoutingMiddleware($this, '_cake_routes_')); return $middlewareQueue; } }```
# Jul 20th 2021, 20:34 slackebot2 // and make an error page/response ->add(ErrorHandlerMiddleware::class) // Handle plugin/theme assets like CakePHP normally does. ->add(new AssetMiddleware([ 'cacheTime' => Configure::read('Asset.cacheTime') ])) ->add(new CustomFieldsMiddleware()) // Add routing middleware. // Routes collection cache enabled by default, to disable
# Jul 20th 2021, 20:34 jadelbe418 ```class Application extends BaseApplication { /** * Setup the middleware queue your application will use. * * @param MiddlewareQueue $middlewareQueue The middleware queue to setup. * @return MiddlewareQueue The updated middleware queue. */ public function middleware($middlewareQueue): MiddlewareQueue { $middlewareQueue // Catch any exceptions in the lower layers,
# Jul 20th 2021, 20:33 slackebot2 ResponseInterface A response */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { print_r($response); return $next($request, $response); } }```
# Jul 20th 2021, 20:33 jadelbe418 ```<?php namespace App\Middleware; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; /** * CustomFields middleware */ class CustomFieldsMiddleware { /** * Invoke method. * * @param ServerRequestInterface $request The request. * @param ResponseInterface $response The response. * @param callable $next Callback to invoke the next middleware. * @return
# Jul 20th 2021, 20:33 jadelbe418 @kevin.pfeifer Cool, thanks! So I was looking at Middleware. It seems that I do am not able to get a body in the response when I attach it to the base application like this:
# Jul 20th 2021, 19:58 kevin.pfeifer You can do both “pre-processing” (a request) and “post-processing” (a response) with a middleware See https://book.cakephp.org/4/en/intro.html#cakephp-request-cycle
# Jul 20th 2021, 19:28 slackebot2 custom fields in the api. I am still getting familiar with the cake event system and middleware. would pre-processing a request body be something I use middleware for? A before render event on the output side?
# Jul 20th 2021, 19:28 jadelbe418 I am working on a custom fields integration for a CakePHP Rest/ Crud based API. It has a slightly sophisticated MySQL schema architecture to allow users to create their own fields on certain tables in the system. I need to be able to filter posted json data and reformat it for the cake orm on a request so it properly fits into the cake schema and reformat it on the way out so the custom fields display consistently with non
# Jul 20th 2021, 15:53 kevin.pfeifer so you don't change your datasoure in your tests via the $connection variable? https://book.cakephp.org/3/en/development/testing.html#creating-fixtures
# Jul 20th 2021, 15:30 martin when I add `test_pipedrive` to the WebServices array and set Classname and Service it works fine. but I have multiple webservices. No problems with them, only with the newest one
# Jul 20th 2021, 15:29 kevin.pfeifer well to answer your question
# Jul 20th 2021, 15:29 kevin.pfeifer you are right :thinking_face:
# Jul 20th 2021, 15:28 martin not sure, default version by cakephp 3.9 I think?
# Jul 20th 2021, 15:27 kevin.pfeifer is it just me or is phpunit 6.5 pretty old? ,:)
# Jul 20th 2021, 15:24 martin would be nice if --debug did give me some debug information
# Jul 20th 2021, 15:17 martin ```vendor/bin/phpunit --debug PHPUnit 6.5.14 by Sebastian Bergmann and contributors. Exception: The datasource configuration "test_pipedrive" was not found. in [/var/www/vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php, line 195]``` How can I fix this issue? pipedrive is a webservice not a database. so can’t really add a test_pipedrive resource? Also have no tests that require that
# Jul 20th 2021, 13:05 sebastiansperandio093 thanks kevin!
# Jul 20th 2021, 12:22 paolo.bragagni yes thank you!!
# Jul 20th 2021, 12:14 ndm Good... for reference, here's an overview of the field formats for the different association types: https://book.cakephp.org/4/en/views/helpers/form.html#associated-form-inputs
# Jul 20th 2021, 12:11 paolo.bragagni :)
# Jul 20th 2021, 12:11 paolo.bragagni it works
# Jul 20th 2021, 12:11 ndm You just need to change the field name.
# Jul 20th 2021, 12:10 paolo.bragagni hum
# Jul 20th 2021, 12:10 ndm what... no! That array format was just to illustrate what the data will look like in the request.
# Jul 20th 2021, 12:08 paolo.bragagni so in this way? $this->Form->hidden('books',['value' => ['categories' => [['id' => 'value']]]])
# Jul 20th 2021, 12:05 paolo.bragagni I check it all
# Jul 20th 2021, 12:04 paolo.bragagni yes
# Jul 20th 2021, 12:04 slackebot2 more categories.
# Jul 20th 2021, 12:04 ndm So it's actually `hasMany`, not `belongsToMany`? And you create a new books record, meaning there is no existing associated data that would need to be modified, and only this one hidden category should be added? Then the field name format would be `categories.0.id` (which translates to `['categories' => [['id' => 'value']]`). But you might get into trouble if there possibly also is a visible control where users can choose one or
# Jul 20th 2021, 11:59 paolo.bragagni (in my old cake2 project echo "\t\t\t echo \$this->Form->hidden('{$assocName}', array('hiddenField' => true, 'value'=> \$f_id));\n"; worked...)
# Jul 20th 2021, 11:58 paolo.bragagni everything is working but the add, because when I add a book from that view it has to select category=2 (in hidden field)
# Jul 20th 2021, 11:57 paolo.bragagni I've done a bake template that build that in the 'view' view
# Jul 20th 2021, 11:56 paolo.bragagni books (libri) habtm categories
# Jul 20th 2021, 11:56 paolo.bragagni
# Jul 20th 2021, 11:55 paolo.bragagni my goal is this (call me crazy)
# Jul 20th 2021, 11:54 paolo.bragagni I have the value already in the view
# Jul 20th 2021, 11:53 dereuromark Right before saving :)
# Jul 20th 2021, 11:51 paolo.bragagni :S
# Jul 20th 2021, 11:41 dereuromark Most of hidden fields could Actually be added directly in Controller. Removes usually some of the tempering and complexitity vectors
# Jul 20th 2021, 11:37 paolo.bragagni in Books 'add1' view I'd like to save one specific category