Latest JAS v1.1.0
144 plugins online

Plugins / Components / Setup

When installing a plugin you typically want it to setup some basic stuff for it to get going.

Its class name should start with the "Plugin_Setup_" followed by the plugin name, e.g. Plugin_Setup_skeleton. It generally should contain 1 function and has 4 optional ones:
  • init
    This should contain the initial logic that is needed to run the setup. Note that this shouldn't actually execute anything but merely setup the basics (see below for some examples)
  • preSetup / postSetup / preDeSetup / postDeSetup
    The functions are triggered before or after the setup (or desetup) and should contain your custom logic that isn't defined in the init function.

Plugin setup class
PHP
class Plugin_Setup_skeleton extends Base_Plugin
{
  function init()
  {
    $this->modules(); //make sure all skeleton module tables created

    $this->mkdir($_path["project"]["style"]); //create a directory

    $this->file("setup/skeleton.css", $_path["project"]["style"]); //copy a file

    $this->data("categories", "name", Array( //create category for pluginConfigs
    "name" => "Skeleton",
    "moduleLock" => true,
    "module" => Array("skeleton_pluginConfigs"),
    ));

    $this->data("skeleton_pluginConfigs", Array("plugin", "key"), Array(
    Array(
      "catnr" => (object) Array("set" => 0, "entry" => 0, "field" => "nr"), //use nr value from first entry in first data set
      "plugin" => "skeleton",
      "key" => "First key",
    ),
    Array(
      "catnr" => (object) Array("set" => 0, "entry" => 0, "field" => "nr"), //use nr value from first entry in first data set
      "plugin" => "skeleton",
      "key" => "Second key",
    ),
    ));

    return true;
  }

  function preSetup()
  {
    //...
  }
  function postSetup()
  {
    //...
  }
  function preDeSetup()
  {
    //...
  }
  function postDeSetup()
  {
    //...
  }
}

Comments (0)