-- Stefan Aumann <[email protected]> wrote
(on Friday, 25 June 2010, 02:42 PM +0200):
> I am trying to access request object parameters within the context
> of a resource plugin. Dumping the entire request object works as
> expected:
<snip>
> If, however, I try to access all or individual parameters, e.g.
>
> $view->debug = $request->getParams() [OR]
> $view->debug = $request->getParams('lang')
>
> I get an empty list (resp. string). Since I am pretty new to
> Zend_Application any help would be much appreciated!
You're making an invalid assumption, basically.
The parameters you're wanting to retrieve are parameters from the URI.
Those parameters, however, are only present *after* routing has taken
place -- they are the result of a positive match on a given route, which
then results in injecting parameters into the request object.
Unfortunately, routing happens _after_ application initialization (which
includes bootstrapping). So, you can't access those request variables
from within your resource plugin; they simply haven't been discovered
yet.
If a resource needs to do initialization that's based on routing
information, the best course of action is to rewrite your resource as a
front controller plugin that operates either at routeShutdown() or
later. At that time, you'll have the request variables, and you can do
further initializations.
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc