changes to plugin classes and a few more bugs fixed
Esse commit está contido em:
@@ -144,8 +144,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads data from the passed project
|
||||
* Alias for MindProject::openProject
|
||||
* Loads data from the passed project.
|
||||
* Alias for MindProject::openProject.
|
||||
*
|
||||
* @param AssocArray $p
|
||||
* @return boolean
|
||||
|
||||
@@ -358,9 +358,10 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
||||
* each program::runAction command blocks
|
||||
*/
|
||||
public function runAction(){
|
||||
|
||||
$this->runPlugins('before');
|
||||
|
||||
// yea, I know it looks crazy!
|
||||
// yea, I know it looks a bit crazy!
|
||||
if(is_string($this->commandAction))
|
||||
$this->{$this->commandAction}();
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class MindPlugin
|
||||
abstract class MindPlugin
|
||||
{
|
||||
public $trigger= null;
|
||||
public $event= 'after';
|
||||
@@ -32,12 +32,16 @@
|
||||
*/
|
||||
static function addPlugin(&$plugin)
|
||||
{
|
||||
if(in_array($plugin->trigger, Mind::$triggers))
|
||||
{
|
||||
//echo $plugin->name." - ".$plugin->trigger."\n\n";
|
||||
|
||||
//print_r(Mind::$triggers);
|
||||
//if(in_array($plugin->trigger, Mind::$triggers))
|
||||
//{
|
||||
if(!isset(Mind::$pluginList[$plugin->trigger]))
|
||||
Mind::$pluginList[$plugin->trigger]= Array( 'before'=>Array(),
|
||||
'after'=>Array());
|
||||
Mind::$pluginList[$plugin->trigger][$plugin->event][]= $plugin;
|
||||
}
|
||||
//}
|
||||
//print_r(Mind::$pluginList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
class PluginOne extends MindPlugin implements plugin
|
||||
{
|
||||
/**
|
||||
* These are the properties you will have to set
|
||||
*/
|
||||
public $name= "Plugin One";
|
||||
public $version= "0.1";
|
||||
public $description = "This is a demo plugin, disabled by default";
|
||||
@@ -18,7 +21,7 @@
|
||||
// change this flag to true and execute the test program
|
||||
// to see this plugin running
|
||||
public $active= true;
|
||||
|
||||
|
||||
public function run()
|
||||
{
|
||||
echo "EXECUTING THE PLUGIN ONE!!!\n";
|
||||
@@ -26,7 +29,7 @@
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setTrigger('test');
|
||||
$this->setEvent('before');
|
||||
$this->setTrigger('info');
|
||||
$this->setEvent('after');
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// change this flag to true and execute the test program
|
||||
// to see this plugin running
|
||||
public $active= true;
|
||||
public $active= false;
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
@@ -42,6 +42,15 @@ EOT
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function projectExists($projectName)
|
||||
{
|
||||
$db= new MindDB();
|
||||
$data= $db->query("SELECT count(1) as count
|
||||
from project
|
||||
where name='".$projectName."'");
|
||||
return $data[0]['count'];
|
||||
}
|
||||
|
||||
public function action()
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
@@ -53,7 +62,7 @@ EOT
|
||||
$this->projectFileName= urlencode($this->argName);
|
||||
$this->projectfile= Mind::$projectsDir.$this->projectFileName;
|
||||
|
||||
if(file_exists($this->projectfile))
|
||||
if($this->projectExists($this->argName))
|
||||
{
|
||||
Mind::write('projectAlreadyExists', true, $this->argName);
|
||||
return false;
|
||||
@@ -124,25 +133,28 @@ EOT
|
||||
$db->execute($qr_vsProj);
|
||||
$db->execute("COMMIT");
|
||||
|
||||
Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile);
|
||||
chmod($this->projectfile, 0777);
|
||||
|
||||
Mind::write('projectCreated', true, $this->argName);
|
||||
|
||||
$ini= file_get_contents($iniSource);
|
||||
$ini= str_replace('<idiom>',
|
||||
$cP['default_human_language'],
|
||||
$ini);
|
||||
$ini= str_replace('<technology>',
|
||||
$cP['default_machine_language'],
|
||||
$ini);
|
||||
$ini= str_replace('<dbms>',
|
||||
$cP['default_dbms'],
|
||||
$ini);
|
||||
file_put_contents(Mind::$projectsDir.
|
||||
$this->argName.
|
||||
'/mind.ini',
|
||||
$ini);
|
||||
if(!file_exists($this->projectfile) && !file_exists($iniSource))
|
||||
{
|
||||
Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile);
|
||||
chmod($this->projectfile, 0777);
|
||||
|
||||
Mind::write('projectCreated', true, $this->argName);
|
||||
|
||||
$ini= file_get_contents($iniSource);
|
||||
$ini= str_replace('<idiom>',
|
||||
$cP['default_human_language'],
|
||||
$ini);
|
||||
$ini= str_replace('<technology>',
|
||||
$cP['default_machine_language'],
|
||||
$ini);
|
||||
$ini= str_replace('<dbms>',
|
||||
$cP['default_dbms'],
|
||||
$ini);
|
||||
file_put_contents(Mind::$projectsDir.
|
||||
$this->argName.
|
||||
'/mind.ini',
|
||||
$ini);
|
||||
}
|
||||
|
||||
Mind::openProject(Array('pk_project'=>$key,
|
||||
'name'=>$this->argName));
|
||||
|
||||
@@ -49,6 +49,8 @@ EOT
|
||||
ob_flush();
|
||||
echo shell_exec($_MIND->conf['phpunit-src']." "._MINDSRC_."/Tests/");
|
||||
}
|
||||
ob_end_flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
private function runStep1()
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
*/
|
||||
$this->setCommandName('modeloteste')
|
||||
->setDescription("This is a model command, only")
|
||||
//->setFileName('modeloTeste') // use this if your class has NOT the same name as its file
|
||||
->setRestrict(false)
|
||||
->setHelp("A longer text, explaining the command")
|
||||
->setAction(function($class){
|
||||
|
||||
externo
+5
@@ -65,6 +65,11 @@ abstract class Setup {
|
||||
}
|
||||
}
|
||||
|
||||
public static function databaseAlreadyExists()
|
||||
{
|
||||
return file_exists('mind3rd/SQLite/mind');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the system requirements.
|
||||
*
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário