[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/lib/vendor/phing/parser/ -> ProjectHandler.php (source)

   1  <?php
   2  /*
   3   * $Id: ProjectHandler.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/parser/AbstractHandler.php';
  23  require_once 'phing/system/io/PhingFile.php';
  24  
  25  /**
  26   * Handler class for the <project> XML element This class handles all elements
  27   * under the <project> element.
  28   *
  29   * @author      Andreas Aderhold <andi@binarycloud.com>
  30   * @copyright (c) 2001,2002 THYRELL. All rights reserved
  31   * @version   $Revision: 1.14 $ $Date: 2005/10/04 19:13:44 $
  32   * @access    public
  33   * @package   phing.parser
  34   */
  35  class ProjectHandler extends AbstractHandler {
  36  
  37      /**
  38       * The phing project configurator object.
  39       * @var ProjectConfigurator
  40       */
  41      private $configurator;
  42  
  43      /**
  44       * Constructs a new ProjectHandler
  45       *
  46       * @param  object  the ExpatParser object
  47       * @param  object  the parent handler that invoked this handler
  48       * @param  object  the ProjectConfigurator object
  49       * @access public
  50       */
  51      function __construct($parser, $parentHandler, $configurator) {
  52          $this->configurator = $configurator;
  53          parent::__construct($parser, $parentHandler);
  54      }
  55  
  56      /**
  57       * Executes initialization actions required to setup the project. Usually
  58       * this method handles the attributes of a tag.
  59       *
  60       * @param  string  the tag that comes in
  61       * @param  array   attributes the tag carries
  62       * @param  object  the ProjectConfigurator object
  63       * @throws ExpatParseException if attributes are incomplete or invalid
  64       * @access public
  65       */
  66      function init($tag, $attrs) {
  67          $def = null;
  68          $name = null;
  69          $id    = null;
  70          $baseDir = null;
  71  
  72          // some shorthands
  73          $project = $this->configurator->project;
  74          $buildFileParent = $this->configurator->buildFileParent;
  75  
  76          foreach ($attrs as $key => $value) {
  77              if ($key === "default") {
  78                  $def = $value;
  79              } elseif ($key === "name") {
  80                  $name = $value;
  81              } elseif ($key === "id") {
  82                  $id = $value;
  83              } elseif ($key === "basedir") {
  84                  $baseDir = $value;
  85              } else {
  86                  throw new ExpatParseException("Unexpected attribute '$key'");
  87              }
  88          }
  89          if ($def === null) {
  90              throw new ExpatParseException("The default attribute of project is required");
  91          }
  92          $project->setDefaultTarget($def);
  93  
  94          if ($name !== null) {
  95              $project->setName($name);
  96              $project->addReference($name, $project);
  97          }
  98  
  99          if ($id !== null) {
 100              $project->addReference($id, $project);
 101          }
 102  
 103          if ($project->getProperty("project.basedir") !== null) {
 104              $project->setBasedir($project->getProperty("project.basedir"));
 105          } else {
 106              if ($baseDir === null) {
 107                  $project->setBasedir($buildFileParent->getAbsolutePath());
 108              } else {
 109                  // check whether the user has specified an absolute path
 110                  $f = new PhingFile($baseDir);
 111                  if ($f->isAbsolute()) {
 112                      $project->setBasedir($baseDir);
 113                  } else {
 114                      $project->setBaseDir($project->resolveFile($baseDir, $buildFileParent));
 115                  }
 116              }
 117          }
 118      }
 119  
 120      /**
 121       * Handles start elements within the <project> tag by creating and
 122       * calling the required handlers for the detected element.
 123       *
 124       * @param  string  the tag that comes in
 125       * @param  array   attributes the tag carries
 126       * @throws ExpatParseException if a unxepected element occurs
 127       * @access public
 128       */
 129      function startElement($name, $attrs) {
 130      
 131          $project = $this->configurator->project;
 132          $types = $project->getDataTypeDefinitions();
 133          
 134          if ($name == "target") {
 135              $tf = new TargetHandler($this->parser, $this, $this->configurator);
 136              $tf->init($name, $attrs);
 137          } elseif (isset($types[$name])) {
 138             $tyf = new DataTypeHandler($this->parser, $this, $this->configurator);
 139             $tyf->init($name, $attrs);
 140          } else {
 141              $tf = new TaskHandler($this->parser, $this, $this->configurator);
 142              $tf->init($name, $attrs);
 143          }
 144      }
 145  }
 146  


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