Hi!
I need to implements a feature in the project in which there will be an external file storage. Iām planning to store uploaded documents straight into SharePoint. For that purpose I planned to call service (which should handle file transferring to SharePoint) in SugarController::action_save() method. I added pre_save(), post_save() and, of course, action_save() methods right into CustomController class in modules/Contacts/controller.php and surprisingly found out that none of them was actually called after clicking Save button in Contacts EditView form. Even SugarController::action_save() method was not called during debug session.
This is the first time I needed to dig into this part of SuiteCRM magic. And it was really amazing for me. Itās extremely weird since SugarCRM Developer Guide clearly suggests to override those methods if needed http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Module_Framework/MVC/Controller/
I know everything about logic hooks and its ābefore_saveā variation. But Iād like to stay in controllerās layer to have āclearā request data.
So there are two questions
Am I wrong in catching those methods calls?
If not is it the only way to catch all the data after clicking Save button in ābefore_saveā logic hook?
I donāt know about the controller, but what exactly do you think might be missing from the logic hook? I think you can get everything there, in nice bean classes, with all the relationships you might need, etc.
To be honest we can have the bean instance in the controller also. But agreeā¦ I was not clear and precise enough in my initial post. Hereās my idea. I like Symfony approach on working with container in controllers. And I would like to reproduce the same approach in the project: get all dependencies needed from the container in the entry point of application (in controller!) and pass them to the service responsible for processing uploaded file. That is what I want to do in action_save()! The trick mentioned above in SugarCRM dev guide would let me to do the things in the Symfony-like way if it works. Logic hook toolbox is spread all over the code - beans, relationships, views, api calls, etc. And specially ābefore_saveā is mostly SugarBean-related thing in my opinion. Of course I can even use SugarBean::save() method to call the logic needed. But in fact I donāt want to save almost anything in my custom bean I would like to create for this particular use case besides local id and id on the remote system. I would like the SugarBean to be āpassiveā, not Active Record :). Of course it looks like more ideology than technology.