Hi,
We have a problem with setting language in our backend module. We use Phalcon 2.1.0 with PHP 5.6.14.
The corresponding part of our router looks like this:
$router = new \Phalcon\Mvc\Router();
$router->setDefaultModule("frontend");
//This is the desired route
$router->add("/admin/set-language/{language:[a-z]+}", array(
'module' => 'backend',
'namespace' => 'App\Modules\Backend\Controllers',
'controller' => 'index',
'action' => 'setLanguage'
));
/* have some other routes here */
//This route is matched
$router->add("/admin/:controller/:action(/)?", array(
'module' => 'backend',
'namespace' => 'App\Modules\Backend\Controllers',
'controller' => 1,
'action' => 2
));
/* have some other routes here */
The language setter buttons look like <a href="/admin/set-language/hu">HU</a>
.
The language setter function is in the backend's ControllerBase like setLanguageAction
(it's like in the Phalcon examples).
When we click on the language setter button, we get: App\Modules\Backend\Controllers\SetLanguageController handler class cannot be loaded
.
As we dumped out the router match, it showed that not the desired route has matched, but the other one which threats the part after "/admin/" as controller.
Why the route is not mached even if it's correct? Is there any mistake we can't see?
As we know, we should list the custom routes from the specific ones to the more general ones, right? So what's the problem here?
Thanks in advance.