I would like to use a modified simple-subcontroller pattern. It has the following structure.
project/
app/
controllers/
admin/
IndexController.php
user/
IdexController.php
LoginController.php
...
plugins/
SecurityPlugin.php
(bsed on the following) https://github.com/phalcon/mvc/tree/master/simple-subcontrollers
Of those who can access user, we want to make sure that only a specific person can access admin and below, so when accessing admin directly, we want to forward to Login under user. For that purpose, I wrote the following SecurityPlugin.
class SecurityPlugin extends \Phalcon\Mvc\User\Plugin
{
public function beforeExecuteRoute($event, $dispatcher)
{
......
$dispatcher->forward(['controller' => 'login', 'action' => 'index',]);
// the result is the same
// $dispatcher->forward(['controller' => 'user\login', 'action' => 'index',]);
return false;
}
}
However, it seems to look for it under admin and will not find LoginController. Isn't it possible to use it like this?
Maybe it should be like this (although not done yet)?
project/
app/
controllers/
user/
IdexController.php
LoginController.php
admin/
IndexController.php
...
plugins/
SecurityPlugin.php