Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • 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
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    32.8. Custom Feed and Entry Classes

    Finally, you can extend the Zend_Feed classes if you'd like to provide your own format or niceties like automatic handling of elements that should go into a custom namespace.

    Here is an example of a custom Atom entry class that handles its own myns: namespace entries. Note that it also makes the registerNamespace() call for you, so the end user doesn't need to worry about namespaces at all.

    Ejemplo 32.7. Extending the Atom Entry Class with Custom Namespaces

    /**
     * The custom entry class automatically knows the feed URI (optional) and
     * can automatically add extra namespaces.
     */
    class MyEntry extends Zend_Feed_Entry_Atom
    {

        public function 
    __construct($uri 'http://www.example.com/myfeed/',
                                    
    $xml null)
        {
            
    parent::__construct($uri$xml);

            
    Zend_Feed::registerNamespace('myns',
                                         
    'http://www.example.com/myns/1.0');
        }

        public function 
    __get($var)
        {
            switch (
    $var) {
                case 
    'myUpdated':
                    
    // Translate myUpdated to myns:updated.
                    
    return parent::__get('myns:updated');

                default:
                    return 
    parent::__get($var);
                }
        }

        public function 
    __set($var$value)
        {
            switch (
    $var) {
                case 
    'myUpdated':
                    
    // Translate myUpdated to myns:updated.
                    
    parent::__set('myns:updated'$value);
                    break;

                default:
                    
    parent::__set($var$value);
            }
        }

        public function 
    __call($var$unused)
        {
            switch (
    $var) {
                case 
    'myUpdated':
                    
    // Translate myUpdated to myns:updated.
                    
    return parent::__call('myns:updated'$unused);

                default:
                    return 
    parent::__call($var$unused);
            }
        }
    }

    Then to use this class, you'd just instantiate it directly and set the myUpdated property:

    $entry = new MyEntry();
    $entry->myUpdated '2005-04-19T15:30';

    // method-style call is handled by __call function
    $entry->myUpdated();
    // property-style call is handled by __get function
    $entry->myUpdated;

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...