Issues

ZF-2286: Add a _setupRowClass() method to Zend_Db_Table_Abstract

Description

This will allow for easily setting row classes based on a common naming convention, eg:


abstract class My_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
    protected function _setup()
    {
        parent::_setup();
        $this->_setupRowClass();
    }
    
    protected function _setupRowClass()
    {
        if (class_exists($class = get_class($this) . '_Row')) {
            $this->_rowClass = $class;
        }
    }
}

Comments

But doesn't this depend on the rowClass being available at the time of instantiation? Or are you envisaging a 'require_once' within your table definition to have this class definition pre-loaded?

I'd recommend something more reliable... like, say, a Zend_Db_Table_Plugin to set this during an init() event ;)

Well yes, it would rely on the rowClass being available during instantiation, but then in most cases the auto loader would include it when the class_exists is run. But then, this might not necessarily have to rely on the class being loaded. I didn't see the implementation of _setupRowClass above as the default, it's simply a method you can override if you wish to set the row class in a consistent manner across all tables, rather than setting the _rowClass property manually in every table class. In exactly the same way we already have _setupTableName.

This is of course something that could be done with a table plugin (once that's ready :) ), as the whole purpose of the plugin proposal is to remove the need to extend Zend_Db_Table_Abstract with another abstract class implementing custom logic, and you could say exactly the same about _setupTableName.

Please categorize/fix as needed.

This issue has gone unaddressed for too long. I'm reassigning this to Ralph for re-evaluation and categorization.

Not sure if this is the solution we want, but the feature is linked (in a round about way) to another feature request

I think between the concrete instantiation coming in 1.9 and the Zend_Application autoloader from 1.8, I think we having this feature in place.