My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday, 7AM PST due to brief network maintenance
                
Search
for
Updated Dec 04, 2007 by arnoschn
HowToCreateAPlugin  
How to create a plugin for Xinc 2.0

Introduction

This documentation is "living" ;) It won't be finished until Xinc 2.0 is finally released. The Plugin-Interface might change slightly in the upcoming weeks.

Plugin Coding

Plugin Class

File: MyDomain/Plugin/ModificationSet/Fake.php

<?php
....
require_once 'Xinc/Plugin/Base.php';
require_once 'MyDomain/Plugin/ModificationSet/Fake/Task.php';

class MyDomain_Plugin_ModificationSet_Fake extends Xinc_Plugin_Base
{
    public function getTaskDefinitions()
    {
        return array(new MyDomain_Plugin_ModificationSet_Fake_Task($this));
    }

    public function validate()
    {
        // do all necessary checks here to validate that the plugin
        // can work properly
        return true;
    }

}

Task Class

File: MyDomain/Plugin/ModificationSet/Fake/Task.php

<?php
....
require_once 'Xinc/Plugin/Task/Base.php';

class MyDomain_Plugin_ModificationSet_Fake_Task extends Xinc_Plugin_Task_Base
{
    public function getPluginSlot(){
        /**
         * see Xinc/Plugin/Slot.php for available slots
         */
        return Xinc_Plugin_Slot::PRE_PROCESS;
    }

    public function validate()
    {
        // do all necessary checks here to validate that the plugin
        // can work properly
        return true;
    }
    public function getName(){
         // return the task-element-name you want to use
         return "fake";
    }

    public function process(Xinc_Build_Interface &$build){
          // do whatever you need todo here and set the Build-status on the project
          // see Xinc/Build/Interface.php for available statuses

          // if subtasks have been registered loop over $this->_subtasks and call 
          // process() on them
          $build>setStatus(Xinc_Build_Interface::PASSED);
    }

}

Include your plugin in Xinc

  1. Edit /etc/xinc/system.xml in the <plugins/> section
  2. insert the following line: <plugin filename="MyDomain/Plugin/ModificationSet/Fake.php" classname="MyDomain_Plugin_ModificationSet_Fake"/>
  3. Restart xinc: /etc/init.d/xinc restart
  4. check the /var/log/xinc.log for errors
  5. Good luck!

Comment by majelbstoat, Dec 12, 2007

Can you give an example of why you'd need to validate in both classes, rather than just one or the other?

Comment by arnoschn, Dec 22, 2007

Plugin::validate():

The plugin validation is done while initiating the system. It makes sure that the Plugin and its Tasks, Widgets, Apis can function properly, i.e. that needed extensions are installed etc.

Task::validate():

The task needs to validate if all the required attributes are present for example:

<svn/> : would not validate since it needs the directory attribute

Hope that helps.

Regards, Arno


Sign in to add a comment
Hosted by Google Code