public function read($len = null)
 {
     $p = new Project();
     $toFile = Register::getSlot("task.copy.currentFromFile")->getValue();
     if ($toFile) {
         if (file_exists($toFile)) {
             actionQueueTask::getInstance()->registerFile($toFile);
         }
     }
     return parent::read();
 }
Exemple #2
0
 /**
  * Returns a name 
  * 
  */
 protected function getRegisterSlot($slotName)
 {
     return Register::getSlot('task.' . $this->getTaskName() . '.' . $slotName);
 }
 /** Sets the named attribute. */
 function setAttribute(Project $project, $element, $attributeName, &$value)
 {
     // we want to check whether the value we are setting looks like
     // a slot-listener variable:  %{task.current_file}
     //
     // slot-listener variables are not like properties, in that they cannot be mixed with
     // other text values.  The reason for this disparity is that properties are only
     // set when first constructing objects from XML, whereas slot-listeners are always dynamic.
     //
     // This is made possible by PHP5 (objects automatically passed by reference) and PHP's loose
     // typing.
     if (StringHelper::isSlotVar($value)) {
         $as = "setlistening" . strtolower($attributeName);
         if (!isset($this->slotListeners[$as])) {
             $msg = $this->getElementName($project, $element) . " doesn't support a slot-listening '{$attributeName}' attribute.";
             throw new BuildException($msg);
         }
         $method = $this->slotListeners[$as];
         $key = StringHelper::slotVar($value);
         $value = Register::getSlot($key);
         // returns a RegisterSlot object which will hold current value of that register (accessible using getValue())
     } else {
         // Traditional value options
         $as = "set" . strtolower($attributeName);
         if (!isset($this->attributeSetters[$as])) {
             $msg = $this->getElementName($project, $element) . " doesn't support the '{$attributeName}' attribute.";
             throw new BuildException($msg);
         }
         $method = $this->attributeSetters[$as];
         if ($as == "setrefid") {
             $value = new Reference($value);
         } else {
             // decode any html entities in string
             $value = html_entity_decode($value);
             // value is a string representation of a boolean type,
             // convert it to primitive
             if (StringHelper::isBoolean($value)) {
                 $value = StringHelper::booleanValue($value);
             }
             // does method expect a PhingFile object? if so, then
             // pass a project-relative file.
             $params = $method->getParameters();
             $classname = null;
             if (($hint = $params[0]->getClass()) !== null) {
                 $classname = $hint->getName();
             }
             // there should only be one param; we'll just assume ....
             if ($classname !== null) {
                 switch (strtolower($classname)) {
                     case "phingfile":
                         $value = $project->resolveFile($value);
                         break;
                     case "path":
                         $value = new Path($project, $value);
                         break;
                     case "reference":
                         $value = new Reference($value);
                         break;
                         // any other object params we want to support should go here ...
                 }
             }
             // if hint !== null
         }
         // if not setrefid
     }
     // if is slot-listener
     try {
         $project->log("    -calling setter " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()", PROJECT_MSG_DEBUG);
         $method->invoke($element, $value);
     } catch (Exception $exc) {
         throw new BuildException($exc);
     }
 }
 /**
  * Append an array of files in a directory.
  * @param FileWriter $writer The FileWriter that is appending to target file.
  * @param array $files array of files to delete; can be of zero length
  * @param PhingFile $dir directory to work from
  */
 private function appendFiles(FileWriter $writer, $files, PhingFile $dir)
 {
     if (!empty($files)) {
         $this->log("Attempting to append " . count($files) . " files" . ($dir !== null ? ", using basedir " . $dir->getPath() : ""));
         $basenameSlot = Register::getSlot("task.append.current_file");
         $pathSlot = Register::getSlot("task.append.current_file.path");
         foreach ($files as $filename) {
             try {
                 $f = new PhingFile($dir, $filename);
                 $basenameSlot->setValue($filename);
                 $pathSlot->setValue($f->getPath());
                 $this->appendFile($writer, $f);
             } catch (Exception $ioe) {
                 $this->log("Unable to append contents of file " . $f->getAbsolutePath() . ": " . $ioe->getMessage(), Project::MSG_WARN);
             }
         }
     }
     // if !empty
 }
Exemple #5
0
 /**
  * Append an array of files in a directory.
  *
  * @param Writer $writer The FileWriter that is appending to target file.
  * @param array $files array of files to delete; can be of zero length
  * @param PhingFile $dir directory to work from
  *
  * @return void
  */
 private function appendFiles(Writer $writer, $files, PhingFile $dir = null)
 {
     if (!empty($files)) {
         $this->log("Attempting to append " . count($files) . " files" . ($dir !== null ? ", using basedir " . $dir->getPath() : ""));
         $basenameSlot = Register::getSlot("task.append.current_file");
         $pathSlot = Register::getSlot("task.append.current_file.path");
         foreach ($files as $file) {
             try {
                 if (!$this->checkFilename($file, $dir)) {
                     continue;
                 }
                 $file = is_string($file) ? new PhingFile($file) : $file;
                 $basenameSlot->setValue($file);
                 $pathSlot->setValue($file->getPath());
                 $this->appendFile($writer, $file);
             } catch (IOException $ioe) {
                 $this->log("Unable to append contents of file " . $file . ": " . $ioe->getMessage(), Project::MSG_WARN);
             } catch (NullPointerException $npe) {
                 $this->log("Unable to append contents of file " . $file . ": " . $npe->getMessage(), Project::MSG_WARN);
             }
         }
     }
 }