using ...
$this->getInvokeArg('bootstrap')->getOptions();
.. to retrieve my config settings from application.ini (using Zend Framework 1.11). this is failing when called from a Zend Helper file but works when called in a controller
why?
The getInvokeArg() method exists for controllers (classes extending Zend_Controller_Action), but is not available for action helpers (classes extending Zend_Controller_Action_Helper_Abstract - I suppose that is what you mean with "Zend Helper file"). You can confirm this in the Zend Framework API, which is a very useful reference when developing with the Zend Framework.
To call getInvokeArg() within an action helper, you must first get the current action controller, which you can do within action helpers by calling the getActionController() method. Concluding, within an action helper, the following code will do what you want:
$this->getActionController()->getInvokeArg('bootstrap')->getOptions();
The $this keyword refers to the current class; as such, within an action helper, $this refers to the action helper, and not the controller.
Related
Is it possible to use GWT deferred binding to make a method invocation of a class?
I've developed a GWT application whereby web pages forms UI widgets are generated using property files instead of coding them in Java.
Using sample property file below, my intention of using Java like reflection in GWT is so that if btnSave is clicked in a form, it will invoke validateAddress() method inside FormValidator.java to perform UI validation on address fields
Sample Property file
txtAddress.UiType=TextField
btnSave.Title=Save
btnSave.UiType=Button
btnSave.onClick=com.sample.form.validation.FormValidator.validateAddress()
FormValidator.java
public boolean validateAddress(){
...(validation code)
}
I am using ZEND 3 and I need to use a module in ordinary PHP file outside framework. How can it be done - make instance of the module and call some method, please?
I have Global Variable in .phtml file and i want to access that variable into the controller file of zend framework.
You can`t cause phtml files genelaly processed AFTER controllers methods.
You have to pass variable through AJAX or URL and access variable by using get or post method in controller
Kindly explain the following regarding Zend Framework and how do I know which one to use, and when and where to use them.
resources.layout.pluginClass
resources.frontcontroller.plugins
The first is described on this page and allows you to provide a specific layout controller plugin class to override the default
pluginClass: the front controller plugin class to use when using Zend_Layout with the MVC components. By default, this is Zend_Layout_Controller_Plugin_Layout
The second, described here allows you to register any number of generic controller plugins
plugins: array of front controller plugin class names. The resource will instantiate each class (with no constructor arguments) and then register the instance with the front controller. If you want to register a plugin with a particular stack index, you need to provide an array with two keys class and stackIndex.
I have a problem. Basically, depending on whether a user goes to /es or /br or /cn etc on our website, we have different language template files. So far, we were using a custom templating engine to make this work, but are making a switch over to ZF. I can't seem to figure out how to get ZF to look for a view script in say cn/about-us if the language varuable is cn.
I can't (don't want to) use Zend_Translate for this because we have way too many translated template files and it's just not feasible using Zend_Translate for bazillion different files with multi-paragraphs of Chinese/Korean/Japanese, forgetting for a second that I don't speak those languages.
Can anybody help me?
You can write a controller plugin and use it's routeStartup() method to alter Zend_View settings (path to where your view scripts are located) and change the request uri before routing starts.
class My_Controller_Plugin_LanguageSwitcher extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// examine the $_SERVER['REQUEST_URI'] and look for your language identifier
// fetch the View and set appropriate view scripts path using setScriptPath() method
// strip the language identifier from your REQUEST_URI
// change the request uri using $request->setRequestUri('your-new-uri-without-the-language- identifier');
}
}