Log message #4265732

# At Username Text
# Jun 17th 2021, 12:08 slackebot \Cake\Http\ServerRequest $request) { if ( $request->getParam('language') andand !isset($params['language']) ) { $params['language'] = $request->getParam('language'); } return $params; } );```
# Jun 17th 2021, 12:08 slackebot $patterns = ['language' => 'en|ar']; $builder ->connect('/', ['controller' => 'Clients', 'action' => 'index']) ->setPatterns($patterns); $builder ->connect('/:controller', ['action' => 'index']) ->setPatterns($patterns); $builder ->connect('/:controller/:action/*') ->setPatterns($patterns); }); \Cake\Routing\Router::addUrlFilter( function (array $params,
# Jun 17th 2021, 12:08 slackebot 'en|ar']; $routes ->connect('/', ['controller' => 'Users', 'action' => 'login']) ->setPatterns($patterns); $routes ->connect('/:controller', ['action' => 'index']) ->setPatterns($patterns); $routes ->connect('/:controller/:action/*', []) ->setPatterns($patterns); }); }); $routes->scope('/:language', function (RouteBuilder $builder) {
# Jun 17th 2021, 12:08 ndm @alamnaryab Go from here. If you run into errors, don't jump to using other methods until you have a firm grasp on why things are failing and how the problem could be solved, otherwise you'll never get anywhere with it, as you're just jumping from one problem to the next. ```$routes->scope('/:language', function (RouteBuilder $routes) { $routes->prefix('Admin', function (RouteBuilder $routes) { $patterns = ['language' =>
# Jun 17th 2021, 12:06 alamnaryab I used that plugin still I am getting almost same errors I have attached my updated routes.php debugger/routes tab snapshot and error message
# Jun 17th 2021, 11:58 k4t I hope there are no downsides of this
# Jun 17th 2021, 11:58 k4t and it looks like this is the only solution for CakePHP 3.1.14
# Jun 17th 2021, 11:57 k4t for me it is only working when I convert my $data array into string
# Jun 17th 2021, 11:49 ndm It works _despite_ doing that. I though that was what you were trying to do, as you've pointed to the `is_string()` check, and even mentioned using a string instead of an array?
# Jun 17th 2021, 11:46 k4t it is workign for you becuase as $date parameter you passed string not an array
# Jun 17th 2021, 11:40 kevin.pfeifer 1. Your AJAX Function in your 2. screenshot uses POST and not GET as a Method 2. I was wrong, `->contain()` doesn’t work with `->get()` you need to specify it like that ```$this->Vieworg->get( $id, [ 'contain' => [ 'Viewadr' ], ] );```
# Jun 17th 2021, 11:35 alamnaryab I have not checked, let me see now
# Jun 17th 2021, 11:35 dantedantas Hi Kevin, here you can see my ajaxAction. And you have also my Ajax-javascript function. I have 2 issues. The first is that I have no idea how to show/catch the result and show it on the other screen. The other issue is if I may have as a responsa an HTML code. I would like to format the result into a table and send it back. Thank you.
# Jun 17th 2021, 11:35 alamnaryab I have not checked, let me see now
# Jun 17th 2021, 11:34 alamnaryab there is no special routes, only default root and admin prefix
# Jun 17th 2021, 11:33 slackebot function (RouteBuilder $routes) { $routes->fallbacks(DashedRoute::class); }); ```
# Jun 17th 2021, 11:33 alamnaryab if it is difficult for you people to look at my dummy project at github please convert this routes.php for me ```use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->connect('/', ['controller' => 'Articles', 'action' => 'index']); $builder->fallbacks(); }); $routes->prefix('Admin',
# Jun 17th 2021, 11:32 alamnaryab I thank you people @ndm @admad @kevin.pfeifer but what ever I am trying I am getting errors on all or admin prefix, that's why I created dummy project to just convert default routes.php for me that works with language in url.
# Jun 17th 2021, 11:31 slackebot ]); }```
# Jun 17th 2021, 11:31 slackebot ($request) use ($contentType) { $this->assertEquals($contentType, $request->getHeaderLine('Content-Type')); return true; })) ->will($this->returnValue([new Response()])); $http = new Client([ 'host' => 'cakephp.org', 'adapter' => $adapter, ]); $http->post('/projects/add', 'string data', [ 'headers' => [ 'Content-Type' => $contentType ],
# Jun 17th 2021, 11:31 ndm It works for me, a quick test shows that the supplied content type is being used: ```public function testContentTypeWithStringData() { $contentType = 'application/x-www-form-urlencoded; charset=utf-8'; $adapter = $this ->getMockBuilder(Stream::class) ->onlyMethods(['send']) ->getMock(); $adapter ->expects($this->once()) ->method('send') ->with($this->callback(function
# Jun 17th 2021, 11:25 admad I hope this doesn't mean now I am on the hook for sorting out his problem :P
# Jun 17th 2021, 11:24 admad @alamnaryab have you checked out https://github.com/ADmad/cakephp-i18n#i18nroute?
# Jun 17th 2021, 11:13 k4t it will work only when you do ```$this->_httpClient->post($url, http_build_query($data), [ 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'] ]);``` which is yeah... a bit weird
# Jun 17th 2021, 11:12 k4t It will work only if you pass $data attribute as a string not an array
# Jun 17th 2021, 10:47 ndm @alamnaryab The example I've posted on SO works fine, I've tested it, the errors that you were receiving were because of wrong URL arrays. Again, if you want this to work without having to supply the `language` key in all URL arrays, then you need to persist it! https://book.cakephp.org/4/en/development/routing.html#creating-persistent-url-parameters
# Jun 17th 2021, 10:45 ndm @k4t It should work fine in 4.x. That `is_string() ...` code won't do anything if you're providing the header as shown in your snippet.
# Jun 17th 2021, 09:50 conehead @paolo.bragagni Use form templates
# Jun 17th 2021, 09:36 kevin.pfeifer :,) ok
# Jun 17th 2021, 09:35 dantedantas I sent the text by mistake. I cant press "Enter". I will finish the mensage. Thank you. :)
# Jun 17th 2021, 09:34 kevin.pfeifer an you should get ``` { 'data' => 'hello' }```
# Jun 17th 2021, 09:33 kevin.pfeifer try setting ``` return $response->withType( 'application/json' ) ->withStringBody( json_encode( [ 'data' => 'hello' ] ) );```
# Jun 17th 2021, 09:33 kevin.pfeifer yes? Don’t you expect that?
# Jun 17th 2021, 09:32 dantedantas Hi Kevin, Guten Morgen. Please, could you help me a little bit more with this issue? I tried what you wrote above, but without success. If I try to access the action, I am getting the screen bellow:
# Jun 17th 2021, 08:45 k4t as I can not append charst=utf-8 to Content-Type header we have problems with encoding sometimes
# Jun 17th 2021, 08:44 k4t I do not understand why there is that is_string($data) in the if which breaks it
# Jun 17th 2021, 08:38 k4t in the latest Cake it will also not work because of: https://github.com/cakephp/cakephp/blob/4.2.7/src/Http/Client.php#L574
# Jun 17th 2021, 08:09 k4t https://github.com/cakephp/cakephp/blob/3.1.14/src/Network/Http/Adapter/Stream.php#L185
# Jun 17th 2021, 08:07 paolo.bragagni how can I put some bootstrap buttons in $this->Form->input ?
# Jun 17th 2021, 08:06 paolo.bragagni in form helper no more after and before ??
# Jun 17th 2021, 08:02 k4t It it generally caused by: https://github.com/cakephp/cakephp/blob/3.x/src/Http/Client/FormData.php#L227