[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/tasks/system/ -> TypedefTask.php (source)

   1  <?php
   2  /*
   3   *  $Id: TypedefTask.php 3076 2006-12-18 08:52:12Z fabien $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://phing.info>.
  20   */
  21  
  22  require_once 'phing/Task.php';
  23  
  24  /**
  25   * Register a datatype for use within a buildfile.
  26   * 
  27   * This is for registering your own datatypes for use within a buildfile.
  28   * 
  29   * If you find that you are using a particular class frequently, you may want to edit the 
  30   * phing/types/defaults.properties file so that it is included by default.  You may also
  31   * want to submit it (if LGPL or compatible license) to be included in Phing distribution.
  32   * 
  33   * <pre>
  34   *   <typedef name="mytype" classname="path.to.MyHandlingClass"/>
  35   *   .
  36   *   <sometask ...>
  37   *     <mytype param1="val1" param2="val2"/>
  38   *   </sometask>
  39   * </pre>
  40   * 
  41   * TODO:
  42   *    -- possibly refactor since this is almost the same as TaskDefTask
  43   *      (right now these are just too simple to really justify creating an abstract class)
  44   * 
  45   * @author    Hans Lellelid <hans@xmpl.org>
  46   * @version   $Revision: 1.7 $
  47   * @package   phing.tasks.system
  48   */
  49  class TypedefTask extends Task {
  50      
  51      /** Tag name for datatype that will be used in XML */
  52      private $name;
  53      
  54      /**
  55       * Classname of task to register.
  56       * This can be a dot-path -- relative to a location on PHP include_path.
  57       * E.g. path.to.MyClass ->  path/to/MyClass.php
  58       * @var string
  59       */
  60      private $classname;
  61      
  62      /**
  63       * Path to add to PHP include_path to aid in finding specified class.
  64       * @var Path
  65       */
  66      private $classpath;
  67      
  68      /** Refid to already defined classpath */
  69      private $classpathId;
  70      
  71      /**
  72       * Set the classpath to be used when searching for component being defined
  73       * 
  74       * @param Path $classpath An Path object containing the classpath.
  75       */
  76      public function setClasspath(Path $classpath) {
  77          if ($this->classpath === null) {
  78              $this->classpath = $classpath;
  79          } else {
  80              $this->classpath->append($classpath);
  81          }
  82      }
  83  
  84      /**
  85       * Create the classpath to be used when searching for component being defined
  86       */ 
  87      public function createClasspath() {
  88          if ($this->classpath === null) {
  89              $this->classpath = new Path($this->project);
  90          }
  91          return $this->classpath->createPath();
  92      }
  93  
  94      /**
  95       * Reference to a classpath to use when loading the files.
  96       */
  97      public function setClasspathRef(Reference $r) {
  98          $this->classpathId = $r->getRefId();
  99          $this->createClasspath()->setRefid($r);
 100      }
 101      
 102      /** Main entry point */
 103      public function main() {
 104          if ($this->name === null || $this->classname === null) {
 105              throw new BuildException("You must specify name and class attributes for <typedef>.");
 106          }        
 107          $this->project->addDataTypeDefinition($this->name, $this->classname, $this->classpath);
 108      }
 109      
 110      /**
 111       * Sets the name that will be used in XML buildfile.
 112       * @param string $name
 113       */
 114      public function setName($name)    {
 115          $this->name = $name;
 116      }
 117      
 118      /**
 119       * Sets the class name / dotpath to use.
 120       * @param string $class
 121       */
 122      public function setClassname($class) {
 123          $this->classname = $class;
 124      }
 125  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7