Search code examples
socialengine

How to include external files in a SocialEngine module


I have created a SocialEngine module named MyAwesomeModule that adds a signup step to existing SocialEngine signup process. It is in application/modules/Myawesomemodule. Besides the files in this directory, it also depends on other files e.g. several created specifically for this module and placed in application/modules/User. The problem that I have is that when I build a package for this module in http://example.com/install/sdk/build, it only includes the files residing within the module directory itself. Other files that are required for this module to work and need to be copied to external directories (application/modules/User) are not included in the package.

I tried adding the list of external files inside package info file i.e.application/packages/module-myawesomemodule-4.0.0.json before building the package as follows:

"application\/modules\/User": {
    "type": "directory",
    "path": "application\/modules\/User",
    "structure": [
        {
            "path": "Plugin\/Signup\/Phone.php",
            "dir": false,
            "file": true,
            "perms": "0644",
            "size": 0,
            "sha1": null
        },
        {
            "path": "Form\/Signup\/Phone.php",
            "dir": false,
            "file": true,
            "perms": "0644",
            "size": 0,
            "sha1": null
        },
        {
            "path": "controllers\/PhoneController.php",
            "dir": false,
            "file": true,
            "perms": "0644",
            "size": 0,
            "sha1": null
        }
    ]
}

But, the external files named in the above snippet are not copied to the package when building. Also, it seems that the external files I named in the JSON file are gone in the destination package after installation. How can I solve this problem?


Solution

  • This is much easier than I thought, thanks to this SocialEngine Community post.
    All is required to add every file you want to your package is to include it in your manifest.php file for the module. As such:

    return array(
        'package' =>
        array(
            'type' => 'module',
            'name' => 'advancedsmsplugin',
            'version' => '4.0.0',
            'sku' => 'com.company.sms',
            'path' => 'application/modules/Advancedsmsplugin',
            'title' => 'Advanced SMS Plugin',
            'description' => 'Advanced SMS Plugin',
            'author' => 'Company Ltd.',
            'callback' =>
            array(
                'class' => 'Engine_Package_Installer_Module',
            ),
            'actions' =>
            array(
                0 => 'install',
                1 => 'upgrade',
                2 => 'refresh',
                3 => 'enable',
                4 => 'disable',
            ),
            'directories' =>
            array(
                0 => 'application/modules/Advancedsmsplugin',
            ),
            'files' =>
            array(
                0 => 'application/languages/en/advancedsmsplugin.csv',
                1 => 'application/modules/User/Form/Signup/Phone.php',
                2 => 'application/modules/User/Plugin/Signup/Phone.php',
                3 => 'application/testpackage.html'
            ),
        ),
    );
    ?>