Zend Framework Değişim Modülü Adı

1 Cevap php

ZF 1.9.6 Trying to change the module based on the user agent of the request. When I try to get the request object from the Front, I get NULL.

Şu anda ben oluşturulan Bootstrap _initModule yöntemi modül adını ayarlamak çalışıyorum.

$front = Zend_Controller_Front::getInstance();
$request = $front->getRequest(); // This is NULL
$request = new Zend_Controller_Request_Http();
$request->setModuleName('iphone');
$front->setRequest($request);

Idam Ancak, yine 'varsayılan' modülü olacak.

1 Cevap

Herhangi bir isteği yönlendirme başlamadan önce olur, çünkü ben, Bootstrap doğru yer olduğunu sanmıyorum.

Bunun için preDispatch ön kontrolör eklentisi kullanarak öneririm:

class Your_Application_Plugin_ModuleSelector extends Zend_Controller_Plugin_Abstract {
    public function preDispatch(Zend_Controller_Request_Abstract $request) {
        ...
        $request->setModuleName('iphone');
    }
...
}

Ile:

resources.frontController.plugins.moduleselector = "Your_Application_Plugin_ModuleSelector"

size application.ini