| @@ 406-435 (lines=30) @@ | ||
| 403 | /** |
|
| 404 | * Required by the Removable interface. |
|
| 405 | */ |
|
| 406 | public function remove(LoggerInterface $logger) |
|
| 407 | { |
|
| 408 | $hasRemovableElements = $this->configuration->get('element-blacklist') != ''; |
|
| 409 | $hasRemovableTypes = $this->configuration->get('type-blacklist') != ''; |
|
| 410 | foreach ($this->children as $child) { |
|
| 411 | // Check types. |
|
| 412 | if ($hasRemovableTypes && |
|
| 413 | !$this->configuration->isAllowedType($child->getType())) { |
|
| 414 | $logger->debug('Removing ' . $child); |
|
| 415 | $this->removeChild($child); |
|
| 416 | ||
| 417 | continue; |
|
| 418 | } |
|
| 419 | ||
| 420 | // Check elements. |
|
| 421 | if ($hasRemovableElements && |
|
| 422 | $child->getType() == Token::ELEMENT && |
|
| 423 | !$this->configuration->isAllowedElement($child->getName())) { |
|
| 424 | $logger->debug('Removing ' . $child); |
|
| 425 | $this->removeChild($child); |
|
| 426 | ||
| 427 | continue; |
|
| 428 | } |
|
| 429 | ||
| 430 | // Check children. |
|
| 431 | if ($child instanceof Removable) { |
|
| 432 | $child->remove($logger); |
|
| 433 | } |
|
| 434 | } |
|
| 435 | } |
|
| 436 | ||
| 437 | /** |
|
| 438 | * Required by the Token interface. |
|
| @@ 93-122 (lines=30) @@ | ||
| 90 | /** |
|
| 91 | * Required by the Removable interface. |
|
| 92 | */ |
|
| 93 | public function remove(LoggerInterface $logger) |
|
| 94 | { |
|
| 95 | $hasRemovableElements = $this->configuration->get('element-blacklist') != ''; |
|
| 96 | $hasRemovableTypes = $this->configuration->get('type-blacklist') != ''; |
|
| 97 | foreach ($this->children as $child) { |
|
| 98 | // Check types. |
|
| 99 | if ($hasRemovableTypes && |
|
| 100 | !$this->configuration->isAllowedType($child->getType())) { |
|
| 101 | $logger->debug('Removing ' . $child); |
|
| 102 | $this->removeChild($child); |
|
| 103 | ||
| 104 | continue; |
|
| 105 | } |
|
| 106 | ||
| 107 | // Check elements. |
|
| 108 | if ($hasRemovableElements && |
|
| 109 | $child->getType() == Token::ELEMENT && |
|
| 110 | !$this->configuration->isAllowedElement($child->getName())) { |
|
| 111 | $logger->debug('Removing ' . $child); |
|
| 112 | $this->removeChild($child); |
|
| 113 | ||
| 114 | continue; |
|
| 115 | } |
|
| 116 | ||
| 117 | // Check children. |
|
| 118 | if ($child instanceof Removable) { |
|
| 119 | $child->remove($logger); |
|
| 120 | } |
|
| 121 | } |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||