Log message #4154747

# At Username Text
# Jun 29th 2018, 13:09 jhob just reading up on anonymous functions in PHP docs now! :slightly_smiling_face:
# Jun 29th 2018, 12:58 josbeir now you are! ;)
# Jun 29th 2018, 12:54 jhob thanks, wasn't familiar with the use syntax :slightly_smiling_face:
# Jun 29th 2018, 12:49 josbeir $ladies = $collection->reject(function ($person, $key) use($var) { $var == ..
# Jun 29th 2018, 12:47 jhob Apologies if this is a really basic question, but how do I pass a var to compare to the filter callback, e.g. (I want to pass $gender) `$collection = new Collection($people); $ladies = $collection->reject(function ($person, $key) { return $person->gender === $gender; });`
# Jun 29th 2018, 12:36 jhob awesome, thank you! Looking at implementing this now
# Jun 29th 2018, 12:36 josbeir :point_up:
# Jun 29th 2018, 12:35 saeideng The inverse of `filter()` is `reject()`
# Jun 29th 2018, 12:35 saeideng it is easy to use `reject()` here
# Jun 29th 2018, 12:31 josbeir =>https://book.cakephp.org/3.0/en/core-libraries/collections.html#filtering => https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#modifying-results-with-map-reduce
# Jun 29th 2018, 12:31 jhob Thanks. Did look at updating users but also nervous about breaking other stuff. Cheers for pointers.
# Jun 29th 2018, 12:31 josbeir or just toArray() and unset() the key :P
# Jun 29th 2018, 12:30 josbeir @jhob multiple choices, you can use map/reduce or use a collection method
# Jun 29th 2018, 12:28 jhob How do I unset/remove a record from a Cake\ORM\ResultSet ?
# Jun 29th 2018, 12:05 lorenzo thanks @josbeir
# Jun 29th 2018, 12:00 josbeir :partyparrot:
# Jun 29th 2018, 12:00 josbeir oh @lorenzo its your bd, happy bday!
# Jun 29th 2018, 11:50 bernat thanks
# Jun 29th 2018, 11:46 josbeir nope
# Jun 29th 2018, 11:45 bernat I guess not. Too specific probably. :s
# Jun 29th 2018, 11:45 bernat I'm solving it myself already, just asking if there was some hack in the framework or some plugin that solves it automatically.
# Jun 29th 2018, 11:45 josbeir and check if it has already been converted and just return the converted object(s)
# Jun 29th 2018, 11:44 josbeir Why not just store it somewhere after converting it?
# Jun 29th 2018, 11:44 bernat What bothers specially is that when reading Products->Services, the object instances for Services get duplicated instead of being reused.
# Jun 29th 2018, 11:43 bernat I want to read the association Services->Products just one time from the database. And somewhere in the code I need Services->Products and in other places it would be handy to have Products->Services. I could load Services->Products->Services but that means a lot of reading from the database and lots of duplicated instances.
# Jun 29th 2018, 11:42 josbeir ok, i was a little too quick in reading your question.. yeah what @tim said or doing it after fetching somewhere
# Jun 29th 2018, 11:41 josbeir :)
# Jun 29th 2018, 11:41 josbeir i'm still not getting the question but thats just me
# Jun 29th 2018, 11:40 bernat Right tim, but when I need this it's because I need the association both ways.
# Jun 29th 2018, 11:40 bernat It's easy to do it myself but I found myself doing it many times and I thought it might be already solved.
# Jun 29th 2018, 11:39 tim Why not just load Services instead and contain Products?
# Jun 29th 2018, 11:39 bernat No, I just mean using arrays/collections. No persistence involved.
# Jun 29th 2018, 11:37 josbeir so that it persists between requests?
# Jun 29th 2018, 11:37 josbeir ?
# Jun 29th 2018, 11:37 josbeir what do you mean by 'in memory'
# Jun 29th 2018, 11:35 bernat I've read the association Services->Products into entities from the database and I'd like to convert it to Products->Services in memory. I don't even know how to search this in Google. It might be a silly question since I could do it myself with some loops but I'm wondering if there's an implemented solution.
# Jun 29th 2018, 11:33 josbeir howdy
# Jun 29th 2018, 11:32 bernat Hi.
# Jun 29th 2018, 11:01 steinkel check for similar issues already fixed in the plugin, 4.2.1 is a bit old now
# Jun 29th 2018, 11:00 steinkel ^ on loginRedirect
# Jun 29th 2018, 10:59 steinkel the error usually happens in the users context when you are trying to redirect to a page and you are not allowed to by Rbac permissions