Make the application modular to have a "main" and "backend" part.
This commit is contained in:
parent
884f721002
commit
e5b0e1fcfd
28 changed files with 112 additions and 7 deletions
47
app/modules/Base.php
Normal file
47
app/modules/Base.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Module;
|
||||
|
||||
use Phalcon\Loader,
|
||||
Phalcon\DiInterface,
|
||||
Phalcon\Mvc\Dispatcher,
|
||||
Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
|
||||
abstract class Base implements ModuleDefinitionInterface
|
||||
{
|
||||
protected $_controllerPath;
|
||||
|
||||
protected $_controllerNamespace;
|
||||
|
||||
protected $_viewDir;
|
||||
|
||||
/**
|
||||
* Register a specific autoloader for the module
|
||||
*/
|
||||
public function registerAutoloaders(DiInterface $di = null)
|
||||
{
|
||||
$loader = new Loader();
|
||||
|
||||
$loader->registerNamespaces([
|
||||
$this->_controllerNamespace => $this->_controllerPath,
|
||||
]);
|
||||
|
||||
$loader->register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register specific services for the module
|
||||
*/
|
||||
public function registerServices(DiInterface $di)
|
||||
{
|
||||
$dispatcher = $di->get('dispatcher');
|
||||
|
||||
$dispatcher->setDefaultNamespace($this->_controllerNamespace);
|
||||
|
||||
$di->get('view')->setViewsDir(array_merge(
|
||||
[ $this->_viewDir ],
|
||||
(array) $di->get('view')->getViewsDir()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in a new issue