File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace SyntaxPhoenix \EJSParserBundle \Exception ;
4
+
5
+ use Exception ;
6
+
7
+ class NoBlockException extends Exception
8
+ {
9
+ }
Original file line number Diff line number Diff line change 6
6
use Exception ;
7
7
use DOMDocument ;
8
8
use Masterminds \HTML5 ;
9
+ use SyntaxPhoenix \EJSParserBundle \Exception \NoBlockException ;
9
10
use SyntaxPhoenix \EJSParserBundle \Parser \Extension \RawParser ;
10
11
use SyntaxPhoenix \EJSParserBundle \Parser \Extension \CodeParser ;
11
12
use SyntaxPhoenix \EJSParserBundle \Parser \Extension \LinkParser ;
@@ -69,9 +70,13 @@ public function setData(object $data): void
69
70
70
71
public function toHtml (): string
71
72
{
72
- $ this ->render ();
73
-
74
- return $ this ->dom ->saveHTML ();
73
+ try {
74
+ $ this ->render ();
75
+
76
+ return $ this ->dom ->saveHTML ();
77
+ } catch (NoBlockException $ exception ) {
78
+ return '' ;
79
+ }
75
80
}
76
81
77
82
private function hasBlocks ()
@@ -85,7 +90,7 @@ private function hasBlocks()
85
90
private function render (): void
86
91
{
87
92
if (!$ this ->hasBlocks ()) {
88
- throw new Exception ('No Blocks to parse ! ' );
93
+ throw new NoBlockException ('No Blocks to parse ! ' );
89
94
}
90
95
foreach ($ this ->data ->blocks as $ block ) {
91
96
if (array_key_exists ($ block ->type , $ this ->parser )) {
You can’t perform that action at this time.
0 commit comments