Skip to content

Commit

Permalink
Moved back base controllers with routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Aug 16, 2019
1 parent fbbefcd commit 4549813
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/config/routes.php → src/Config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use Phalcon\Mvc\Router\Group as RouterGroup;

$routes = new RouterGroup([
'module' => 'phlexusadmin',
'module' => 'baseadmin',
'controller' => 'index',
'action' => 'index',
'namespace' => 'Phlexus\Modules\PhlexusAdmin\Controllers',
'namespace' => 'Phlexus\Modules\BaseAdmin\Controllers',
]);

$routes->addGet('/admin', [
Expand Down
21 changes: 21 additions & 0 deletions src/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace Phlexus\Modules\BaseAdmin\Controllers;

use Phalcon\Mvc\Controller;

/**
* Abstract Admin Controller
*
* @package Phlexus\Modules\Admin\Controllers
*/
abstract class AbstractController extends Controller
{
/**
* @return void
*/
public function initialize(): void
{
$this->tag->appendTitle(' - Phlexus Admin');
}
}
4 changes: 2 additions & 2 deletions src/Controllers/AuthController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php declare(strict_types=1);

namespace Phlexus\Modules\PhlexusAdmin\Controllers;
namespace Phlexus\Modules\BaseAdmin\Controllers;

use Phalcon\Http\ResponseInterface;
use Phalcon\Mvc\Controller;

/**
* Class AuthController
*
* @package Phlexus\Modules\PhlexusAdmin\Controllers
* @package Phlexus\Modules\Admin\Controllers
*/
class AuthController extends Controller
{
Expand Down
21 changes: 21 additions & 0 deletions src/Controllers/ErrorsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace Phlexus\Modules\BaseAdmin\Controllers;

final class ErrorsController extends AbstractController
{
public function show402Action(): void
{
// Nothing here
}

public function show404Action(): void
{
// Nothing here
}

public function show500Action(): void
{
// Nothing here
}
}
16 changes: 11 additions & 5 deletions src/Controllers/IndexController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?php declare(strict_types=1);

namespace Phlexus\Modules\PhlexusAdmin\Controllers;
namespace Phlexus\Modules\BaseAdmin\Controllers;

use Phalcon\Mvc\Controller;

class IndexController extends Controller
/**
* Class IndexController
*
* @package Phlexus\Modules\Admin\Controllers
*/
final class IndexController extends AbstractController
{
/**
* @return void
*/
public function indexAction(): void
{

$this->tag->setTitle('Dashboard');
}
}
16 changes: 10 additions & 6 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php declare(strict_types=1);

namespace Phlexus\Modules\PhlexusAdmin;
namespace Phlexus\Modules\BaseAdmin;

use Phalcon\Di\DiInterface;
use Phalcon\Loader;
use Phalcon\Mvc\View\Engine\Volt;
use Phlexus\Module as PhlexusModule;
use Phlexus\Modules\BaseAdmin\Events\Listeners\AuthenticationListener;
use Phlexus\Modules\BaseAdmin\Events\Listeners\DispatcherListener;

/**
* Admin Module
Expand All @@ -26,7 +28,7 @@ class Module extends PhlexusModule
*/
public function getHandlersNamespace(): string
{
return 'Phlexus\Modules\PhlexusAdmin';
return 'Phlexus\Modules\BaseAdmin';
}

/**
Expand Down Expand Up @@ -57,7 +59,6 @@ public function registerServices(DiInterface $di = null)

$themePath = $theme->themes_dir . self::PHLEXUS_ADMIN_THEME_NAME;
$cacheDir = $theme->themes_dir_cache;
$defaultBaseLayout = $themePath . '/views/layouts/default';

$view->registerEngines([
'.volt' => function ($view) use ($cacheDir, $di) {
Expand All @@ -69,8 +70,11 @@ public function registerServices(DiInterface $di = null)
return $volt;
}
]);
$view->setMainView($defaultBaseLayout);
$view->setViewsDir($themePath . '/views/');
$view->setVar('defaultBaseLayout', $defaultBaseLayout);

$view->setMainView($themePath . '/layouts/default');
$view->setViewsDir($themePath . '/');

$di->getShared('eventsManager')->attach('dispatch', new DispatcherListener());
$di->getShared('eventsManager')->attach('dispatch:beforeDispatchLoop', new AuthenticationListener());
}
}

0 comments on commit 4549813

Please sign in to comment.