Nasıl sevk önce bir isteği denetleyicisi / eylem değerleri yakalayabilirsiniz?

2 Cevap php

Zend Framework:

I have the following url  /base/url/[number]/[string] 
OR                        /base/url/action/controller/param/value

I want in the case of /base/url/[number]/[string] to transform it to /base/url/controller/a/action/b/id/[number]/name/[string] The a and b are constants (i.e. each time I see a number in the place of the action, I use the same values).
Where can I catch the action and controller values before they are being dispatched?

2 Cevap

Sen) routeShutdown (Kontrolör Plugin eylem ve denetleyici tarifesi (güzergah seçildikten sonra sonra) veya preDispatch olarak () (her kontrolör sevk öncesi). Ben routeShutdown kullanmak istiyorsunuz sanırım. Sen İsteği erişilebilir var, bu yüzden hiç bir şey denetleyici ve eylem ayarlayabilirsiniz ..

How to write plugins

Bunu yollarının bu tür işlemek için özel bir Rota oluşturmak ve onları doğru denetleyicisi ve URL'ye gönderilir olabilir.

Örneğin:

$router = $front->getRouter();
$router->addRoute(
    'my_route',
    new Zend_Controller_Router_Route(
         ':number/:string',
         array(
              'controller' => 'your_controller',
              'action' => 'your_action'
         )
    )
);