Beispiel #1
0
 /**
  * Populate all static view files for specified root path and list of languages
  *
  * @param string $rootPath
  * @param ObjectManagerFactory $omFactory
  * @param array $locales
  * @return void
  */
 public function deploy($rootPath, ObjectManagerFactory $omFactory, array $locales)
 {
     $this->omFactory = $omFactory;
     if ($this->isDryRun) {
         $this->logger->logMessage('Dry run. Nothing will be recorded to the target directory.');
     }
     $langList = implode(', ', $locales);
     $this->logger->logMessage("Requested languages: {$langList}");
     $libFiles = $this->filesUtil->getStaticLibraryFiles();
     list($areas, $appFiles) = $this->collectAppFiles($locales);
     foreach ($areas as $area => $themes) {
         $this->emulateApplicationArea($rootPath, $area);
         foreach ($locales as $locale) {
             foreach ($themes as $themePath) {
                 $this->logger->logMessage("=== {$area} -> {$themePath} -> {$locale} ===");
                 $this->count = 0;
                 $this->errorCount = 0;
                 foreach ($appFiles as $info) {
                     list($fileArea, $fileThemePath, , $module, $filePath) = $info;
                     $this->deployAppFile($area, $fileArea, $themePath, $fileThemePath, $locale, $module, $filePath);
                 }
                 foreach ($libFiles as $filePath) {
                     $this->deployFile($filePath, $area, $themePath, $locale, null);
                 }
                 $this->logger->logMessage("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n");
             }
         }
     }
     $version = $this->versionGenerator->generate();
     $this->logger->logMessage("New version of deployed files: {$version}");
     if (!$this->isDryRun) {
         $this->versionStorage->save($version);
     }
 }
Beispiel #2
0
 /**
  * Load or generate deployment version of static files depending on the application mode
  *
  * @param string $appMode
  * @return string
  */
 protected function readValue($appMode)
 {
     switch ($appMode) {
         case \Magento\Framework\App\State::MODE_DEFAULT:
             try {
                 $result = $this->versionStorage->load();
             } catch (\UnexpectedValueException $e) {
                 $result = $this->versionGenerator->generate();
                 $this->versionStorage->save($result);
             }
             break;
         case \Magento\Framework\App\State::MODE_DEVELOPER:
             $result = $this->versionGenerator->generate();
             break;
         default:
             $result = $this->versionStorage->load();
     }
     return $result;
 }