@@ -49,8 +49,9 @@ class Element
4949 *
5050 * @param bool $withoutP
5151 */
52- public function __construct (AbstractElement $ element , $ withoutP = false )
52+ public function __construct (HTML $ parentWriter , AbstractElement $ element , $ withoutP = false )
5353 {
54+ $ this ->parentWriter = $ parentWriter ;
5455 $ this ->element = $ element ;
5556 $ this ->withoutP = $ withoutP ;
5657 }
@@ -66,36 +67,10 @@ public function write()
6667 $ elmName = str_replace ('PhpOffice \\PhpWord \\Element \\' , '' , get_class ($ this ->element ));
6768 $ elmWriterClass = 'PhpOffice \\PhpWord \\Writer \\HTML \\Element \\' . $ elmName ;
6869 if (class_exists ($ elmWriterClass ) === true ) {
69- $ elmWriter = new $ elmWriterClass ($ this ->element , $ this ->withoutP );
70- $ elmWriter ->setParentWriter ($ this ->parentWriter );
70+ $ elmWriter = new $ elmWriterClass ($ this ->parentWriter , $ this ->element , $ this ->withoutP );
7171 $ html = $ elmWriter ->write ();
7272 }
7373
7474 return $ html ;
7575 }
76-
77- /**
78- * Set parent writer
79- *
80- * @param \PhpOffice\PhpWord\Writer\HTML $writer
81- */
82- public function setParentWriter (HTML $ writer )
83- {
84- $ this ->parentWriter = $ writer ;
85- }
86-
87- /**
88- * Get parent writer
89- *
90- * @return \PhpOffice\PhpWord\Writer\HTML
91- * @throws \PhpOffice\PhpWord\Exception\Exception
92- */
93- public function getParentWriter ()
94- {
95- if (!is_null ($ this ->parentWriter )) {
96- return $ this ->parentWriter ;
97- } else {
98- throw new Exception ("No parent HTML Writer assigned. " );
99- }
100- }
10176}
0 commit comments