本文整理汇总了PHP中Magento\Framework\App\Utility\Files::getStaticPreProcessingFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::getStaticPreProcessingFiles方法的具体用法?PHP Files::getStaticPreProcessingFiles怎么用?PHP Files::getStaticPreProcessingFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Utility\Files
的用法示例。
在下文中一共展示了Files::getStaticPreProcessingFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collectAppFiles
/**
* 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->output->writeln(
"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];
}
示例2: deploy
/**
* Populate all static view files for specified root path and list of languages
*
* @param ObjectManagerFactory $omFactory
* @param array $locales
* @param array $deployableAreaThemeMap
* @return int
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function deploy(ObjectManagerFactory $omFactory, array $locales, array $deployableAreaThemeMap = [])
{
$this->omFactory = $omFactory;
if ($this->getOption(Options::DRY_RUN)) {
$this->output->writeln('Dry run. Nothing will be recorded to the target directory.');
}
$libFiles = $this->filesUtil->getStaticLibraryFiles();
$appFiles = $this->filesUtil->getStaticPreProcessingFiles();
foreach ($deployableAreaThemeMap as $area => $themes) {
$this->emulateApplicationArea($area);
foreach ($locales as $locale) {
$this->emulateApplicationLocale($locale, $area);
foreach ($themes as $themePath) {
$this->output->writeln("=== {$area} -> {$themePath} -> {$locale} ===");
$this->count = 0;
$this->errorCount = 0;
/** @var \Magento\Theme\Model\View\Design $design */
$design = $this->objectManager->create(\Magento\Theme\Model\View\Design::class);
$design->setDesignTheme($themePath, $area);
$assetRepo = $this->objectManager->create(\Magento\Framework\View\Asset\Repository::class, ['design' => $design]);
/** @var \Magento\RequireJs\Model\FileManager $fileManager */
$fileManager = $this->objectManager->create(\Magento\RequireJs\Model\FileManager::class, ['config' => $this->objectManager->create(\Magento\Framework\RequireJs\Config::class, ['assetRepo' => $assetRepo, 'design' => $design]), 'assetRepo' => $assetRepo]);
$fileManager->createRequireJsConfigAsset();
foreach ($appFiles as $info) {
list($fileArea, $fileTheme, , $module, $filePath, $fullPath) = $info;
if ($this->checkSkip($filePath)) {
continue;
}
if (($fileArea == $area || $fileArea == 'base') && ($fileTheme == '' || $fileTheme == $themePath || in_array($fileArea . Theme::THEME_PATH_SEPARATOR . $fileTheme, $this->findAncestors($area . Theme::THEME_PATH_SEPARATOR . $themePath)))) {
$compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, $module, $fullPath);
if ($compiledFile !== '') {
$this->deployFile($compiledFile, $area, $themePath, $locale, $module, $fullPath);
}
}
}
foreach ($libFiles as $filePath) {
if ($this->checkSkip($filePath)) {
continue;
}
$compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, null);
if ($compiledFile !== '') {
$this->deployFile($compiledFile, $area, $themePath, $locale, null);
}
}
if (!$this->getOption(Options::NO_JAVASCRIPT)) {
if ($this->jsTranslationConfig->dictionaryEnabled()) {
$dictionaryFileName = $this->jsTranslationConfig->getDictionaryFileName();
$this->deployFile($dictionaryFileName, $area, $themePath, $locale, null);
}
if ($this->getMinification()->isEnabled('js')) {
$fileManager->createMinResolverAsset();
}
}
$this->bundleManager->flush();
$this->output->writeln("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n");
}
}
}
if (!($this->getOption(Options::NO_HTML_MINIFY) ?: !$this->getAssetConfig()->isMinifyHtml())) {
$this->output->writeln('=== Minify templates ===');
$this->count = 0;
foreach ($this->filesUtil->getPhtmlFiles(false, false) as $template) {
$this->htmlMinifier->minify($template);
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->output->writeln($template . " minified\n");
} else {
$this->output->write('.');
}
$this->count++;
}
$this->output->writeln("\nSuccessful: {$this->count} files modified\n---\n");
}
$version = (new \DateTime())->getTimestamp();
$this->output->writeln("New version of deployed files: {$version}");
if (!$this->getOption(Options::DRY_RUN)) {
$this->versionStorage->save($version);
}
if ($this->errorCount > 0) {
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
}
示例3: prepareDeployableEntities
/**
* @param Files $filesUtil
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function prepareDeployableEntities($filesUtil)
{
$magentoAreas = [];
$magentoThemes = [];
$magentoLanguages = [self::DEFAULT_LANGUAGE_VALUE];
$areaThemeMap = [];
$files = $filesUtil->getStaticPreProcessingFiles();
foreach ($files as $info) {
list($area, $themePath, $locale) = $info;
if ($themePath) {
$areaThemeMap[$area][$themePath] = $themePath;
}
if ($themePath && $area && !in_array($area, $magentoAreas)) {
$magentoAreas[] = $area;
}
if ($locale && !in_array($locale, $magentoLanguages)) {
$magentoLanguages[] = $locale;
}
if ($themePath && !in_array($themePath, $magentoThemes)) {
$magentoThemes[] = $themePath;
}
}
$areasInclude = $this->input->getOption(Options::AREA);
$areasExclude = $this->input->getOption(Options::EXCLUDE_AREA);
$this->checkAreasInput($magentoAreas, $areasInclude, $areasExclude);
$deployableAreas = $this->getDeployableEntities($magentoAreas, $areasInclude, $areasExclude);
$languagesInclude = $this->input->getArgument(self::LANGUAGES_ARGUMENT) ?: $this->input->getOption(Options::LANGUAGE);
$languagesExclude = $this->input->getOption(Options::EXCLUDE_LANGUAGE);
$this->checkLanguagesInput($languagesInclude, $languagesExclude);
$deployableLanguages = $languagesInclude[0] == 'all' ? $this->getDeployableEntities($magentoLanguages, $languagesInclude, $languagesExclude) : $languagesInclude;
$themesInclude = $this->input->getOption(Options::THEME);
$themesExclude = $this->input->getOption(Options::EXCLUDE_THEME);
$this->checkThemesInput($magentoThemes, $themesInclude, $themesExclude);
$deployableThemes = $this->getDeployableEntities($magentoThemes, $themesInclude, $themesExclude);
$deployableAreaThemeMap = [];
$requestedThemes = [];
foreach ($areaThemeMap as $area => $themes) {
if (in_array($area, $deployableAreas) && ($themes = array_intersect($themes, $deployableThemes))) {
$deployableAreaThemeMap[$area] = $themes;
$requestedThemes += $themes;
}
}
return [$deployableLanguages, $deployableAreaThemeMap, $requestedThemes];
}