[ 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/ -> AdhocTaskdefTask.php (source)

   1  <?php
   2  
   3  /*
   4   * $Id: AdhocTaskdefTask.php 3076 2006-12-18 08:52:12Z fabien $
   5   *
   6   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   7   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   8   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   9   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  16   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17   *
  18   * This software consists of voluntary contributions made by many individuals
  19   * and is licensed under the LGPL. For more information please see
  20   * <http://phing.info>.
  21   */
  22   
  23  require_once 'phing/tasks/system/AdhocTask.php';
  24  
  25  /**
  26   * A class for creating adhoc tasks in build file.
  27   * 
  28   * <target name="test-adhoc">
  29   *        <adhoc-task name="foo"><![CDATA[
  30   *
  31   *            class FooTest extends Task {
  32   *                private $bar;
  33   *                
  34   *                function setBar($bar) {
  35   *                    $this->bar = $bar;
  36   *                }
  37   *                
  38   *                function main() {
  39   *                    $this->log("In FooTest: " . $this->bar);
  40   *                }
  41   *            }
  42   *
  43   *        ]]></adhoc-task>
  44   * 
  45   *      <foo bar="B.L.I.N.G"/>
  46   * </target>
  47   *  
  48   * @author    Hans Lellelid <hans@xmpl.org>
  49   * @version   $Revision: 1.5 $
  50   * @package   phing.tasks.system
  51   */
  52  class AdhocTaskdefTask extends AdhocTask {
  53  
  54      /**
  55       * The tag that refers to this task.
  56       */
  57      private $name;
  58      
  59      /**
  60       * Set the tag that will represent this adhoc task/type.
  61       * @param string $name
  62       */       
  63      public function setName($name) {
  64          $this->name = $name;
  65      }
  66      
  67      /** Main entry point */
  68      public function main() {        
  69          if ($this->name === null) {
  70              throw new BuildException("The name attribute is required for adhoc task definition.",$this->location);
  71          }
  72          
  73          $this->execute();
  74          
  75          $classes = $this->getNewClasses();
  76          if (count($classes) !== 1) {
  77              throw new BuildException("You must define one (and only one) class for AdhocTaskdefTask.");
  78          }
  79          $classname = array_shift($classes);
  80          
  81          // instantiate it to make sure it is an instance of Task
  82          $t = new $classname();
  83          if (!($t instanceof Task)) {
  84              throw new BuildException("The adhoc class you defined must be an instance of phing.Task", $this->location);
  85          }
  86          
  87          $this->log("Task " . $this->name . " will be handled by class " . $classname, PROJECT_MSG_VERBOSE);
  88          $this->project->addTaskDefinition($this->name, $classname);        
  89      }
  90  }


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