Accessing View object from Module Bootstrap

4 messages Options
Embed this post
Permalink
bingomanatee

Accessing View object from Module Bootstrap

Reply Threaded More More options
Print post
Permalink
I am attempting to design a "Druplally" framework around ZF and I want to allow the module's bootstrap to have access to the View object (for helper registration etc.)

When I put the following in the MAIN bootstrap file

<code>
    public function _initHelpers () {

        $this->bootstrap('view');
        $view = $this->getResource('view');
    }
</code>

it works fine. (I have resources.view[] = in my main configuration.)

However the same code in a MODULE'S bootstrap crashes:

Zend_Application_Bootstrap_Exception: Resource matching "view" not found in /Users/bingomanatee/Documents/sites/ZendFramework/library/Zend/Application/Bootstrap/BootstrapAbstract.php

(the error statck points to bootstrap('view') )

So my question(s) is/are:

* Does a module's bootstrap expect a configuration file to exist IN THE MODULE (with a resources.view[] node)?
* Why does the module not have access to the application resources?

If anyone can help me figure out why I cannot access the view helper from the module or outline exactly what the "Resource space" of a module's bootstrap file is, I'd be greatful.

Thanks

Dave
weierophinney

Re: Accessing View object from Module Bootstrap

Reply Threaded More More options
Print post
Permalink
-- bingomanatee <[hidden email]> wrote
(on Wednesday, 04 November 2009, 10:02 AM -0800):

> I am attempting to design a "Druplally" framework around ZF and I want to
> allow the module's bootstrap to have access to the View object (for helper
> registration etc.)
>
> When I put the following in the MAIN bootstrap file
>
> <code>
>     public function _initHelpers () {
>
>         $this->bootstrap('view');
>         $view = $this->getResource('view');
>     }
> </code>
>
> it works fine. (I have resources.view[] = in my main configuration.)
>
> However the same code in a MODULE'S bootstrap crashes:

When in a module bootstrap, you need to grab it from the application
bootstrap, which, cryptically, you retrieve with the getApplication()
method:

    public function _initHelpers()
    {
        $bootstrap = $this->getApplication();
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View');
        // ...
    }


--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
bingomanatee

Re: Accessing View object from Module Bootstrap

Reply Threaded More More options
Print post
Permalink
Thanks, Matt - while i (REALLY REALLY) appreciate the help, I do have to ask -- it seems to me that that sort of delegation would be a great thing to built into the module bootstrap itself -- as modules are subsets of the app, I'd kind of expect that they would inherit the resources of their application.

Something to think about...

BTW(off topic) I am working on "Zupal" -- a Zend implementation of Drupal -- and will present it when I've got it tuned the way I like it. Already very RAD friendly.

Dave
weierophinney

Re: Accessing View object from Module Bootstrap

Reply Threaded More More options
Print post
Permalink
-- bingomanatee <[hidden email]> wrote
(on Wednesday, 04 November 2009, 02:17 PM -0800):
> Thanks, Matt - while i (REALLY REALLY) appreciate the help, I do have to ask
> -- it seems to me that that sort of delegation would be a great thing to
> built into the module bootstrap itself -- as modules are subsets of the app,
> I'd kind of expect that they would inherit the resources of their
> application.
>
> Something to think about...

As usual, my answer is: add a feature request to the tracker. :) Bonus
points if you provide a patch with implementation and unit tests. :)

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/