How to change core module files in socialengine4

2019-07-18 09:16发布

问题:

I am developing modules in socialengine4. Now I need to change the core functionality of the application. I need to make some changes in user signup process by adding some core features like proving auto complete fields.

I know this is a core feature of User module of SocialEngine. But This is not a good practice because any update of socialengine will override my changes.

I have searched the solution but couldn't be able to find any thing. I know if you want to change any thing in core modules of magento, it directs us specific way to do that. Similarly I want to know the process, how can I change in socialengine?

Regards

回答1:

It depends on what you want to change on SocialEngine core.

To change the signup process (for example add a new step), you have to add a new row in this table engine4_user_signup and implement your new step.

If you just want to add some actions after a user signup successfully, you can add a Hook in your custom module.

To implement a hook in Socialengine, following these steps: Define hook in manifest file, will be something like below

'hooks' => array(
    array(
      'event' => 'onUserCreateAfter',
      'resource' => 'YourPluginName_Plugin_Signup',
    ),
  ),

In the plugin class YourPluginName_Plugin_Signup, add this method onUserCreateAfter

public function onUserCreateAfter($payload)
{
    $user = $payload->getPayload();
    //Do whatever you want
}

Hope this can help you.



回答2:

I'm not the slightest bit familiar with Social Engine, but seeing that it offers plugins:

http://www.socialengine.com/customize/se4/plugins

… I feel rather safe to suggest that there's some kind of API that allows you to hook into, and probably override, whatever core functionality you're not entirely happy with.

If it's anything like Symfony, Drupal or WordPress, there more often than not is some kind of event, hook, action, filter, whatever, at a key step in the process. It should allow you to catch whatever core has come up with to that point, trash it, and entirely override and "redo" it. The key here is to have a thorough understanding of the APIs involved — no amount of asking SO questions will spare you from reading the docs.

What occasionally happens, that being said, is that the only plausible candidate event is uncooperative, in the sense that it comes too late and only allows you to "add" something extra to what has been done already. In this case, you can take the higher ground and fight back by finding an earlier event. Start an output buffer on it, and trash this buffer in the uncooperative event. Now, you redo things as the way you want them, without losing your changes during upgrades.

Note that doing the latter is not risk-free, though. If anything, it adds a huge burden on you: if core changes anything in this area that you've redone from the ground up, you need to make sure that your overriding it doesn't break when you upgrade the application.