Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function modifyView($view) |
||
32 | { |
||
33 | $viewContent = file_get_contents($view->getPath()); |
||
34 | |||
35 | $file = tempnam(sys_get_temp_dir(), $view->name()); |
||
36 | |||
37 | $re = '/(@section\(([^))]+)\)+)(.*?)(@endsection|@show|@overwrite)/s'; |
||
38 | $viewContent = preg_replace_callback($re, function ($matches) use ($view) { |
||
39 | ++$this->viewId; |
||
40 | $sectionName = str_replace(["'", '"'], '', $matches[2]); |
||
41 | return $matches[1] . '<!--XRAY START ' . $this->viewId . ' ' . $view->getName() . '@section:' . $sectionName . ' ' . $view->getPath() . '-->' . $matches[3] . '<!--XRAY END ' . $this->viewId . '-->' . $matches[4]; |
||
42 | }, $viewContent); |
||
43 | |||
44 | $viewContent = '<!--XRAY START ' . $this->viewId . ' ' . $view->getName() . ' ' . $view->getPath() . '-->' . PHP_EOL . $viewContent . PHP_EOL . '<!--XRAY END ' . $this->viewId . '-->'; |
||
45 | |||
46 | file_put_contents($file, $viewContent); |
||
47 | |||
48 | $view->setPath($file); |
||
49 | |||
50 | ++$this->viewId; |
||
51 | } |
||
52 | |||
64 |