[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/compiler/filter/ -> WactFilterInfoExtractor.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  /**

  11   * class WactFilterInfoExtractor.

  12   *

  13   * @package wact

  14   * @version $Id: WactFilterInfoExtractor.class.php 5945 2007-06-06 08:31:43Z pachanga $

  15   */
  16  class WactFilterInfoExtractor
  17  {
  18    var $dictionary;
  19    var $file;
  20    var $annotations = array();
  21  
  22    function __construct($dict, $file)
  23    {
  24      $this->dictionary = $dict;
  25      $this->file = $file;
  26    }
  27  
  28    function setCurrentFile($file)
  29    {
  30      $this->file = $file;
  31    }
  32  
  33    function annotation($name, $value)
  34    {
  35      $this->annotations[$name] = $value;
  36    }
  37  
  38    function beginClass($class, $parent_class)
  39    {
  40      $this->_validate();
  41  
  42      if(isset($this->annotations['min_attributes']))
  43        $min = (int)$this->annotations['min_attributes'];
  44      else
  45        $min = 0;
  46  
  47      if(isset($this->annotations['max_attributes']))
  48        $max = (int)$this->annotations['max_attributes'];
  49      else
  50        $max = 0;
  51  
  52      $info = new WactFilterInfo($this->annotations['filter'], $class, $min, $max);
  53  
  54      $this->dictionary->registerFilterInfo($info, $this->file);
  55    }
  56  
  57    function endClass()
  58    {
  59      $this->annotations = array();
  60    }
  61  
  62    function _validate()
  63    {
  64      if(!file_exists($this->file))
  65        throw new WactException('File not found', array('file' => $this->file));
  66  
  67      if(!isset($this->annotations['filter']))
  68        throw new WactException('Annotation not found in file', array('annotation' => 'filter',
  69                                                                             'file' => $this->file));
  70    }
  71  }


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7