Введение в Zend Framework

 Learning Zend Framework

appendix

 Zend Framework Reference


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Ttranslation 27.4% Update 2010-11-28 - Revision 23238 - Version ZF 1.11.x

    77.5. Zend_View_Abstract

    Zend_View_Abstract is the base class on which Zend_View is built; Zend_View itself simply extends it and declares a concrete implementation of the _run() method (which is invoked by render()).

    Many developers find that they want to extend Zend_View_Abstract to add custom functionality, and inevitably run into issues with its design, which includes a number of private members. This document aims to explain the decision behind the design.

    Zend_View is something of an anti-templating engine in that it uses PHP natively for its templating. As a result, all of PHP is available, and view scripts inherit the scope of their calling object.

    It is this latter point that is salient to the design decisions. Internally, Zend_View::_run() does the following:

    protected function _run()
    {
        include 
    func_get_arg(0);
    }

    As such, the view scripts have access to the current object ($this), and any methods or members of that object. Since many operations depend on members with limited visibility, this poses a problem: the view scripts could potentially make calls to such methods or modify critical properties directly. Imagine a script overwriting $_path or $_file inadvertently -- any further calls to render() or view helpers would break!

    Fortunately, PHP 5 has an answer to this with its visibility declarations: private members are not accessible by objects extending a given class. This led to the current design: since Zend_View extends Zend_View_Abstract, view scripts are thus limited to only protected or public methods and members of Zend_View_Abstract -- effectively limiting the actions it can perform, and allowing us to secure critical areas from abuse by view scripts.

    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...