Question

I have some 3rd party modules in vendor, which are zfcuser and hybridauth. I added some of my code in the Controller and View classes. While I updated composer packages and all packages are updated and all of my manual code is changed/removed with the new code it received. What could be its solution?

Was it helpful?

Solution

You should NEVER change third party vendor code. It will make you unable to update the module as you experienced already.

If your find a bug in vendor code which would also hit others it would be a good idea to create a Pull Request to get your changes merged in the master repository. In the meantime you could fork the github repo to your own github account, make the changes and refer to your forked version in the composer config.

If you want to add custom code to the module it is best practice to create you own module (i.e. MyUser) and overwrite the Controllers and views to reflect your needs. See here how to overwrite the built in view files. Just make sure your module is loaded AFTER the ZfcUser module. The template resolver needs to check for templates in your module first.

To overwrite controllers you have to overwrite the controller pluginmanager configuration, so the pluginManager retrieves your custom controller instead of the default one. Put this in your module.config.php. Alternatively you can use the getControllerConfig method in the Module class.

return array(
    'controllers' => array(
        'invokables' => array(
            'zfcuser' => 'MyNamespace\Controller\UserController',
        ),
    ),
);

Same idea applies to services. Just overwrite the alias in the configuration and make sure your module is loaded after the ZfcUser module.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top