-- Davey Shafik <[EMAIL PROTECTED]> wrote
(on Thursday, 07 December 2006, 01:58 PM -0500):
> I think anything that has a potential for being extended, should  
> probably most of it's properties set to protected, the MVC components  
> are a great example.
> 
> Others, like Zend_Search and Zend_Json aren't likely to be extended,  
> they're pretty much standalone, which entirely encapsulate what they  
> do, so these might have a number of private properties.

Actually, there are some good reasons for most items being marked as
private in Zend_View_Abstract -- it's to prevent their usage directly
from the view scripts. It's a scoping issue.

The way Zend_View works, Zend_View::_run() actually performs an
include() on the view script, which means that it has full access to
$this. However, since _run() lives in Zend_View, and not
Zend_View_Abstract, that means that private properties and methods are
off limits, while protected and public ones remain accessible.

If you need to extend Zend_View, there are two ways to do so, and both
ar documented:

    * Do so in a view script
    * Implement Zend_View_Interface


> On Dec 7, 2006, at 1:15 PM, David Koblas wrote:
> 
> > 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).
> > 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.
> >
> > There probably is a more "framework friendly" approach to what I'm  
> > doing, but at the same time, extending the classes is a little bit  
> > of a bear.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to