[*] Project : Add possibility to use admin controllers in modules
This commit is contained in:
@@ -171,6 +171,9 @@ class AdminControllerCore extends Controller
|
|||||||
/** @var array required_fields to display in the Required Fields form */
|
/** @var array required_fields to display in the Required Fields form */
|
||||||
public $required_fields = array();
|
public $required_fields = array();
|
||||||
|
|
||||||
|
/** @var module contain the controller */
|
||||||
|
public $module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array actions to execute on multiple selections
|
* @var array actions to execute on multiple selections
|
||||||
* Usage:
|
* Usage:
|
||||||
@@ -2583,6 +2586,15 @@ class AdminControllerCore extends Controller
|
|||||||
*/
|
*/
|
||||||
public function createTemplate($tpl_name)
|
public function createTemplate($tpl_name)
|
||||||
{
|
{
|
||||||
|
// Use for module
|
||||||
|
if (!is_null($this->module))
|
||||||
|
{
|
||||||
|
$moduleTemplate = _PS_MODULE_DIR_.$this->module.'/templates/admin/'.$this->override_folder.$tpl_name;
|
||||||
|
|
||||||
|
if ($this->viewAccess() && file_exists($moduleTemplate))
|
||||||
|
return $this->context->smarty->createTemplate($moduleTemplate, $this->context->smarty);
|
||||||
|
}
|
||||||
|
|
||||||
// Use override tpl if it exists
|
// Use override tpl if it exists
|
||||||
// If view access is denied, we want to use the default template that will be used to display an error
|
// If view access is denied, we want to use the default template that will be used to display an error
|
||||||
if ($this->viewAccess()
|
if ($this->viewAccess()
|
||||||
|
|||||||
@@ -342,7 +342,13 @@ class DispatcherCore
|
|||||||
// Instantiate controller
|
// Instantiate controller
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Controller::getController($controller_class)->run();
|
$controller = Controller::getController($controller_class);
|
||||||
|
|
||||||
|
// Controller comes from a module set "module name"
|
||||||
|
if (!empty($controller_row['module']) && $controller_type == 'controller')
|
||||||
|
$controller->module = $controller_row['module'];
|
||||||
|
|
||||||
|
$controller->run();
|
||||||
}
|
}
|
||||||
catch (PrestaShopException $e)
|
catch (PrestaShopException $e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user