-- Steven Szymczak <[email protected]> wrote
(on Thursday, 28 May 2009, 12:24 PM +0100):
> Personally, I try very hard to push all the heavy lifting off to models;  
> but, after reading the chapter linked, it seems I have to admit I'm  
> guilty of using controllers as "data police".
>
> My scenario: the controller merges some global/local config information  
> in order to create a database connection specific to it's needs.  It  
> then passes an instance of Zend_Config to the constructor of a database  
> manager class (model), which actually spawns a connection.  The  
> controller then asks the database manager for information, particular to  
> the needs of whatever action is called for, and assigns the results to  
> the view without ever actually "using" said information itself.
>
> So is this functionality better handled by the view?

No, this approach makes great sense, and perfectly illustrates what the
controller should be doing: marshalling the configuration and resources
that will be used by the models and views.

Ideally, your controller is getting all the model dependencies and
providing them to the model as it is instantiated. These might include
a data mapper, the data access classes, a service locator, etc. This
work has to happen *somewhere*, and since your controller is the object
that knows what views and models will be used, that's the right place to
do it.

> Sorry for hijacking the thread :)
>
> Dalibor Karlović wrote:
>> On Thursday 28 May 2009 02:27:03 Steven Szymczak wrote:
>>> Why wouldn't you?
>>
>> If you have access to a DB instance inside your controller, you're more 
>> inclined to use it. :) Which leads to FSUCs. [1]
>>
>> [1] http://sn.im/ixdgi
>>
>>> Dalibor Karlović wrote:
>>>> On Tuesday 26 May 2009 20:40:38 Vladas Diržys wrote:
>>>>> Hi,
>>>>>
>>>>> what is the right way to get a db (or any other) resource in the
>>>>> controller? Now I'm using following line:
>>>>> $this->getFrontController()->getParam('bootstrap')->getResource('db');
>>>> Why do you need you DB instance inside your controller?
>>
>

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

Reply via email to