Log message #4122723

# At Username Text
# Mar 7th 2018, 11:51 narendravaghela okay..., so what is the best way to determine that?
# Mar 7th 2018, 11:48 neon1024 Not reliably
# Mar 7th 2018, 11:46 narendravaghela Is there any way to detect user timezone from request object?
# Mar 7th 2018, 11:46 marcusgoede keys don’t matter here for me
# Mar 7th 2018, 11:45 marcusgoede yes, i know, i was just confused, it did change the order of the array, but not as i wanted
# Mar 7th 2018, 11:45 neon1024 If you do not want to preserve the key ordering perhaps you need to use a callback and your own sort function
# Mar 7th 2018, 11:45 neon1024 Sorting on the registrationDate would put them in order of the value, it will not order the keys
# Mar 7th 2018, 11:43 marcusgoede yes, but the keys are not sorted as well. 0, 11, 18, 17, … if i use ksort the values are still not ordered
# Mar 7th 2018, 11:43 neon1024 Not sure, sorry, seems like it should be working
# Mar 7th 2018, 11:41 neon1024 Those are not keys, they are values.
# Mar 7th 2018, 11:40 slackebot (int) 17 => [ ‘registrationDate’ => ‘2018-02-28’, ... ], (int) 16 => [ ‘registrationDate’ => ‘2018-02-28’, ... ], (int) 15 => [ ‘registrationDate’ => ‘2018-02-28’, ... ], the keys are not orders
# Mar 7th 2018, 11:40 marcusgoede ok, i understand and i changed the code. but it’s still strange. $collection = new Collection($users[‘users’]); $collection = $collection->sortBy(‘registrationDate’); $users = $collection->toArray(); $users: [ (int) 0 => [ ‘registrationDate’ => ‘2018-02-28’, ... ], (int) 11 => [ ‘registrationDate’ => ‘2018-02-28’, ... ], (int) 18 => [ ‘registrationDate’ =>
# Mar 7th 2018, 11:39 neon1024 Currently I can only see rolling my own PaginatorHelper as a solution
# Mar 7th 2018, 11:39 neon1024 I don’t recall having this issue before
# Mar 7th 2018, 11:38 neon1024 It seems to not be possible from what i can see, as the request params are used regardless
# Mar 7th 2018, 11:38 neon1024 Okay, I’m really struggling on how to find out how I can remove the pagination query params from my pagination links, and also how to prevent users changing the sorting field in the query params
# Mar 7th 2018, 11:21 neon1024 I don’t think collections work by reference
# Mar 7th 2018, 11:21 neon1024 Yeah, I agree with @richellyitalo you are not assigning the return of your function call
# Mar 7th 2018, 11:11 richellyitalo `$collection = $collection->sortBy...`
# Mar 7th 2018, 11:11 richellyitalo Are you try `$collection->sortBy('registrationDate');` or put `$collection`before sortBy ?
# Mar 7th 2018, 11:02 marcusgoede hello, can anybody help me why my collection is not sorted? I have no idea, what I am doing wrong. $collection = collection($users[‘users’]); $collection->sortBy(function ($user) { return $user[‘registrationDate’]; }); $users[‘users’] = $collection->toArray();
# Mar 7th 2018, 10:42 richellyitalo Nice tip....I will setup only in routes api.
# Mar 7th 2018, 10:42 neon1024 If you have a web service and http on the same application, be sure you don’t set all your requests to application/json! :P
# Mar 7th 2018, 10:42 richellyitalo ok...thanks , very helpfull
# Mar 7th 2018, 10:41 neon1024 Just check the url and then you can use something like `$request = $request->withHeader('Content-Type', 'application/json')`
# Mar 7th 2018, 10:40 neon1024 Middleware sounds very complicated, but is actually very simple
# Mar 7th 2018, 10:40 richellyitalo Ok, no problem.
# Mar 7th 2018, 10:40 neon1024 https://book.cakephp.org/3.0/en/controllers/middleware.html
# Mar 7th 2018, 10:40 neon1024 It’s part of my work, so I’m not allowed to share it, sorry
# Mar 7th 2018, 10:39 richellyitalo Do you have the code or article with this solutions?
# Mar 7th 2018, 10:39 neon1024 @richellyitalo Well I solved that problem using a middleware class, which automatically adds the headers I need to the request
# Mar 7th 2018, 10:38 richellyitalo @neon1024 So I can't make the server works /users normally to return json without content-type ?
# Mar 7th 2018, 10:35 dereuromark willem: i use an enhanced version of it that a lot of things on top, but yeah
# Mar 7th 2018, 10:35 neon1024 You set the headers in the request you send your endpoint
# Mar 7th 2018, 10:35 willem @dereuromark this one right? https://github.com/World-Architects/cakephp-fixture-check
# Mar 7th 2018, 10:34 richellyitalo How can I do that?
# Mar 7th 2018, 10:34 neon1024 @richellyitalo Sure you can, but you’ll have to pass the correct Content-Type headers
# Mar 7th 2018, 10:34 richellyitalo without json
# Mar 7th 2018, 10:33 richellyitalo example: `/users.json` like this `/user`
# Mar 7th 2018, 10:33 richellyitalo I wanna be know if I can remove format from REST in route.
# Mar 7th 2018, 10:33 willem fixture_check -> is this a plugin ?