Source for file Switch.php

Documentation is available at Switch.php

  1. <?php
  2.  
  3. /**
  4.  * Decorator that, depending on a token, switches between two definitions.
  5.  */
  6. {
  7.     
  8.     protected $tag;
  9.     protected $withTag$withoutTag;
  10.     
  11.     /**
  12.      * @param string $tag Tag name to switch upon
  13.      * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag
  14.      * @param HTMLPurifier_AttrDef $without_tag Call if token doesn't match, or there is no token
  15.      */
  16.     public function __construct($tag$with_tag$without_tag{
  17.         $this->tag = $tag;
  18.         $this->withTag = $with_tag;
  19.         $this->withoutTag = $without_tag;
  20.     }
  21.     
  22.     public function validate($string$config$context{
  23.         $token $context->get('CurrentToken'true);
  24.         if (!$token || $token->name !== $this->tag{
  25.             return $this->withoutTag->validate($string$config$context);
  26.         else {
  27.             return $this->withTag->validate($string$config$context);
  28.         }
  29.     }
  30.     
  31. }

Documentation generated on Thu, 19 Jun 2008 18:50:22 -0400 by phpDocumentor 1.4.2