Example #1
0
 /**
  * Returns an array of phrases used by JavaScript files in a specific area of magento.
  *
  * @param string $area of magento to search, such as 'frontend' or 'adminthml'
  * @return string[]
  */
 protected function _getJavascriptPhrases($area)
 {
     $jsPhrases = [];
     foreach ($this->_utilityFiles->getJsFilesForArea($area) as $file) {
         $this->_parser->parse($file);
         $jsPhrases = array_merge($jsPhrases, $this->_parser->getPhrases());
     }
     return $jsPhrases;
 }
Example #2
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];
 }
Example #3
0
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/bootstrap.php';
use Magento\Framework\Test\Utility\Files;
use Magento\Tools\Dependency\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(['directory|d=s' => 'Path to base directory for parsing']);
    $console->parse();
    $directory = $console->getOption('directory') ?: BP;
    Files::setInstance(new \Magento\Framework\Test\Utility\Files($directory));
    $filesForParse = Files::init()->getComposerFiles('code', false);
    ServiceLocator::getCircularDependenciesReportBuilder()->build(['parse' => ['files_for_parse' => $filesForParse], 'write' => ['report_filename' => 'modules-circular-dependencies.csv']]);
    fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL);
} catch (\Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getUsageMessage() . PHP_EOL);
    exit(1);
} catch (\Exception $e) {
    fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL);
    exit(1);
}
Example #4
0
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/bootstrap.php';
use Magento\Framework\Test\Utility\Files;
use Magento\Tools\Dependency\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(['directory|d=s' => 'Path to base directory for parsing']);
    $console->parse();
    $directory = $console->getOption('directory') ?: BP;
    Files::setInstance(new \Magento\Framework\Test\Utility\Files($directory));
    $filesForParse = Files::init()->getFiles([Files::init()->getPathToSource() . '/app/code/Magento'], '*');
    $configFiles = Files::init()->getConfigFiles('module.xml', [], false);
    ServiceLocator::getFrameworkDependenciesReportBuilder()->build(['parse' => ['files_for_parse' => $filesForParse, 'config_files' => $configFiles, 'declared_namespaces' => Files::init()->getNamespaces()], 'write' => ['report_filename' => 'framework-dependencies.csv']]);
    fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL);
} catch (\Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getUsageMessage() . PHP_EOL);
    exit(1);
} catch (\Exception $e) {
    fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL);
    exit(1);
}
Example #5
0
 /**
  * Fetch virtual class declarations from DI configs
  *
  * @return array
  */
 public static function getVirtualClasses()
 {
     if (!empty(self::$_virtualClasses)) {
         return self::$_virtualClasses;
     }
     $configFiles = \Magento\Framework\Test\Utility\Files::init()->getDiConfigs();
     foreach ($configFiles as $fileName) {
         $configDom = new \DOMDocument();
         $configDom->load($fileName);
         $xPath = new \DOMXPath($configDom);
         $vTypes = $xPath->query('/config/virtualType');
         /** @var \DOMNode $virtualType */
         foreach ($vTypes as $virtualType) {
             $name = $virtualType->attributes->getNamedItem('name')->textContent;
             if (!$virtualType->attributes->getNamedItem('type')) {
                 continue;
             }
             $type = $virtualType->attributes->getNamedItem('type')->textContent;
             self::$_virtualClasses[$name] = $type;
         }
     }
     return self::$_virtualClasses;
 }