/**
  * Checks to make sure all settings are kosher. In this case, it
  * means that the dest attribute has been set and we have a mapper.
  */
 public function verifySettings()
 {
     if ($this->targetdir === null) {
         $this->setError("The targetdir attribute is required.");
     }
     if ($this->map === null) {
         if ($this->mapperElement === null) {
             $this->map = new IdentityMapper();
         } else {
             $this->map = $this->mapperElement->getImplementation();
             if ($this->map === null) {
                 $this->setError("Could not set <mapper> element.");
             }
         }
     }
 }
 /**
  * Maps the passed in name to a new filename & returns resolved File object.
  * @param      string $from
  * @return     PhingFile Resolved File object.
  * @throws     BuilException    - if no Mapper element se
  *                          - if unable to map new filename.
  */
 protected function getMappedFile($from)
 {
     if (!$this->mapperElement) {
         throw new BuildException("This task requires you to use a <mapper/> element to describe how filename changes should be handled.");
     }
     $mapper = $this->mapperElement->getImplementation();
     $mapped = $mapper->main($from);
     if (!$mapped) {
         throw new BuildException("Cannot create new filename based on: " . $from);
     }
     // Mappers always return arrays since it's possible for some mappers to map to multiple names.
     $outFilename = array_shift($mapped);
     $outFile = new PhingFile($this->getOutputDirectory(), $outFilename);
     return $outFile;
 }
Esempio n. 3
0
 /**
  * Add a <code>Mapper</code>.
  * @param Mapper $mapper the <code>Mapper</code> to add.
  */
 public function addMapper(Mapper $mapper)
 {
     $this->add($mapper->getImplementation());
 }