Log message #4190399

# At Username Text
# Jun 20th 2019, 17:46 mdotobie I think I like this architecture.
# Jun 20th 2019, 17:46 slackebot1 `\App\Model\Table` namespace as `ShippingItemTable`. Instead of extending `\Cake\ORM\Table` like a normal Table, it extends `App\Model\Datasource\Json`. In turn, the Entity is in the `\App\Model\Entity` namespace as `ShippingItem`
# Jun 20th 2019, 17:46 mdotobie Hey @jeremyharris, although I know I haven’t provided alot of context, I wanted to point out that as I sat here working on this I’ve decided to move the `\App\Model\Json\Json` to `App\Model\Datasource\Json`. My first experimental subclasses of this is a definition JSON file for Shipping Carrier data, the data lives in `config` and the “table” originally lived in the `\App\Model\Json` namespace as `ShippingJson` but it’s now mixed
# Jun 20th 2019, 16:27 jeremyharris same!
# Jun 20th 2019, 16:26 mdotobie okay. sometimes I like to do a sanity check to see if the way I’m thinking about things actually makes sense. I’m prone to over-engineering…but I like the mental stretching it gives to learn how to approach problems in non-obvious ways.
# Jun 20th 2019, 16:26 jeremyharris no need to make the developer learn their API if they don’t have good typehinted clients
# Jun 20th 2019, 16:25 jeremyharris yeah in those cases it makes sense to me to wrap them
# Jun 20th 2019, 16:25 jeremyharris if you need that level of abstraction then that’s fine. Sometimes it’s not necessary, because in reality your application is tied to those APIs even after the abstraction. I guess it depends on what the service class is doing
# Jun 20th 2019, 16:25 mdotobie Well, when that API doesn’t have a straightforward API. For instance I use the Mandrill PHP library as is, but I do a lot of custom stuff to Slack so I have a SlackService class that uses the Slack API directly through Guzzle injected into the Service class.
# Jun 20th 2019, 16:23 mdotobie I actually do something I refer to as Service classes as wrappers to API libraries.
# Jun 20th 2019, 16:22 slackebot1 “importers” and the `Hash` class as the data extractor.
# Jun 20th 2019, 16:22 mdotobie That’s what I thought @jeremyharris and I figured the reason was because of what you outlined. So I think my approach of creating two new kinds of classes that mimic the Table/Entity structure without relying on the underlying datasource is the easiest way to implement what I’m after. If I was using an API as the datasource I’d probably just replace using `JsonConfig` with something like `Guzzle` as they are just intended to be the da
# Jun 20th 2019, 16:19 slackebot1 is really good. I think you *could* still write something similar that would fit within the cake 3 ORM, but it would be pretty time consuming and the ORM method support would be minimal, so it probably wouldn’t be too useful
# Jun 20th 2019, 16:19 jeremyharris I think you’re correct. That way of writing datasources for APIs has been superseded by better API clients that have their own set of exception handling for specific API errors. I wrote maybe the first Stripe plugin that was a cakephp datasource for 2.x that translated the datasource commands, like ->read, into the appropriate REST call. However, this isn’t really useful anymore because the stripe client was released some time after
# Jun 20th 2019, 16:13 slackebot1 DB data source would have worked. I like that approach as well but it seems with the changes to the ORM in Cake3, this isn’t really a path that can be taken any longer. Am I misreading that?
# Jun 20th 2019, 16:13 slackebot1 the `Table` class. The returned JSON is then loaded into a `JsonObject` that mimics the `Entity` class functionality. This `JsonObject` and/or it’s subclasses include the methods that act on the JSON data. This feels like a good approach but I was interested in any feedback. I did read an article under the CakePHP 2.0 book about leveraging the Datasource class to load data from an external API source and have it work with the Table classes in a way
# Jun 20th 2019, 16:13 mdotobie Partially to satisfy a use case and partially as an experiment, I’ve been creating a way to use a JSON file as a datasource (mostly as a way to more quickly iterate over an evolving data structure). I’ve created a class called `Json` in the Model folder that uses a combination of the JsonConfig and Hash classes to load a JSON file that is defined in a more specific subclass that extends the `Json` class. This structure is intended to mi
# Jun 20th 2019, 15:56 neon1024 ..and you’ll need cascadeCallbacks set to true in your associations
# Jun 20th 2019, 15:55 neon1024 You won’t be able to cascade soft-delete without the behaviour attached to the Tables if I remember
# Jun 20th 2019, 15:55 peppejaripappalardo thx for your hint @neon1024
# Jun 20th 2019, 15:55 peppejaripappalardo yes, the problem is that, at this time the Behavior on Events and Mission is not implemented yet. So maybe that let fail the query
# Jun 20th 2019, 15:54 neon1024 If they were cascade soft-deleted then the query shouldn’t fail
# Jun 20th 2019, 15:52 peppejaripappalardo Yes, i need to keep Missions and Events for Historical Archive
# Jun 20th 2019, 15:51 neon1024 So wouldn’t that further mean, you’d want to cascade soft-delete the Missions as well
# Jun 20th 2019, 15:51 neon1024 Wouldn’t that also mean that a Missions belongsTo Users
# Jun 20th 2019, 15:50 neon1024 `$this->Users->behaviors()->unload('Trash')`
# Jun 20th 2019, 15:41 peppejaripappalardo Guys someone who use Muffin/Trash: I have implemented the soft-delete for the Users Table. But these users are related to Missions and Events. When i soft-delete a User, the query of Events or Missions stop to render the Event or the Mission related to the UserID who is soft-deleted. I tryed to deactivate the Behavior with $this->Users->removeBehavior('Trash') into the EventsController, but it dosen't work. Any suggestions?
# Jun 20th 2019, 15:32 rudy1976s @jeremyharris thank you , I will try the @dereuromark plugin
# Jun 20th 2019, 15:30 jeremyharris yep, you can write your own log engine or use an existing plugin: https://github.com/FriendsOfCake/awesome-cakephp#auditing--logging
# Jun 20th 2019, 15:29 rudy1976s I have a question regarding logs: is there a way to be able to save log to DB using the cake Log class ?
# Jun 20th 2019, 15:28 rudy1976s good afternoon to all bakers!
# Jun 20th 2019, 14:24 neon1024 Thanks!
# Jun 20th 2019, 14:17 jeremyharris includes polyfills only where necessary
# Jun 20th 2019, 14:17 jeremyharris I saw this come across HN, might be of interest: https://www.pika.dev/cdn
# Jun 20th 2019, 14:16 neon1024 I’ve been meaning to look for an NPM module which adds polyfills for stuff so that it just gets baked in when I build with Webpack, but I didn’t get there yet
# Jun 20th 2019, 14:15 neon1024 I didn’t try it though
# Jun 20th 2019, 14:15 neon1024 https://www.theverge.com/2019/4/8/18300077/microsoft-edge-chromium-canary-development-release-download
# Jun 20th 2019, 14:14 neon1024 9, 10, 11, Edge, and then onto this new Chromium based browser apparently
# Jun 20th 2019, 14:14 jeremyharris gotcha
# Jun 20th 2019, 14:14 neon1024 After 11 I believe
# Jun 20th 2019, 14:14 jeremyharris yeah not in IE but it’s in edge, which was like IE 10 or 11 right? I’ve been away from frontend for a while