/**
  * Constructor
  * @param $project the project to which this antxml context belongs to
  */
 public function __construct($project)
 {
     $this->project = $project;
     $this->implicitTarget = new Target();
     $this->implicitTarget->setName("");
     $this->implicitTarget->setHidden(true);
 }
예제 #2
0
 public function setUp()
 {
     $this->configureProject(PHING_TEST_BASE . "/etc/components/Target/Target.xml");
     $this->target = new Target();
     $this->target->setProject($this->project);
     $this->target->setName('MyTarget');
 }
 /**
  * Creates the ExpatParser, sets root handler and kick off parsing
  * process.
  *
  * @throws BuildException if there is any kind of execption during
  *                        the parsing process
  */
 protected function parse()
 {
     try {
         // get parse context
         $ctx = $this->project->getReference("phing.parsing.context");
         if (null == $ctx) {
             // make a new context and register it with project
             $ctx = new PhingXMLContext($this->project);
             $this->project->addReference("phing.parsing.context", $ctx);
         }
         //record this parse with context
         $ctx->addImport($this->buildFile);
         if (count($ctx->getImportStack()) > 1) {
             $currentImplicit = $ctx->getImplicitTarget();
             $currentTargets = $ctx->getCurrentTargets();
             $newCurrent = new Target();
             $newCurrent->setProject($this->project);
             $newCurrent->setName('');
             $ctx->setCurrentTargets(array());
             $ctx->setImplicitTarget($newCurrent);
             // this is an imported file
             // modify project tag parse behavior
             $this->setIgnoreProjectTag(true);
             $this->_parse($ctx);
             $newCurrent->main();
             $ctx->setImplicitTarget($currentImplicit);
             $ctx->setCurrentTargets($currentTargets);
         } else {
             $ctx->setCurrentTargets(array());
             $this->_parse($ctx);
             $ctx->getImplicitTarget()->main();
         }
     } catch (Exception $exc) {
         //throw new BuildException("Error reading project file", $exc);
         throw $exc;
     }
 }