作为初级开发人员,我在与一位高级开发人员争论,他说我的路由错误且危险,可能所有请求都可以路由到 homepege,但我认为他错了,我什至对其进行了测试。他说,通过添加这个
$this->router[] = new Route('/', 'Front:Bridge:default');
低于此定义的所有路由都将被忽略,所有内容都将路由到 Front:Bridge
我认为这是 BS,因为该路线明确指出,仅将请求直接重定向到 Web 根目录到 Front:Bridge。应用程序的功能确实没有改变,但他坚持我肯定会在某处引入不可预见的错误。
整个 routerFactory 供参考
public function getRouter()
{
$this->router[] = new Route('/muj-ucet[/<action=default>]', [
'module' => 'Front',
'presenter' => 'Account',
'action' => [
Route::VALUE => 'default',
Route::FILTER_TABLE => [
'zpravy' => 'message',
'profil' => 'profile',
'objednavky' => 'orders',
'sprava-uzivatelu' => 'users'
],
],
]);
$this->router[] = new Route('/', 'Front:Bridge:default');
$this->router[] = new Route('[<lang [a-zA-Z]{2}>/]html/prihlaseni.html', 'OnlineUser:Front:Login:default');
$this->router[] = new Route('/superadmin/prihlaseni', 'OnlineUser:Front:Login:superAdminLogin');
$this->router[] = new Route('[<lang [a-zA-Z]{2}>/]html/registrace.html', 'OnlineUser:Front:Registration:default');
$this->router[] = new Route('/potvrzeni-registrace', Linker::ACTION_CONFIRM_REGISTRATION);
$this->router[] = new Route('/aktivace-uctu', Linker::ACTION_ACTIVATION_ACCOUNT);
$this->router[] = new Route('/nove-heslo', Linker::ACTION_FORGOT_PASSWORD);
$this->router[] = new Route('/logout', 'OnlineUser:Front:Login:logout');
$this->router[] = new Route('/validace/<action=default>', [
'module' => 'OnlineUser:Front',
'presenter' => 'Validation',
'action' => [
Route::VALUE => 'default',
Route::FILTER_TABLE => [
'validace-emailu' => 'validateEmailNotExists',
'validace-ico' => 'validateIcNotExists',
'validace-ico-ares-heo' => 'validateIcAresAndHeO',
],
],
]);
$this->router[] = new Route('[<path .+>]', 'Front:Bridge:default');
return $this->router;
}