AbstractElement.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @see https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2018 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Writer\HTML\Element;
  18. use Laminas\Escaper\Escaper;
  19. use PhpOffice\PhpWord\Element\AbstractElement as Element;
  20. use PhpOffice\PhpWord\Writer\AbstractWriter;
  21. /**
  22. * Abstract HTML element writer
  23. *
  24. * @since 0.11.0
  25. */
  26. abstract class AbstractElement
  27. {
  28. /**
  29. * Parent writer
  30. *
  31. * @var \PhpOffice\PhpWord\Writer\AbstractWriter
  32. */
  33. protected $parentWriter;
  34. /**
  35. * Element
  36. *
  37. * @var \PhpOffice\PhpWord\Element\AbstractElement
  38. */
  39. protected $element;
  40. /**
  41. * Without paragraph
  42. *
  43. * @var bool
  44. */
  45. protected $withoutP = false;
  46. /**
  47. * @var \Laminas\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
  48. */
  49. protected $escaper;
  50. /**
  51. * Write element
  52. */
  53. abstract public function write();
  54. /**
  55. * Create new instance
  56. *
  57. * @param \PhpOffice\PhpWord\Writer\AbstractWriter $parentWriter
  58. * @param \PhpOffice\PhpWord\Element\AbstractElement $element
  59. * @param bool $withoutP
  60. */
  61. public function __construct(AbstractWriter $parentWriter, Element $element, $withoutP = false)
  62. {
  63. $this->parentWriter = $parentWriter;
  64. $this->element = $element;
  65. $this->withoutP = $withoutP;
  66. $this->escaper = new Escaper();
  67. }
  68. /**
  69. * Set without paragraph.
  70. *
  71. * @param bool $value
  72. */
  73. public function setWithoutP($value)
  74. {
  75. $this->withoutP = $value;
  76. }
  77. }