2008年9月27日星期六

[fw-mvc] sanity check over new eclipse zf project

I recently created a new 6.01 eclipse project and discovered the usage of a
plugin to initiate the application. I like this alot! Just out of curiosity
though, I was considering extending it with a second abstract layer, so I
can obtain these standard resources more fluently. Is this a valid
implementation, or is there an unforeseen design flaw I might come across?
Basically, I'd extend off this, initiating the registry oncreation, and
well, you can see the rest.. pretty simple, but i am a bit hesitant and not
sure why.

Thanks!

-Jonathan

..... [ skipping ahead ] ...

public function __construct()
{
if( !$this->_reg){
$this->_reg = Zend_Registry::getInstance();
}
}

/**
* @return Zend_Db_Adapter
*/
public function getDb()
{
if( !$this->_reg->isRegistered('_db')) {

$db = Zend_Db::factory($this->getConfig('resource/database'));

Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->getCache());

$this->_reg->set('_db', $db);
}
return $this->_reg->get('_db');
}

/**
* @return Zend_Cache_Core
*/
public function getCache()
{
if( !$this->_reg->isRegistered('_cache')) {
$cache =
Zend_Cache::factory($frontendCache,$backendCache,$frontendOptions,$backendOptions);

$this->_reg->set('_cache', $cache);
}
}
}
[/code]
--
View this message in context: http://www.nabble.com/sanity-check-over-new-eclipse-zf-project-tp19705998p19705998.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: