Introduction to 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
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    34.3. Filter Chains

    Often multiple filters should be applied to some value in a particular order. For example, a login form accepts a username that should be only lowercase, alphabetic characters. Zend_Filter provides a simple method by which filters may be chained together. The following code illustrates how to chain together two filters for the submitted username:

    // Create a filter chain and add filters to the chain
    $filterChain = new Zend_Filter();
    $filterChain->addFilter(new Zend_Filter_Alpha())
                ->
    addFilter(new Zend_Filter_StringToLower());

    // Filter the username
    $username $filterChain->filter($_POST['username']);

    Filters are run in the order they were added to Zend_Filter. In the above example, the username is first removed of any non-alphabetic characters, and then any uppercase characters are converted to lowercase.

    Any object that implements Zend_Filter_Interface may be used in a filter chain.

    34.3.1. Changing filter chain order

    Since 1.10, the Zend_Filter chain also supports altering the chain by prepending or appending filters. For example, the next piece of code does exactly the same as the other username filter chain example:

    // Create a filter chain and add filters to the chain
    $filterChain = new Zend_Filter();

    // this filter will be appended to the filter chain
    $filterChain->appendFilter(new Zend_Filter_StringToLower());

    // this filter will be prepended at the beginning of the filter chain.
    $filterChain->prependFilter(new Zend_Filter_Alpha());

    // Filter the username
    $username $filterChain->filter($_POST['username']);
    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...