예제 #1
0
 /**
  * Creates images from local filesystem path
  *
  * @param  Path $path     Path passed by the shell
  * @param  string         $filename Filename
  * @param  string         $type     Media Type
  * @return Image
  */
 public function fromLocalPath(Path $path, $filename, $type = '')
 {
     // Replace backslash by regular slash in file path (otherwise breaks the parser)
     $filename = str_replace('\\', '/', $filename);
     $imagePath = $path->getRoot() . DS . $filename;
     $parts = pathinfo($imagePath);
     $this->setData(['binary_data' => file_get_contents($imagePath), 'full_path' => $imagePath, 'relative_path' => $path->getDirectory() . DS . $filename, 'file_name' => $parts['filename'], 'file_extension' => $parts['extension'], 'type' => $type]);
     // Retrieve binary contents
     $this->setId($this);
     return $this;
 }
예제 #2
0
 /**
  * @param \DOMDocument $xml
  * @return \DOMDocument
  */
 protected function _addDefaultProcessors(\DOMDocument $xml)
 {
     $type = $xml->getElementsByTagName('type');
     if (!$type->length) {
         return $xml;
     }
     // add default preprocessor before existing, common/<type>
     $preprocessors = $xml->getElementsByTagName(Processor::PRE_PROCESSORS);
     $websiteCommon = $xml->createElement('directory', 'common/' . $type->item(0)->textContent);
     $commonType = $xml->createElement('directory', $this->_path->getWebsite() . '/common');
     if ($preprocessors->length) {
         $firstNode = $preprocessors->item(0)->firstChild;
         $preprocessors->item(0)->insertBefore($commonType, $firstNode);
         $preprocessors->item(0)->insertBefore($websiteCommon, $firstNode);
     } else {
         $element = $xml->createElement('preprocessors');
         $element->appendChild($commonType);
         $element->appendChild($websiteCommon);
         $xml->appendChild($element);
     }
     return $xml;
 }
예제 #3
0
 /**
  * @covers ::getGroup
  * @covers ::_processPath
  */
 public function test_getWebsite_should_return_proper_value()
 {
     $paramPath = 'configuration/eset/prep/';
     $path = new Path($paramPath, '/base/absolute', 'rootdir');
     $this->assertEquals('eset', $path->getWebsite());
 }
예제 #4
0
 /**
  * Inits processor and run preprocessor tasks if any
  *
  * @return void
  */
 protected function _initProcessor()
 {
     $this->_processor = Processor::getInstance();
     $paramPath = $this->_input->getArgument('path');
     // If path cannot be loaded, exit immediately
     if (!$paramPath) {
         return;
     }
     $path = new Path($paramPath, getcwd(), $this->_baseDirectory);
     if ($path->isValid()) {
         $this->_processor->setPath($path);
         if (!$this->_input->getOption('ignore-manifest')) {
             $this->_manifest->load($path);
             // Check if we've some preprocessor task to complete
             $this->_runProcessors(Processor::PRE_PROCESSORS);
         }
     }
 }