Does anyone have a working example of this:
I get I can use a legacy before save hook, but would like to try out the SuiteCRM 8 way. I can’t seem to find an example.
Does anyone have a working example of this:
I get I can use a legacy before save hook, but would like to try out the SuiteCRM 8 way. I can’t seem to find an example.
Search the core code for implements RecordSaveHandlerInterface.
This will take you to a single instance of an example in core code:
/core/modules/Campaigns/Service/Record/SaveHandlers/CampaignsCreateUnsubscribeList.php
Note that RecordSaveHandlerInterface extends BaseModuleSaveHandlerInterface so keep an eye on that interface too, to know which methods you can override.
When you create your own Save handler in extensions directory, simply having your call include a implements RecordSaveHandlerInterface should be enough for Symfony to pick it up and load it where it should be loaded.
I recommend creating a simple class with empty methods and check that it’s loading before doing any actual code:
symfony console debug:autowiring YourClassName
or
php bin/console debug:autowiring YourClassName
Thanks @pgr. I guess I’m really leading the way here on some of this stuff! There isn’t alot of resources or other examples. Hopefully, bit by bit I can compile enough examples and use cases to make SuiteCRM 8 customization more friendly for others.
Awesome! The below user has provided lots of SuiteCRM 8 code changes. You could check that out.
As I know you use the API to sync to Mautic etc, be aware that I don’t think the Symfony code (Before/After save, retrieve etc) will run when using the V8 API.
Mark