Suite 8: access Symfony container from legacy

is there a way to access the Symfony container from the legacy app?
I have a logic hook from which I’d like to access my service. But as the service uses dependency injections, I can’t just create a new instance.

I tried to find if there’s no ‘application’ instance in the global variables, from which I could call container and thus my service, but I didn’t find anything.


Hi @peterkracik,

Welcome to the community! :wave: and thank you for trying out SuiteCRM 8.

There is no way to communicate from Legacy to Suite 8 side.

  • We try to look to legacy as a black box “API” that Suite 8 uses (roughly speaking)
  • We have been trying to avoid dependencies from legacy to Suite 8, as we will want to remove legacy in the future.

I’m not yet sure if we will want to add that kind of dependency.

There maybe ways to avoid a logic hook, depending on what you are trying to do. If not possible, its probably best to create a class on legacy side.

thank you @clemente.raposo :slight_smile:

And is there a way to implement a logic hook in the Symfony part instead of the legacy part? Is there some event handling mechanism?

I have this hook:
$hook_array['after_save'][] = [1, 'Notify users', 'custom/modules/myModule/MyModuleNotificationHook.php', 'MyModuleNotificationHook', 'sendNotification'];

And from the MyModuleNotificationHook I need to access let’s say NotificationService.
I can’t move it, because it has dependencies on other services, so I would have to somehow duplicate it in the legacy.
If I could somehow move the hook to the symfony part, it would solve my problems.

Hi @peterkracik,

With Suite 8 side only code what you can do is override the RecordHandler method that saves the record. but that will only trigger your notification when the record is saved from the front end.

it won’t trigger on workflows or when the record is updated in other logic on the backend.

Is it enough for you if it triggers on frontend save?