-- David Koblas <[EMAIL PROTECTED]> wrote
(on Thursday, 07 December 2006, 10:15 AM -0800):
> I'm working on making an custom View class and have noticed that the
> private/protected is a little too strict (this possibly applies in other
> places).
I've detailed the rationale behind this in another reply in this thread.
> The specific case is that I went to override render -- after a bit of
> poking figured out I should override _run() instead. But, in the
> process found that I had no access to the 'scriptPath' aka
> $this->_path['script'] variable to do my own implementation of the
> $this->_script() method. Now that I'm back to my own render rountine
> have no access to the $this->_vars . While I can go and write my own
> implementation on __set() it doesn't really make sense.
If you *must* extend Zend_View (its usually better to write a custom
view script to use with Zend_View or implement Zend_View_Interface), and
need to extend these methods, the easiest way is to redeclare the
properties/methods as protected:
class My_View_Abstract extends Zend_View_Abstract
{
protected $_vars = array();
protected $_path = array();
protected function _script($path)
{
}
}
class My_View extends My_View_Abstract
{
}
Since the parent method of _script is private, you won't be able to call
parent::_script() unfortunately -- but you will be able to write your
own implementation.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/