First you need to know this: A resource (most time) creates something (a view, db, log, whatever). You might want to grab this "thing", but sometimes you need the access to the plugin itself.
The getResource() gets the "thing" for you. The getResourcePlugin() gets the plugin. So you might have a db resource, returning the db adapter. Then, it's enough to do: $db = $this->getResource('db'); It might you want to have access to a certain method of the resource plugin. Then, you do this: $result = $this->getPluginResource('db')->doSomething(); You could trick the outcome of getResource() by implementing a "get" method. So your db resource needs a (public) function getDb(), which will return a db adapter instance. Regards, Jurian -- Jurian Sluiman Soflomo.com Op Tuesday 27 October 2009 18:45:46 schreef ljs629: > 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'? Both seem to be defined in my > application.ini: > ... > resources.view = > ... > resources.db.adapter = PDO_MYSQL > resources.db.params.host = localhost > resources.db.params.username = xxxx > resources.db.params.dbname = xxxxxxx > resources.db.params.password = xxxxxxx > ... > > Thanks!
signature.asc
Description: This is a digitally signed message part.