ZF-7953: Zend_Validate_Db_Abstract should use getter for adapter

Description

It would make extensions to the Zend_Validate_Db validators a bit easier if the db adapter was accessible via a getter.

Use case: I need a validator that can validate against the context, so I set it up so that I can use placeholders in the exclude parameter that get swapped out with corresponding values from the context. To get the context values quoted, I need access to the adapter, except that I can't use $this->_adapter, as it hasn't been initialised yet. So I end up having to copy the init code from Zend_Validate_Db_Abstract::_query()

Comments

Patched Zend_Validate_Db_Abstract with new getter method

Patch unusable. Added feature as part of another on with r18417

Although r18417 added a getter/setter for the adapter, it would be more useful to let the getter have a default fallback like there is in the _query method. Otherwise each extensions requiring the adapter needs to duplicate that part of the query method, which is the reason why I raised the issue in the first place.

Could you give me a reason why my patch was rejected? Would be helpful for future contributions.

Your "patch" did not conform the API. When you add a getter you must also add a setter. When you do this for one option you should also do this for all other options, not only for a single one.

Related to _query: getAdapter return only what has been set. A default adapter is not set by the user, so it's not returned by getAdapter. And the adapter option can also be optional or set afterwards. So it is not filled per default.

Extending classes will not have to duplicate the adapter code, but simply use/extend _query for their own purposes.

But that's precisely the point. You cannot have an extension use the default adapter prior to querying without : 1. Duplicating the "get default adapter" code in _query() or 2. Providing a getter for it