ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilHtmlPurifierComposite.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
13  protected $purifiers = [];
14 
20  public function addPurifier(ilHtmlPurifierInterface $purifier) : bool
21  {
22  $key = array_search($purifier, $this->purifiers);
23  if (false === $key) {
24  $this->purifiers[] = $purifier;
25  return true;
26  }
27 
28  return false;
29  }
30 
36  public function removePurifier(ilHtmlPurifierInterface $purifier) : bool
37  {
38  $key = array_search($purifier, $this->purifiers);
39  if (false === $key) {
40  return false;
41  }
42  unset($this->purifiers[$key]);
43 
44  return true;
45  }
46 
50  public function purify(string $html) : string
51  {
52  foreach ($this->purifiers as $purifier) {
53  $html = $purifier->purify($html);
54  }
55 
56  return $html;
57  }
58 
62  public function purifyArray(array $htmlCollection) : array
63  {
64  foreach ($htmlCollection as $key => $html) {
65  foreach ($this->purifiers as $purifier) {
66  $html = $purifier->purify($html);
67  }
68 
69  $htmlCollection[$key] = $html;
70  }
71 
72  return $htmlCollection;
73  }
74 }
addPurifier(ilHtmlPurifierInterface $purifier)
Adds a node to composite.
Composite for nesting multiple purifiers.
Interface for html sanitizing functionality.
removePurifier(ilHtmlPurifierInterface $purifier)
Removes a node from composite.