Exemplo n.º 1
0
 /**
  * @throws BuildException
  */
 public function main()
 {
     $reffed = $this->reference !== null ? $this->reference->getReferencedObject($this->getProject()) : null;
     if ($reffed !== null && $reffed instanceof BuildException) {
         throw $reffed;
     }
     parent::main();
 }
Exemplo n.º 2
0
 /**
  * Check to see whether any DataType we hold references to is
  * included in the Stack (which holds all DataType instances that
  * directly or indirectly reference this instance, including this
  * instance itself).
  *
  * If one is included, throw a BuildException created by circularReference
  *
  * This implementation is appropriate only for a DataType that
  * cannot hold other DataTypes as children.
  *
  * The general contract of this method is that it shouldn't do
  * anything if checked is true and set it to true on exit.
  *
  * @param         $stk
  * @param Project $p
  *
  * @return void
  *
  * @throws BuildException
  */
 public function dieOnCircularReference(&$stk, Project $p)
 {
     if ($this->checked || !$this->isReference()) {
         return;
     }
     $o = $this->ref->getReferencedObject($p);
     if ($o instanceof DataType) {
         // TESTME - make sure that in_array() works just as well here
         //
         // check if reference is in stack
         //$contains = false;
         //for ($i=0, $size=count($stk); $i < $size; $i++) {
         //    if ($stk[$i] === $o) {
         //        $contains = true;
         //        break;
         //    }
         //}
         if (in_array($o, $stk, true)) {
             // throw build exception
             throw $this->circularReference();
         } else {
             array_push($stk, $o);
             $o->dieOnCircularReference($stk, $p);
             array_pop($stk);
         }
     }
     $this->checked = true;
 }
Exemplo n.º 3
0
 /**
  * Performs the check for circular references and returns the referenced object.
  *
  * @param $requiredClass
  * @param $dataTypeName
  *
  * @throws BuildException
  *
  * @return mixed
  */
 public function getCheckedRef($requiredClass, $dataTypeName)
 {
     if (!$this->checked) {
         // should be in stack
         $stk = array();
         $stk[] = $this;
         $this->dieOnCircularReference($stk, $this->getProject());
     }
     $o = $this->ref->getReferencedObject($this->getProject());
     if (!$o instanceof $requiredClass) {
         throw new BuildException($this->ref->getRefId() . " doesn't denote a " . $dataTypeName);
     } else {
         return $o;
     }
 }
 /**
  * @param Reference $r
  *
  * @throws BuildException
  */
 public function setRefid(Reference $r)
 {
     if (count($this->parameters) !== 0 || $this->className !== null) {
         throw $this->tooManyAttributes();
     }
     $o = $r->getReferencedObject($this->getProject());
     if ($o instanceof PhingFilterReader) {
         $this->setClassName($o->getClassName());
         $this->setClasspath($o->getClassPath());
         foreach ($o->getParams() as $p) {
             $this->addParam($p);
         }
     } else {
         $msg = $r->getRefId() . " doesn\\'t refer to a PhingFilterReader";
         throw new BuildException($msg);
     }
     parent::setRefid($r);
 }
Exemplo n.º 5
0
 function setRefid(Reference $r)
 {
     if (count($this->filterReaders) !== 0) {
         throw $this->tooManyAttributes();
     }
     // change this to get the objects from the other reference
     $o = $r->getReferencedObject($this->getProject());
     if ($o instanceof FilterChain) {
         $this->filterReaders = $o->getFilterReaders();
     } else {
         throw new BuildException($r->getRefId() . " doesn't refer to a FilterChain");
     }
     parent::setRefid($r);
 }
Exemplo n.º 6
0
 /** Do the execution.
  * @throws BuildException if something is invalid
  */
 public function main()
 {
     $savedPath = $this->path;
     $savedPathSep = $this->pathSep;
     // may be altered in validateSetup
     $savedDirSep = $this->dirSep;
     // may be altered in validateSetup
     // If we are a reference, create a Path from the reference
     if ($this->isReference()) {
         $this->path = new Path($this->getProject());
         $this->path = $this->path->createPath();
         $obj = $this->refid->getReferencedObject($this->getProject());
         if ($obj instanceof Path) {
             $this->path->setRefid($this->refid);
         } elseif ($obj instanceof FileSet) {
             $fs = $obj;
             $this->path->addFileset($fs);
         } elseif ($obj instanceof DirSet) {
             $ds = $obj;
             $this->path->addDirset($ds);
         } else {
             throw new BuildException("'refid' does not refer to a " . "path, fileset, dirset, or " . "filelist.");
         }
     }
     $this->validateSetup();
     // validate our setup
     // Currently, we deal with only two path formats: Unix and Windows
     // And Unix is everything that is not Windows
     // (with the exception for NetWare and OS/2 below)
     // for NetWare and OS/2, piggy-back on Windows, since here and
     // in the apply code, the same assumptions can be made as with
     // windows - that \\ is an OK separator, and do comparisons
     // case-insensitive.
     $fromDirSep = $this->onWindows ? "\\" : "/";
     $rslt = '';
     // Get the list of path components in canonical form
     $elems = $this->path->listPaths();
     foreach ($elems as $key => $elem) {
         if (is_string($elem)) {
             $elem = new Path($this->project, $elem);
         }
         $elem = $this->mapElement($elem);
         // Apply the path prefix map
         // Now convert the path and file separator characters from the
         // current os to the target os.
         if ($key !== 0) {
             $rslt .= $this->pathSep;
         }
         $rslt .= str_replace($fromDirSep, $this->dirSep, $elem);
     }
     // Place the result into the specified property,
     // unless setonempty == false
     $value = $rslt;
     if ($this->setonempty) {
         $this->log("Set property " . $this->property . " = " . $value, Project::MSG_VERBOSE);
         $this->getProject()->setNewProperty($this->property, $value);
     } else {
         if ($rslt !== '') {
             $this->log("Set property " . $this->property . " = " . $value, Project::MSG_VERBOSE);
             $this->getProject()->setNewProperty($this->property, $value);
         }
     }
     $this->path = $savedPath;
     $this->dirSep = $savedDirSep;
     $this->pathSep = $savedPathSep;
 }
Exemplo n.º 7
0
 public function getManifest()
 {
     return $this->ref->getReferencedObject($this->getProject());
 }