Log message #4205077

# At Username Text
# Sep 22nd 2019, 12:59 nucc1 when using the Authentication plugin, is it possible to catch and do something else with the UnAuthenticatedException, or do I have to rely on the redirect?
# Sep 22nd 2019, 12:42 noel There are but they don't seem to work for json-api. Thx anyhow.
# Sep 22nd 2019, 12:27 adam282 I am sure there is some built-in Cake routines and response handlers for JSON
# Sep 22nd 2019, 12:26 adam282 Honestly, I have no idea as in the last app I wrote, I had a small subset of functions that required a JSON response and that was CakePHP 2.x so I did it the way you just mentioned.
# Sep 22nd 2019, 12:22 noel @adam282 turning off autorender and setting the layout to false does indeed prevent the template from being required, which is cool. However _serialize doesn't result in any output. Is there a way to interact with crud-json-api's classes so as to build up a json-api response? Obviously I build up an array manually and then json_encode it and send it as a response but that seems like re-inventing the wheel.
# Sep 22nd 2019, 12:18 noel Ok tx I'll try that. I found this works although it seems heavy-handed: ``` public function index() { if ($this->request->is('jsonapi')) { $response = new \Cake\Http\Response; $response = $response->withType('application/json') ->withStringBody(json_encode(['success' => true])); } return $response; } ```
# Sep 22nd 2019, 12:13 adam282 Something like this inside your function inside your Controller: ``` $this->viewBuilder()->setLayout(false); $this->autoRender = false; ```
# Sep 22nd 2019, 12:12 adam282 Yeah, you need to turn off autorender and set the layout to false
# Sep 22nd 2019, 12:09 noel Hi. Working with crud-json-api – is there a way to have a custom response that has nothing to do with table's in the database for a particular Controller? I tried doing `$this->loadComponent('RequestHandler')` and `$this->set('_serialize', ['myVar'])` but it still seems to be asking for the template.
# Sep 22nd 2019, 11:19 admad @val https://github.com/FriendsOfCake/fixturize
# Sep 22nd 2019, 09:34 valerij.bancer Hi, is there an alternative of Fixturize plugin in 3.x? https://github.com/lorenzo/cakephp-fixturize
# Sep 22nd 2019, 07:29 maymeow need adwise I have relations `users -> addresses -> posts` When administrator wants to delete address or user what to do or what are you doing? • Cascading delete ? (so all things related to users and addresses are deleted • Deactivate user address etc ... so all posts are keep in database?
# Sep 21st 2019, 23:19 D-rex How do I disable csrf?
# Sep 21st 2019, 23:18 D-rex Keep getting CSRF token mismatch even after rem,oving the middleware from the route scope
# Sep 21st 2019, 20:55 noel Ok nvm. Got it
# Sep 21st 2019, 20:39 noel Actually I got the PATCH request working now. However I still have the issue with the exception renderer.
# Sep 21st 2019, 18:50 noel So I assume this is because errorException renderer isn't set up for JSON API... but I can't seem to get that set up using the information in the docs. Any help appreciated tx.
# Sep 21st 2019, 18:49 slackebot Crud\Error\Exception\ValidationException ```
# Sep 21st 2019, 18:49 noel So this is the body of my PATCH request: ``` { "data": { "type": "cocktails", "attributes": { "id": "22", "name": "Sex on a beach", "description": "Scratchy but fun" } } } ``` and the headers are: ``` Accept: application/vnd.api+json Content-Type: application/vnd.api+json ``` and the return is a 422 Unprocessable exception showing as HTML with the text: ``` A validation error occurred
# Sep 21st 2019, 18:48 noel It works correctly for GET but the problem is that when I try to update via PostMan using a PATCH request, I'm getting an HTML validation error response instead of a json response. Also the validation error is not specified, it just says "validation error".
# Sep 21st 2019, 18:39 noel Hi guys. Can someone please help me to set up error exception renderer for JSON API? The docs here are apparently out of date: https://crud-json-api.readthedocs.io/en/latest/preface/setup.html, what's shown there doesn't work.
# Sep 21st 2019, 16:53 peppejaripappalardo thx anyway
# Sep 21st 2019, 16:53 peppejaripappalardo np @destinydriven
# Sep 21st 2019, 14:22 destinydriven Sysmo, sorry I can’t be of much help
# Sep 21st 2019, 10:04 peppejaripappalardo thx @destinydriven i saw it, but the error persist
# Sep 21st 2019, 09:24 destinydriven @peppejaripappalardo ^
# Sep 21st 2019, 09:20 destinydriven You have duplicate key ‘duration’
# Sep 21st 2019, 09:18 peppejaripappalardo some hint please? :S
# Sep 21st 2019, 09:18 slackebot ],`
# Sep 21st 2019, 09:18 peppejaripappalardo `'_cake_core_' => [` ` 'className' => RedisEngine::class,` ` 'prefix' => 'myapp_cake_core_',` ` 'path' => CACHE . 'persistent/',` ` 'serialize' => true,` ` 'duration' => '+1 years',` ` 'host' => 'gjnas.serveftp.com',` ` 'password' => '*****',` ` 'database' => 0,` ` 'port' => 6379,` ` 'duration' => '+24 hours',` `
# Sep 21st 2019, 09:18 peppejaripappalardo `Cache engine Cake\Cache\Engine\RedisEngine is not properly configured`
# Sep 21st 2019, 09:18 peppejaripappalardo Got an issue with cache
# Sep 21st 2019, 09:18 peppejaripappalardo Hi all
# Sep 21st 2019, 09:07 destinydriven Elasty, thanks. Reciprocated
# Sep 21st 2019, 09:04 adam282 True. I don’t use it absolutely every where though I try my best to. Sorry I couldn’t help any better. I am out, have a good one.
# Sep 21st 2019, 09:04 destinydriven No worries, there’s no law saying that FormHelper has to be used all the time
# Sep 21st 2019, 09:03 destinydriven same difference
# Sep 21st 2019, 09:02 destinydriven yes
# Sep 21st 2019, 09:02 adam282 Oh, well no cause you said it works without form builder
# Sep 21st 2019, 09:02 adam282 It might not be Cake interpreting it but PHP
# Sep 21st 2019, 09:01 adam282 Try `echo $this->Form->hidden("DailyHour.{$i}.employee_id", ['value' => $key, 'id' => false]);`