[英]How can I catch the controller/action values of a request before dispatch?
Zend框架:
I have the following url /base/url/[number]/[string]
OR /base/url/action/controller/param/value
我想在/base/url/[number]/[string]
下將其轉換為/ base / url / controller / a / action / b / id / [number] / name / [string] a和b是常量(即,每次在操作處看到數字時,我都使用相同的值)。
在將動作和控制器值分派之前,在哪里可以捕獲它們?
您可以在routeShutdown()(一旦選擇路由)中的Controller插件中或preDispatch()(在每次分發控制器之前)中接收動作和控制器。 我猜您會使用routeShutdown。 您可以訪問“請求”,因此可以將控制器和操作設置為任何內容。
您可以創建一個自定義Route來處理這種路由,並將其分派到正確的控制器和URL。
例如:
$router = $front->getRouter();
$router->addRoute(
'my_route',
new Zend_Controller_Router_Route(
':number/:string',
array(
'controller' => 'your_controller',
'action' => 'your_action'
)
)
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.