Documentation

Migrations

All the common extension types for HUBzero can include their own migrations directory. Migrations are used for installing the extension into the required tables for the CMS to know about said extension's existence, installing any needed tables, installing sample data, etc.

To illustrate the typical component directory structures and files:

/app
.. /plugins
.. .. /system
.. .. .. /example
.. .. .. .. /migrations
.. .. .. .. .. /Migration20190301102219PlgSystemExaple.php
.. .. .. .. example.php

See the Migrations documentation for more about naming conventions, setup, etc.

Plugins typically have at least one initial migration for registering the plugin with the CMS which just involves calling the addPluginEntry helper method:

<?php

use Hubzero\Content\Migration\Base;

// No direct access
defined('_HZEXEC_') or die();

/**
 * Migration script for registering the example plugin
 **/
class Migration20190301102219PlgSystemExample extends Base
{
    /**
     * Up
     **/
    public function up()
    {
        // Register the component Note the 'com_' prefix is optional.
        //
        // @param   string  $folder   (required) Plugin folder
        // @param   string  $element  (required) Plugin element
        // @param   int     $enabled  (optional, default: 1) Whether or not the plugin should be enabled
	// @param   string  $params          (optional) Plugin params (if already known)
        $this->addPluginEntry('system', 'example');
    }

    /**
     * Down
     **/
    public function down()
    {
        $this->deletePluginEntry('system', 'example');
    }
}

That's all there is to it! The addPluginEntry adds the necessary entries to the needed database tables for the CMS to be aware of the plugin's existence.

Last modified: