Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Base.php
Go to the documentation of this file.
1 <?php
7 
12 use Magento\Framework\View\File\Factory as FileFactory;
13 
17 class Base implements CollectorInterface
18 {
23 
27  private $subDir;
28 
32  private $fileFactory;
33 
41  public function __construct(
43  FileFactory $fileFactory,
44  $subDir = ''
45  ) {
46  $this->componentDirSearch = $dirSearch;
47  $this->fileFactory = $fileFactory;
48  $this->subDir = $subDir ? $subDir . '/' : '';
49  }
50 
58  public function getFiles(ThemeInterface $theme, $filePath)
59  {
60  $result = [];
61  $sharedFiles = $this->componentDirSearch->collectFilesWithContext(
62  ComponentRegistrar::MODULE,
63  "view/base/{$this->subDir}{$filePath}"
64  );
65  foreach ($sharedFiles as $file) {
66  $result[] = $this->fileFactory->create($file->getFullPath(), $file->getComponentName(), null, true);
67  }
68  $area = $theme->getData('area');
69  $themeFiles = $this->componentDirSearch->collectFilesWithContext(
70  ComponentRegistrar::MODULE,
71  "view/{$area}/{$this->subDir}{$filePath}"
72  );
73  foreach ($themeFiles as $file) {
74  $result[] = $this->fileFactory->create($file->getFullPath(), $file->getComponentName());
75  }
76  return $result;
77  }
78 }
__construct(DirSearch $dirSearch, FileFactory $fileFactory, $subDir='')
Definition: Base.php:41
getFiles(ThemeInterface $theme, $filePath)
Definition: Base.php:58
$dirSearch
Definition: bootstrap.php:86