コード例 #1
0
ファイル: Deployer.php プロジェクト: shabbirvividads/magento2
 /**
  * Deploy a static view file
  *
  * @param string $filePath
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @param string $module
  * @return void
  */
 private function deployFile($filePath, $area, $themePath, $locale, $module)
 {
     $requestedPath = $filePath;
     if (substr($filePath, -5) == '.less') {
         $requestedPath = preg_replace('/.less$/', '.css', $filePath);
     }
     $logMessage = "Processing file '{$filePath}' for area '{$area}', theme '{$themePath}', locale '{$locale}'";
     if ($module) {
         $logMessage .= ", module '{$module}'";
     }
     $this->logger->logDebug($logMessage);
     try {
         $asset = $this->assetRepo->createAsset($requestedPath, ['area' => $area, 'theme' => $themePath, 'locale' => $locale, 'module' => $module]);
         $asset = $this->minifyService->getAssets([$asset], true)[0];
         $this->logger->logDebug("\tDeploying the file to '{$asset->getPath()}'", '.');
         if ($this->isDryRun) {
             $asset->getContent();
         } else {
             $this->assetPublisher->publish($asset);
             $this->bundleManager->addAsset($asset);
         }
         $this->count++;
     } catch (\Magento\Framework\View\Asset\File\NotFoundException $e) {
         // File was not found by Fallback (possibly because it's wrong context for it) - there is nothing to publish
         $this->logger->logDebug("\tNotice: Could not find file '{$filePath}'. This file may not be relevant for the theme or area.");
     } catch (\Less_Exception_Compiler $e) {
         $this->logger->logDebug("\tNotice: Could not parse LESS file '{$filePath}'. " . "This may indicate that the file is incomplete, but this is acceptable. " . "The file '{$filePath}' will be combined with another LESS file.");
     } catch (\Exception $e) {
         $this->logger->logError($e->getMessage() . " ({$logMessage})");
         $this->logger->logDebug((string) $e);
         $this->errorCount++;
     }
 }
コード例 #2
0
 /**
  * Deploy a static view file
  *
  * @param string $filePath
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @param string $module
  * @return void
  */
 private function deployFile($filePath, $area, $themePath, $locale, $module)
 {
     $requestedPath = $filePath;
     if (substr($filePath, -5) == '.less') {
         $requestedPath = preg_replace('/.less$/', '.css', $filePath);
     }
     $logModule = $module ? "<{$module}>" : (null === $module ? '<lib>' : '<theme>');
     try {
         $asset = $this->assetRepo->createAsset($requestedPath, ['area' => $area, 'theme' => $themePath, 'locale' => $locale, 'module' => $module]);
         $this->logger->logDebug("{$logModule} {$filePath} -> {$asset->getPath()}");
         if ($this->isDryRun) {
             $asset->getContent();
         } else {
             $this->assetPublisher->publish($asset);
         }
         $this->count++;
     } catch (\Exception $e) {
         $this->logger->logError("{$logModule} {$filePath}");
         $this->logger->logDebug((string) $e);
         $this->errorCount++;
     }
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: LogTest.php プロジェクト: shabbirvividads/magento2
 /**
  * @param int $verbosity
  * @param string $expectedMsg
  *
  * @dataProvider logDebugAltDataProvider
  */
 public function testLogDebugAlt($verbosity, $expectedMsg)
 {
     $object = new Log($verbosity);
     $object->logDebug('foo', '[alt]');
     $this->expectOutputString($expectedMsg);
 }