Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileIterator.php
Go to the documentation of this file.
1 <?php
8 
11 
16 {
21 
27  public function __construct(
28  ReadFactory $readFactory,
29  array $paths,
30  \Magento\Framework\Module\Dir\ReverseResolver $dirResolver
31  ) {
32  parent::__construct($readFactory, $paths);
33  $this->_moduleDirResolver = $dirResolver;
34  }
35 
40  public function current()
41  {
42  $path = $this->key();
43  $moduleName = $this->_moduleDirResolver->getModuleName($path);
44  if (!$moduleName) {
45  throw new \UnexpectedValueException(
46  sprintf("Unable to determine a module, file '%s' belongs to.", $this->key())
47  );
48  }
49 
50  $fileRead = $this->fileReadFactory->create($this->key(), DriverPool::FILE);
51  $contents = $fileRead->readAll();
52  return str_replace('<template ', '<template module="' . $moduleName . '" ', $contents);
53  }
54 }
$contents
Definition: website.php:14
__construct(ReadFactory $readFactory, array $paths, \Magento\Framework\Module\Dir\ReverseResolver $dirResolver)