コード例 #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
ファイル: Deployer.php プロジェクト: nja78/magento2
    /**
     * Deploy a static view file
     *
     * @param string $filePath
     * @param string $area
     * @param string $themePath
     * @param string $locale
     * @param string $module
     * @return void
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    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'";
        }

        if ($this->output->isVeryVerbose()) {
            $this->output->writeln($logMessage);
        }

        try {
            $asset = $this->assetRepo->createAsset(
                $requestedPath,
                ['area' => $area, 'theme' => $themePath, 'locale' => $locale, 'module' => $module]
            );
            $asset = $this->minifyService->getAssets([$asset], true)[0];
            if ($this->output->isVeryVerbose()) {
                $this->output->writeln("\tDeploying the file to '{$asset->getPath()}'");
            } else {
                $this->output->write('.');
            }
            if ($this->isDryRun) {
                $asset->getContent();
            } else {
                $this->assetPublisher->publish($asset);
                $this->bundleManager->addAsset($asset);
            }
            $this->count++;
        } catch (\Less_Exception_Compiler $e) {
            $this->verboseLog(
                "\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."
            );
            $this->verboseLog("\tCompiler error: " . $e->getMessage());
        } catch (\Exception $e) {
            $this->output->writeln($e->getMessage() . " ($logMessage)");
            $this->verboseLog($e->getTraceAsString());
            $this->errorCount++;
        }
    }
コード例 #3
0
ファイル: Deployer.php プロジェクト: Doability/magento2dev
 /**
  * Deploy a static view file
  *
  * @param string $filePath
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @param string $module
  * @param string|null $fullPath
  * @return string
  * @throws \InvalidArgumentException
  * @throws LocalizedException
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 private function deployFile($filePath, $area, $themePath, $locale, $module, $fullPath = null)
 {
     $compiledFile = '';
     $extension = pathinfo($filePath, PATHINFO_EXTENSION);
     foreach ($this->alternativeSources as $name => $alternative) {
         if (in_array($extension, $alternative->getAlternativesExtensionsNames(), true) && strpos(basename($filePath), '_') !== 0) {
             $compiledFile = substr($filePath, 0, strlen($filePath) - strlen($extension) - 1);
             $compiledFile = $compiledFile . '.' . $name;
         }
     }
     if ($this->output->isVeryVerbose()) {
         $logMessage = "Processing file '{$filePath}' for area '{$area}', theme '{$themePath}', locale '{$locale}'";
         if ($module) {
             $logMessage .= ", module '{$module}'";
         }
         $this->output->writeln($logMessage);
     }
     try {
         $asset = $this->assetRepo->createAsset($filePath, ['area' => $area, 'theme' => $themePath, 'locale' => $locale, 'module' => $module]);
         if ($this->output->isVeryVerbose()) {
             $this->output->writeln("\tDeploying the file to '{$asset->getPath()}'");
         } else {
             $this->output->write('.');
         }
         if ($this->getOption(Options::DRY_RUN)) {
             $asset->getContent();
         } else {
             $this->assetPublisher->publish($asset);
             $this->bundleManager->addAsset($asset);
         }
         $this->count++;
     } catch (ContentProcessorException $exception) {
         $pathInfo = $fullPath ?: $filePath;
         $errorMessage = __('Compilation from source: ') . $pathInfo . PHP_EOL . $exception->getMessage();
         $this->errorCount++;
         $this->output->write(PHP_EOL . PHP_EOL . $errorMessage . PHP_EOL, true);
         $this->getLogger()->critical($errorMessage);
     } catch (\Exception $exception) {
         $this->output->write('.');
         $this->verboseLog($exception->getTraceAsString());
         $this->errorCount++;
     }
     return $compiledFile;
 }
コード例 #4
0
 public function testFlush()
 {
     $this->bundle->expects($this->once())->method('flush');
     $this->manager->flush();
 }