cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]Routing parsing with multi-lingual

Open nghenglim opened this issue 12 years ago • 2 comments

According to vokuro syntax, if I do http://localhost/vokuro/zh/reset-password/somecode/3

<?php

$router = new Phalcon\Mvc\Router();
$router->add('/confirm/{code}/{uid}', array(
    'controller' => 'user_control',
    'action' => 'confirmEmail'
));
$router->add('/reset-password/{code}/{uid}', array(
    'controller' => 'user_control',
    'action' => 'resetPassword'
));
$router->add('/{language:[a-z]{2}+}/confirm/{code}/{uid}', array(
    'controller' => 'user_control',
    'action' => 'confirmEmail'
));
$router->add('/{language:[a-z]{2}+}/reset-password/{code}/{uid}', array(
    'controller' => 'user_control',
    'action' => 'resetPassword'
));
$router->add('/{language:[a-z]{2}+}/:controller/:action/:params/?', array(
  'controller' => 2,
  'action' => 3,
  "params"     => 4,
));
$router->add('/{language:[a-z]{2}+}/:controller/:action/?', array(
  'controller' => 2,
  'action' => 3,
));
$router->add('/{language:[a-z]{2}+}/:controller/?', array(
  'controller' => 2,
));
$router->add('/{language:[a-z]{2}+}/?', array(
  'controller' => 'index',
  'action' => 'index',
));
return $router;

the router will parse it reset-password as controller instead of using user_control as controller.

Vokuro\Controllers\ResetPasswordController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('Vokuro\Controll...', 2)
#1 [internal function]: Phalcon\Dispatcher->dispatch()
#2 C:\xampp\htdocs\vokuro\public\index.php(27): Phalcon\Mvc\Application->handle()
#3 {main}

nghenglim avatar Jan 13 '14 13:01 nghenglim

Routes are traversed backwards, ie from the last one to the first one.

/zh/reset-password/somecode/3 will be matched by /{language:[a-z]{2}+}/:controller/:action/:params/?.

Try swapping

/{language:[a-z]{2}+}/:controller/:action/:params/?

and

'/{language:[a-z]{2}+}/reset-password/{code}/{uid}'

ghost avatar Jan 13 '14 13:01 ghost

Okay I've misunderstood it.

nghenglim avatar Jan 13 '14 13:01 nghenglim