1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,102 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace Illuminate\View\Engines; |
|
4 |
- |
|
5 |
-use Exception; |
|
6 |
-use ErrorException; |
|
7 |
-use Illuminate\View\Compilers\CompilerInterface; |
|
8 |
- |
|
9 |
-class CompilerEngine extends PhpEngine |
|
10 |
-{ |
|
11 |
- /** |
|
12 |
- * The Blade compiler instance. |
|
13 |
- * |
|
14 |
- * @var \Illuminate\View\Compilers\CompilerInterface |
|
15 |
- */ |
|
16 |
- protected $compiler; |
|
17 |
- |
|
18 |
- /** |
|
19 |
- * A stack of the last compiled templates. |
|
20 |
- * |
|
21 |
- * @var array |
|
22 |
- */ |
|
23 |
- protected $lastCompiled = []; |
|
24 |
- |
|
25 |
- /** |
|
26 |
- * Create a new Blade view engine instance. |
|
27 |
- * |
|
28 |
- * @param \Illuminate\View\Compilers\CompilerInterface $compiler |
|
29 |
- * @return void |
|
30 |
- */ |
|
31 |
- public function __construct(CompilerInterface $compiler) |
|
32 |
- { |
|
33 |
- $this->compiler = $compiler; |
|
34 |
- } |
|
35 |
- |
|
36 |
- /** |
|
37 |
- * Get the evaluated contents of the view. |
|
38 |
- * |
|
39 |
- * @param string $path |
|
40 |
- * @param array $data |
|
41 |
- * @return string |
|
42 |
- */ |
|
43 |
- public function get($path, array $data = []) |
|
44 |
- { |
|
45 |
- $this->lastCompiled[] = $path; |
|
46 |
- |
|
47 |
- // If this given view has expired, which means it has simply been edited since |
|
48 |
- // it was last compiled, we will re-compile the views so we can evaluate a |
|
49 |
- // fresh copy of the view. We'll pass the compiler the path of the view. |
|
50 |
- if ($this->compiler->isExpired($path)) { |
|
51 |
- $this->compiler->compile($path); |
|
52 |
- } |
|
53 |
- |
|
54 |
- $compiled = $this->compiler->getCompiledPath($path); |
|
55 |
- |
|
56 |
- // Once we have the path to the compiled file, we will evaluate the paths with |
|
57 |
- // typical PHP just like any other templates. We also keep a stack of views |
|
58 |
- // which have been rendered for right exception messages to be generated. |
|
59 |
- $results = $this->evaluatePath($compiled, $data); |
|
60 |
- |
|
61 |
- array_pop($this->lastCompiled); |
|
62 |
- |
|
63 |
- return $results; |
|
64 |
- } |
|
65 |
- |
|
66 |
- /** |
|
67 |
- * Handle a view exception. |
|
68 |
- * |
|
69 |
- * @param \Exception $e |
|
70 |
- * @param int $obLevel |
|
71 |
- * @return void |
|
72 |
- * |
|
73 |
- * @throws \Exception |
|
74 |
- */ |
|
75 |
- protected function handleViewException(Exception $e, $obLevel) |
|
76 |
- { |
|
77 |
- $e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); |
|
78 |
- |
|
79 |
- parent::handleViewException($e, $obLevel); |
|
80 |
- } |
|
81 |
- |
|
82 |
- /** |
|
83 |
- * Get the exception message for an exception. |
|
84 |
- * |
|
85 |
- * @param \Exception $e |
|
86 |
- * @return string |
|
87 |
- */ |
|
88 |
- protected function getMessage(Exception $e) |
|
89 |
- { |
|
90 |
- return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')'; |
|
91 |
- } |
|
92 |
- |
|
93 |
- /** |
|
94 |
- * Get the compiler implementation. |
|
95 |
- * |
|
96 |
- * @return \Illuminate\View\Compilers\CompilerInterface |
|
97 |
- */ |
|
98 |
- public function getCompiler() |
|
99 |
- { |
|
100 |
- return $this->compiler; |
|
101 |
- } |
|
102 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,102 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace Illuminate\View\Engines; |
|
4 |
+ |
|
5 |
+use Exception; |
|
6 |
+use ErrorException; |
|
7 |
+use Illuminate\View\Compilers\CompilerInterface; |
|
8 |
+ |
|
9 |
+class CompilerEngine extends PhpEngine |
|
10 |
+{ |
|
11 |
+ /** |
|
12 |
+ * The Blade compiler instance. |
|
13 |
+ * |
|
14 |
+ * @var \Illuminate\View\Compilers\CompilerInterface |
|
15 |
+ */ |
|
16 |
+ protected $compiler; |
|
17 |
+ |
|
18 |
+ /** |
|
19 |
+ * A stack of the last compiled templates. |
|
20 |
+ * |
|
21 |
+ * @var array |
|
22 |
+ */ |
|
23 |
+ protected $lastCompiled = []; |
|
24 |
+ |
|
25 |
+ /** |
|
26 |
+ * Create a new Blade view engine instance. |
|
27 |
+ * |
|
28 |
+ * @param \Illuminate\View\Compilers\CompilerInterface $compiler |
|
29 |
+ * @return void |
|
30 |
+ */ |
|
31 |
+ public function __construct(CompilerInterface $compiler) |
|
32 |
+ { |
|
33 |
+ $this->compiler = $compiler; |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ /** |
|
37 |
+ * Get the evaluated contents of the view. |
|
38 |
+ * |
|
39 |
+ * @param string $path |
|
40 |
+ * @param array $data |
|
41 |
+ * @return string |
|
42 |
+ */ |
|
43 |
+ public function get($path, array $data = []) |
|
44 |
+ { |
|
45 |
+ $this->lastCompiled[] = $path; |
|
46 |
+ |
|
47 |
+ // If this given view has expired, which means it has simply been edited since |
|
48 |
+ // it was last compiled, we will re-compile the views so we can evaluate a |
|
49 |
+ // fresh copy of the view. We'll pass the compiler the path of the view. |
|
50 |
+ if ($this->compiler->isExpired($path)) { |
|
51 |
+ $this->compiler->compile($path); |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ $compiled = $this->compiler->getCompiledPath($path); |
|
55 |
+ |
|
56 |
+ // Once we have the path to the compiled file, we will evaluate the paths with |
|
57 |
+ // typical PHP just like any other templates. We also keep a stack of views |
|
58 |
+ // which have been rendered for right exception messages to be generated. |
|
59 |
+ $results = $this->evaluatePath($compiled, $data); |
|
60 |
+ |
|
61 |
+ array_pop($this->lastCompiled); |
|
62 |
+ |
|
63 |
+ return $results; |
|
64 |
+ } |
|
65 |
+ |
|
66 |
+ /** |
|
67 |
+ * Handle a view exception. |
|
68 |
+ * |
|
69 |
+ * @param \Exception $e |
|
70 |
+ * @param int $obLevel |
|
71 |
+ * @return void |
|
72 |
+ * |
|
73 |
+ * @throws \Exception |
|
74 |
+ */ |
|
75 |
+ protected function handleViewException(Exception $e, $obLevel) |
|
76 |
+ { |
|
77 |
+ $e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); |
|
78 |
+ |
|
79 |
+ parent::handleViewException($e, $obLevel); |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ /** |
|
83 |
+ * Get the exception message for an exception. |
|
84 |
+ * |
|
85 |
+ * @param \Exception $e |
|
86 |
+ * @return string |
|
87 |
+ */ |
|
88 |
+ protected function getMessage(Exception $e) |
|
89 |
+ { |
|
90 |
+ return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')'; |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ /** |
|
94 |
+ * Get the compiler implementation. |
|
95 |
+ * |
|
96 |
+ * @return \Illuminate\View\Compilers\CompilerInterface |
|
97 |
+ */ |
|
98 |
+ public function getCompiler() |
|
99 |
+ { |
|
100 |
+ return $this->compiler; |
|
101 |
+ } |
|
102 |
+} |