Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregatedFileCollector.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
23  protected $searchPattern;
24 
29 
33  protected $design;
34 
38  protected $readFactory;
39 
48  public function __construct(
52  $searchPattern = null
53  ) {
54  $this->searchPattern = $searchPattern;
55  $this->collectorAggregated = $collectorAggregated;
56  $this->design = $design;
57  $this->readFactory = $readFactory;
58  }
59 
67  public function collectFiles($searchPattern = null)
68  {
69  $result = [];
70  if ($searchPattern === null) {
72  }
73  if ($searchPattern === null) {
74  throw new \Exception('Search pattern cannot be empty.');
75  }
76  $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern);
77  foreach ($files as $file) {
78  $fullFileName = $file->getFilename();
79  $fileDir = dirname($fullFileName);
80  $fileName = basename($fullFileName);
81  $dirRead = $this->readFactory->create($fileDir);
82  $result[$fullFileName] = $dirRead->readFile($fileName);
83  }
84 
85  return $result;
86  }
87 }
__construct(CollectorInterface $collectorAggregated, DesignInterface $design, ReadFactory $readFactory, $searchPattern=null)
$fileName
Definition: translate.phtml:15
foreach($appDirs as $dir) $files