|
HowToCreateAPlugin
How to create a plugin for Xinc 2.0
IntroductionThis 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 CodingPlugin ClassFile: 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 ClassFile: 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
|
Sign in to add a comment
Can you give an example of why you'd need to validate in both classes, rather than just one or the other?
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