class Hans_Zend_View extends Zend_View
{
{
public function esc($var)
{
return parent::escape($var);
}
public function e($var)
{
return parent::escape($var);
}
}
So when you want to use esc instead of escape it will work. You will only need to use the Hans_Zend_View class instead of the Zend_View. By extending Zend_View you have all the available resources of that class and also you add to it with your own logic i.e. esc function.
If in your class you declare a function that has the same name as a function that is present in the class that is being extended, your function will override that one. Hence if for instance you used
public function escape($var)
{
return 'blah blah';
}
you would effectively 'kill' the Zend_View's escape function. (just an FYI)
I hope this helps.
Nikolaos
On Fri, Jan 30, 2009 at 10:24, Hans Anderson <windsurf17@gmail.com> wrote:
I'm new to ZF and to some of the concepts of OO type systems in general, though I've used PHP for quite some time. So, my apologies if this is really basic, but how can I efficiently create a replacement for $this->escape() that would still use all of the settings (like SetEscape(), etc) but be named $this->e() or $this->esc(), just for cleaner view files (with the caveat that $this->e() isn't as immediately understandable as $this->escape()).
Do I need to extend Zend_View and change how the whole MVC system works or is there some other way?
Not a hugely important thing, but it keeps occurring to me to ask.
TIA,
Hans
--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.
没有评论:
发表评论