Beispiel #1
0
 /**
  * Accumulate all static view files in the application and record all found areas, themes and languages
  *
  * Returns an array of areas and files with meta information
  *
  * @param array $requestedLocales
  * @return array
  */
 private function collectAppFiles($requestedLocales)
 {
     $areas = [];
     $locales = [];
     $files = $this->filesUtil->getStaticPreProcessingFiles();
     foreach ($files as $info) {
         list($area, $themePath, $locale) = $info;
         if ($themePath) {
             $areas[$area][$themePath] = $themePath;
         }
         if ($locale) {
             $locales[$locale] = $locale;
         }
     }
     foreach ($requestedLocales as $locale) {
         unset($locales[$locale]);
     }
     if (!empty($locales)) {
         $langList = implode(', ', $locales);
         $this->logger->logMessage("WARNING: there were files for the following languages detected in the file system: {$langList}." . ' These languages were not requested, so the files will not be populated.');
     }
     return [$areas, $files];
 }
 /**
  * Launch application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->state->setAreaCode($this->params->getArea());
     $this->objectManager->configure($this->configLoader->load($this->params->getArea()));
     $sourceFileGenerator = $this->sourceFileGeneratorPool->create($this->params->getExt());
     foreach ($this->params->getFiles() as $file) {
         $file .= '.' . $this->params->getExt();
         $this->logger->logMessage("Gathering {$file} sources.");
         $asset = $this->assetRepo->createAsset($file, ['area' => $this->params->getArea(), 'theme' => $this->params->getTheme(), 'locale' => $this->params->getLocale()]);
         $sourceFile = $this->assetSource->findSource($asset);
         $content = \file_get_contents($sourceFile);
         $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $content, 'origContentType' => $asset->getContentType()]);
         $processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
         $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
         $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
         $source = $rootDir->getRelativePath($processedCoreFile);
         $destination = $asset->getPath();
         $rootDir->copyFile($source, $destination, $targetDir);
         $this->logger->logMessage("Done");
     }
     $this->response->setCode(Response::SUCCESS);
     return $this->response;
 }