FEATURE: Adding Real MVC Support for plugins - Adding some plugin data into cotroller object and fixing a error when the controller action not found

This commit is contained in:
Erik Amaru Ortiz
2013-06-18 12:20:48 -04:00
parent 643d19fdc6
commit 6221e11426
2 changed files with 43 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ class Controller
* @var boolean debug switch for general purpose
*/
public $debug = null;
/**
*
* @var array - private array to store proxy data
@@ -45,6 +46,18 @@ class Controller
*/
private $layout = '';
/**
*
* @var string contains the pluin name, in case the controller is on a plugin
*/
private $pluginName = '';
/**
*
* @var string contains the plugin path
*/
private $pluginHomeDir = '';
/**
* Magic setter method
*
@@ -292,5 +305,25 @@ class Controller
{
G::header( "Location: $url" );
}
public function setPluginName($name)
{
$this->pluginName = $name;
}
public function getPluginName()
{
return $this->pluginName;
}
public function setPluginHomeDir($dir)
{
$this->pluginHomeDir = $dir;
}
public function getPluginHomeDir()
{
return $this->pluginHomeDir;
}
}

View File

@@ -828,17 +828,17 @@ if (substr( SYS_COLLECTION, 0, 8 ) === 'gulliver') {
if (is_file($pluginControllerPath. $controllerClass . '.php')) {
require_once $pluginControllerPath. $controllerClass . '.php';
$isControllerCall = true;
} elseif (is_file($pluginControllerPath. ucfirst($controllerClass) . '.php')) {
$controllerClass = ucfirst($controllerClass);
require_once $pluginControllerPath. $controllerClass . '.php';
$isControllerCall = true;
} elseif (is_file($pluginControllerPath. ucfirst($controllerClass) . 'Controller.php')) {
$controllerClass = ucfirst($controllerClass) . 'Controller';
require_once $pluginControllerPath. $controllerClass . '.php';
}
//if the method exists
if (is_callable(array($controllerClass, $controllerAction))) {
$isControllerCall = true;
} else {
$isControllerCall = false;
}
}
@@ -986,6 +986,12 @@ if (! defined( 'EXECUTE_BY_CRON' )) {
$controller = new $controllerClass();
$controller->setHttpRequestData($_REQUEST);//NewRelic Snippet - By JHL
transactionLog($controllerAction);
if ($isPluginController) {
$controller->setPluginName($pluginName);
$controller->setPluginHomeDir(PATH_PLUGINS . $pluginName . PATH_SEP);
}
$controller->call($controllerAction);
} elseif ($isRestRequest) {
//NewRelic Snippet - By JHL