当前位置: 首页>>代码示例>>PHP>>正文


PHP Files::init方法代码示例

本文整理汇总了PHP中Magento\Framework\App\Utility\Files::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::init方法的具体用法?PHP Files::init怎么用?PHP Files::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\Utility\Files的用法示例。


在下文中一共展示了Files::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testReadListsCorruptedFile

 public function testReadListsCorruptedFile()
 {
     $result = Files::init()->readLists(__DIR__ . '/_files/list_corrupted_file.txt');
     foreach ($result as $path) {
         $this->assertNotContains('unknown.txt', $path);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:FilesTest.php

示例2: getDependencyInfo

 /**
  * Gets alien dependencies information for current module by analyzing file's contents
  *
  * @param string $currentModule
  * @param string $fileType
  * @param string $file
  * @param string $contents
  * @return array
  */
 public function getDependencyInfo($currentModule, $fileType, $file, &$contents)
 {
     if (!in_array($fileType, ['php', 'template'])) {
         return [];
     }
     $pattern = '~\\b(?<class>(?<module>(' . implode('_|', \Magento\Framework\App\Utility\Files::init()->getNamespaces()) . '[_\\\\])[a-zA-Z0-9]+)[a-zA-Z0-9_\\\\]*)\\b~';
     $dependenciesInfo = [];
     if (preg_match_all($pattern, $contents, $matches)) {
         $matches['module'] = array_unique($matches['module']);
         foreach ($matches['module'] as $i => $referenceModule) {
             $referenceModule = str_replace('_', '\\', $referenceModule);
             if ($currentModule == $referenceModule) {
                 continue;
             }
             $dependenciesInfo[] = ['module' => $referenceModule, 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => trim($matches['class'][$i])];
         }
     }
     $result = $this->_caseGetUrl($currentModule, $contents);
     if (count($result)) {
         $dependenciesInfo = array_merge($dependenciesInfo, $result);
     }
     $result = $this->_caseLayoutBlock($currentModule, $fileType, $file, $contents);
     if (count($result)) {
         $dependenciesInfo = array_merge($dependenciesInfo, $result);
     }
     return $dependenciesInfo;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:PhpRule.php

示例3: buildReport

 /**
  * Build Framework dependencies report
  *
  * @param string $outputPath
  * @return void
  */
 protected function buildReport($outputPath)
 {
     $filePaths = $this->registrar->getPaths(ComponentRegistrar::MODULE);
     $filesForParse = Files::init()->getFiles($filePaths, '*');
     $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' => $outputPath]]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:DependenciesShowFrameworkCommand.php

示例4: testObsoleteJavascriptAttributeType

 public function testObsoleteJavascriptAttributeType()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $invoker(function ($file) {
         $this->assertNotRegexp('/type="text\\/javascript"/', file_get_contents($file), 'Please do not use "text/javascript" type attribute.');
     }, \Magento\Framework\App\Utility\Files::init()->getPhtmlFiles());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:PhtmlTemplateTest.php

示例5: __construct

 /**
  * Constructor
  *
  * @param array $mapRouters
  * @param array $mapLayoutBlocks
  * @param array $mapLayoutHandles
  */
 public function __construct(array $mapRouters, array $mapLayoutBlocks, array $mapLayoutHandles)
 {
     $this->_mapRouters = $mapRouters;
     $this->_mapLayoutBlocks = $mapLayoutBlocks;
     $this->_mapLayoutHandles = $mapLayoutHandles;
     $this->_namespaces = implode('|', \Magento\Framework\App\Utility\Files::init()->getNamespaces());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:LayoutRule.php

示例6: getWhitelist

 /**
  * Returns whitelist based on blacklist and git changed files
  *
  * @param array $fileTypes
  * @param string $changedFilesBaseDir
  * @param string $baseFilesFolder
  * @return array
  */
 public static function getWhitelist($fileTypes = ['php'], $changedFilesBaseDir = '', $baseFilesFolder = '')
 {
     $globPatternsFolder = self::getBaseFilesFolder();
     if ('' !== $baseFilesFolder) {
         $globPatternsFolder = $baseFilesFolder;
     }
     $directoriesToCheck = Files::init()->readLists($globPatternsFolder . '/_files/whitelist/common.txt');
     $changedFiles = [];
     $globFilesListPattern = ($changedFilesBaseDir ?: self::getChangedFilesBaseDir()) . '/_files/changed_files*';
     foreach (glob($globFilesListPattern) as $listFile) {
         $changedFiles = array_merge($changedFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
     }
     array_walk($changedFiles, function (&$file) {
         $file = BP . '/' . $file;
     });
     $changedFiles = array_filter($changedFiles, function ($path) use($directoriesToCheck, $fileTypes) {
         if (!file_exists($path)) {
             return false;
         }
         $path = realpath($path);
         foreach ($directoriesToCheck as $directory) {
             $directory = realpath($directory);
             if (strpos($path, $directory) === 0) {
                 if (!empty($fileTypes)) {
                     return in_array(pathinfo($path, PATHINFO_EXTENSION), $fileTypes);
                 }
                 return true;
             }
         }
         return false;
     });
     return $changedFiles;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:41,代码来源:LiveCodeTest.php

示例7: testLocalXmlFilesAbsent

 public function testLocalXmlFilesAbsent()
 {
     $area = '*';
     $package = '*';
     $theme = '*';
     $this->assertEmpty(glob(\Magento\Framework\App\Utility\Files::init()->getPathToSource() . "/app/design/{$area}/{$package}/{$theme}/local.xml"));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:ObsoleteThemeLocalXmlTest.php

示例8: testObsoleteDirectives

 public function testObsoleteDirectives()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $invoker(function ($file) {
         $this->assertNotRegExp('/\\{\\{htmlescape.*?\\}\\}/i', file_get_contents($file), 'Directive {{htmlescape}} is obsolete. Use {{escapehtml}} instead.');
     }, \Magento\Framework\App\Utility\Files::init()->getEmailTemplates());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:EmailTemplateTest.php

示例9: _getBaseFrontendHandles

 /**
  * Return layout handles that are declared in the base layouts for frontend
  *
  * @return array
  */
 protected function _getBaseFrontendHandles()
 {
     if ($this->_baseFrontendHandles === null) {
         $files = \Magento\Framework\App\Utility\Files::init()->getLayoutFiles(['include_design' => false, 'area' => 'frontend'], false);
         $this->_baseFrontendHandles = $this->_extractLayoutHandles($files);
     }
     return $this->_baseFrontendHandles;
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:13,代码来源:ThemeHandlesTest.php

示例10: setupFileLists

 /**
  * Helper method to setup the black and white lists
  *
  * @param string $type
  * @return void
  */
 public static function setupFileLists($type = '')
 {
     if ($type != '' && !preg_match('/\\/$/', $type)) {
         $type = $type . '/';
     }
     self::$whiteList = Files::init()->readLists(__DIR__ . '/_files/' . $type . 'whitelist/*.txt');
     self::$blackList = Files::init()->readLists(__DIR__ . '/_files/' . $type . 'blacklist/*.txt');
 }
开发者ID:Mohitsahu123,项目名称:data-migration-tool-ce,代码行数:14,代码来源:LiveCodeTest.php

示例11: filterFiles

 /**
  * Skip blacklisted files
  *
  * @param array $fileList
  * @return array
  * @throws \Exception
  */
 private function filterFiles(array $fileList)
 {
     $blackListFiles = Files::init()->readLists(__DIR__ . '/_files/blacklist/*.txt');
     $filter = function ($value) use($blackListFiles) {
         return !in_array($value, $blackListFiles);
     };
     return array_filter($fileList, $filter);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:LiveCodeTest.php

示例12: testXmlFiles

 public function testXmlFiles()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $invoker(function ($configFile) {
         $schema = $this->urnResolver->getRealPath('urn:magento:module:Magento_Widget:etc/widget.xsd');
         $this->_validateFileExpectSuccess($configFile, $schema);
     }, array_merge(\Magento\Framework\App\Utility\Files::init()->getConfigFiles('widget.xml'), \Magento\Framework\App\Utility\Files::init()->getLayoutConfigFiles('widget.xml')));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:WidgetConfigTest.php

示例13: declaredConsistentlyDataProvider

 /**
  * @return array
  */
 public function declaredConsistentlyDataProvider()
 {
     $result = [];
     $root = \Magento\Framework\App\Utility\Files::init()->getPathToSource();
     foreach (Package::readDeclarationFiles($root) as $row) {
         $result[] = $row;
     }
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:PackageTest.php

示例14: testBlocksIntoContainers

 public function testBlocksIntoContainers()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $invoker(function ($file) {
         $xml = simplexml_load_file($file);
         $this->assertSame([], $xml->xpath('/widgets/*/supported_blocks'), 'Obsolete node: <supported_blocks>. To be replaced with <supported_containers>');
         $this->assertSame([], $xml->xpath('/widgets/*/*/*/block_name'), 'Obsolete node: <block_name>. To be replaced with <container_name>');
     }, \Magento\Framework\App\Utility\Files::init()->getConfigFiles('widget.xml'));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:9,代码来源:XmlTest.php

示例15: testXssSensitiveOutput

 /**
  * @return void
  */
 public function testXssSensitiveOutput()
 {
     $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
     $xssOutputValidator = new XssOutputValidator();
     $invoker(function ($file) use($xssOutputValidator) {
         $lines = $xssOutputValidator->getLinesWithXssSensitiveOutput($file);
         $this->assertEmpty($lines, "Potentially XSS vulnerability. " . "Please verify that output is escaped at lines " . $lines);
     }, Files::init()->getPhtmlFiles());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:XssPhtmlTemplateTest.php


注:本文中的Magento\Framework\App\Utility\Files::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。