Esempio n. 1
0
 /**
  * Import from Yaml file.
  *
  * @param string $file
  * @param string $override
  * @param bool   $force    if set to true items not included in import will be deleted
  *
  * @return Result
  */
 public function importFromYaml($file, $override = null, $force = false)
 {
     Craft::app()->config->maxPowerCaptain();
     $yaml = IOHelper::getFileContents($file);
     $yaml_override = IOHelper::getFileContents($override);
     $dataModel = Data::fromYaml($yaml, $yaml_override);
     return $this->importDataModel($dataModel, $force);
 }
 /**
  * Loads config file
  */
 private function loadConfig()
 {
     try {
         if ($yaml = IOHelper::getFileContents(self::UNITTESTSUITE_CONFIG)) {
             $this->config = Yaml::parse($yaml);
         } else {
             $this->logError(sprintf('Unable to load configuration from %s', self::UNITTESTSUITE_CONFIG));
         }
     } catch (\Exception $e) {
         $this->logError(sprintf('An error occurred loading configuration: %s', $e->getMessage()));
     }
 }
Esempio n. 3
0
 /**
  * Test export to yml excluding data types.
  *
  * @covers ::exportToYaml
  */
 public function testExportToYamlExcludingDataTypes()
 {
     $this->prepExportMockServices();
     $exportableDataTypes = Schematic::getExportableDataTypes();
     $dataTypesToExport = array_diff($exportableDataTypes, ['pluginData']);
     $results = $this->schematicService->exportToYaml($this->getYamlExportFile(), $dataTypesToExport);
     $this->assertFalse($results->hasErrors());
     // Read and process the recently created export YAML file.
     $yaml = IOHelper::getFileContents($this->getYamlExportFile());
     $dataModel = Data::fromYaml($yaml, []);
     // Make sure the excluded data type was not exported.
     $this->assertEmpty($dataModel->pluginData);
 }
Esempio n. 4
0
 /**
  * @return string
  */
 private function getOverrideTestFile()
 {
     return IOHelper::getFileContents(__DIR__ . '/../data/test_override.yml');
 }
 /**
  * Strip orientation from EXIF data for an image at a path.
  *
  * @param $filePath
  *
  * @return bool
  */
 public function stripOrientationFromExifData($filePath)
 {
     if (!ImageHelper::canHaveExifData($filePath)) {
         return null;
     }
     $data = new PelDataWindow(IOHelper::getFileContents($filePath));
     // Is this a valid JPEG?
     if (PelJpeg::isValid($data)) {
         $jpeg = $file = new PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if ($exif) {
             $tiff = $exif->getTiff();
             $ifd0 = $tiff->getIfd();
             // Delete the Orientation entry and re-save the file
             $ifd0->offsetUnset(PelTag::ORIENTATION);
             $file->saveFile($filePath);
             return true;
         }
     }
     return false;
 }
Esempio n. 6
0
 /**
  * Strip orientation from EXIF data for an image at a path.
  *
  * @param $filePath
  *
  * @return bool
  */
 public function stripOrientationFromExifData($filePath)
 {
     if (!ImageHelper::canHaveExifData($filePath)) {
         return null;
     }
     // Quick and dirty, if possible
     if ($this->isImagick() && method_exists('Imagick', 'setImageProperty')) {
         $image = new \Imagick($filePath);
         $image->setImageOrientation(\Imagick::ORIENTATION_UNDEFINED);
         $image->writeImages($filePath, true);
         return true;
     }
     $data = new PelDataWindow(IOHelper::getFileContents($filePath));
     // Is this a valid JPEG?
     if (PelJpeg::isValid($data)) {
         $jpeg = $file = new PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if ($exif) {
             $tiff = $exif->getTiff();
             $ifd0 = $tiff->getIfd();
             // Delete the Orientation entry and re-save the file
             $ifd0->offsetUnset(PelTag::ORIENTATION);
             $file->saveFile($filePath);
             return true;
         }
     }
     return false;
 }