Пример #1
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;
 }
Пример #2
0
<?php

/**
 *
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
use Magento\Tools\Webdev\CliParams;
use Magento\Tools\View\Deployer\Log;
require __DIR__ . '/../../../bootstrap.php';
try {
    $opt = new \Zend_Console_Getopt(['locale=s' => 'locale, default: en_US', 'area=s' => 'area, one of (frontend|adminhtml|doc), default: frontend', 'theme=s' => 'theme in format Vendor/theme, default: Magento/blank', 'files=s' => 'files to pre-process (accept more than one file type as comma-separate values),' . ' default: css/styles-m', 'ext=s' => 'dynamic stylesheet language: less|sass', 'verbose|v' => 'provide extra output', 'help|h' => 'show help']);
    $opt->parse();
    if ($opt->getOption('help')) {
        echo $opt->getUsageMessage();
        exit(0);
    }
    $params = new CliParams($opt);
    $logger = new Log($params->getVerbose());
} catch (\Zend_Console_Getopt_Exception $e) {
    echo $e->getMessage() . PHP_EOL;
    echo 'Please, use quotes(") for wrapping strings.' . PHP_EOL;
    exit(1);
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\\Tools\\Webdev\\App\\FileAssembler', ['params' => $params, 'logger' => $logger]);
$bootstrap->run($app);