Thanks again - 

I understand now what gets returned by getResource vs. getPluginResource but
I'm a little confused as to what is considered a 'resource' and what is
considered a 'plugin resource'?



ljs629 wrote:
> 
> 
> Ahhhh... great.  And thanks for the quick response!  
> 
> 
> 
> weierophinney wrote:
>> 
>> -- ljs629 <[email protected]> wrote
>> (on Tuesday, 27 October 2009, 10:45 AM -0700):
>>> I'm new to ZF and I'm trying to figure out the difference between
>>> resource
>>> and plugin resource - specifically, I have a working site and in the
>>> bootstrap I init the doctype with this:
>>> 
>>> 
>>>         public function _initDocType(){
>>>                 $this->bootstrap('view');
>>>                 $view = $this->getResource('view');
>>>                 $view->doctype('XHTML1_STRICT');
>>>         }
>>> 
>>> And I init the registry with this:
>>> 
>>> 
>>>         public function _initRegistry()
>>>         {
>>>                 $this->bootstrap('db');
>>>                 $resource = $this->getPluginResource('db');
>>>                 $db = $resource->getDbAdapter();
>>>                 Zend_Registry::set('db', $db);
>>>         }
>>> 
>>> My question is, why do I need to use getResource for the 'view' BUT
>>> getPluginResource for the 'db'?  
>> 
>> You don't.
>> 
>> getPluginResource() returns the actual plugin resource instance.
>> getResource() will return whatever was returned by a given resource --
>> whether it's one you've defined in your class or a plugin resource.
>> 
>> You could change these lines:
>> 
>>     $resource = $this->getPluginResource('db');
>>     $db = $resource->getDbAdapter();
>> 
>> to simply:
>>     
>>     $db = $this->getResource('db');
>> 
>> since the DB resource returns the established DB adapter.
>> 
>> -- 
>> Matthew Weier O'Phinney
>> Project Lead            | [email protected]
>> Zend Framework          | http://framework.zend.com/
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/resource-vs.-pluginresource-tp26082067p26082852.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to