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
|
|
@ -9,12 +9,19 @@ use Phalcon\Mvc\Application;
|
|||
|
||||
class Bootstrap extends Injectable
|
||||
{
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
protected $_app;
|
||||
|
||||
public function __construct(DiInterface $di = null)
|
||||
{
|
||||
if ($di === null) {
|
||||
$di = new DiDefault();
|
||||
}
|
||||
$this->setDI($di);
|
||||
|
||||
$this->_app = new Application();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,6 +41,14 @@ class Bootstrap extends Injectable
|
|||
$di->get('debugger')->listen(true, true);
|
||||
}
|
||||
|
||||
// Modules
|
||||
$this->_app->registerModules([
|
||||
'main' => [ 'className' => 'App\Module\Main' ],
|
||||
'backend' => [ 'className' => 'App\Module\Backend' ],
|
||||
]);
|
||||
|
||||
$this->_app->setDefaultModule('main');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +59,7 @@ class Bootstrap extends Injectable
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
$app = new Application($this->getDI());
|
||||
return $app->handle()->getContent();
|
||||
$this->_app->setDI($this->getDI());
|
||||
return $this->_app->handle()->getContent();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class Services extends DiDefault
|
|||
$loader->registerNamespaces(array(
|
||||
'App\Controller' => $config->application->controllersDir,
|
||||
'App\Listener' => $config->application->listenersDir,
|
||||
'App\Module' => $config->application->modulesDir,
|
||||
'App\Model' => $config->application->modelsDir,
|
||||
'App\Form' => $config->application->formsDir,
|
||||
'Httpcb' => $config->application->libraryDir,
|
||||
|
|
@ -222,7 +223,7 @@ class Services extends DiDefault
|
|||
|
||||
$view = new View();
|
||||
|
||||
$view->setViewsDir($config->application->viewsDir);
|
||||
$view->setViewsDir([ $config->application->viewsDir ]);
|
||||
$view->setLayoutsDir('_layouts/');
|
||||
$view->setPartialsDir('_partials/');
|
||||
|
||||
|
|
|
|||
Reference in a new issue