Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Comment.php
Go to the documentation of this file.
1 <?php
7 
15 
25 {
29  private $filesystem;
30 
34  private $placeholder;
35 
40  public function __construct(
41  Filesystem $filesystem,
42  PlaceholderInterface $placeholder
43  ) {
44  $this->filesystem = $filesystem;
45  $this->placeholder = $placeholder;
46  }
47 
89  public function execute($fileName)
90  {
91  $fileContent = $this->filesystem
92  ->getDirectoryRead(DirectoryList::CONFIG)
93  ->readFile($fileName);
94 
95  $pattern = sprintf('/\s+\*\s+(?P<placeholder>%s.*?)\s/', preg_quote(Environment::PREFIX));
96  preg_match_all($pattern, $fileContent, $matches);
97 
98  if (!isset($matches['placeholder'])) {
99  return [];
100  }
101 
102  $configs = [];
103  foreach ($matches['placeholder'] as $placeholder) {
104  $path = $this->placeholder->restore($placeholder);
105  $path = preg_replace('/^' . ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '\//', '', $path);
106  $configs[$placeholder] = $path;
107  }
108 
109  return $configs;
110  }
111 }
$pattern
Definition: website.php:22
$fileName
Definition: translate.phtml:15
__construct(Filesystem $filesystem, PlaceholderInterface $placeholder)
Definition: Comment.php:40
$filesystem