1 | <?php |
||
17 | class Option extends OpenElement |
||
18 | { |
||
19 | 5 | protected function getAllowedAttributes() |
|
33 | |||
34 | 4 | protected function removeInvalidChildren(LoggerInterface $logger) |
|
35 | { |
||
36 | 4 | if ($this->hasAttribute('label')) { |
|
37 | 2 | if ($this->hasAttribute('value')) { |
|
38 | // If both the "label" and "value" attributes are present, |
||
39 | // then no content is allowed. |
||
40 | 2 | foreach ($this->children as $child) { |
|
41 | 2 | if ($child instanceof NonParticipating) { |
|
42 | 2 | continue; |
|
43 | } |
||
44 | |||
45 | 1 | $logger->debug('Removing ' . $child . '. No content allowed inside an "option" element that contains both "label" and "value" attribute.'); |
|
46 | 1 | $this->removeChild($child); |
|
47 | 2 | } |
|
48 | 2 | } else { |
|
49 | // If the "label" and not "value" attribute is present, |
||
50 | // then onyl text is allowed. |
||
51 | 2 | foreach ($this->children as $child) { |
|
52 | 2 | if ($child instanceof NonParticipating || |
|
53 | 2 | $child instanceof Text) { |
|
54 | 1 | continue; |
|
55 | } |
||
56 | |||
57 | 1 | $logger->debug('Removing ' . $child . '. Only text allowed inside an "option" element that contains only a "label" attribute.'); |
|
58 | 1 | $this->removeChild($child); |
|
59 | 2 | } |
|
60 | } |
||
61 | 2 | } else { |
|
62 | // If no "label" attribute is present, |
||
63 | // then only text is allowed. |
||
64 | 4 | foreach ($this->children as $child) { |
|
65 | 4 | if ($child instanceof NonParticipating || |
|
66 | 4 | $child instanceof Text) { |
|
67 | 4 | continue; |
|
68 | } |
||
69 | |||
70 | 1 | $logger->debug('Removing ' . $child . '. Only text allowed inside an "option" element that does not contain a "label" attribute.'); |
|
71 | 1 | $this->removeChild($child); |
|
72 | 4 | } |
|
73 | } |
||
74 | 4 | } |
|
75 | |||
76 | 5 | protected function removeInvalidSelf(LoggerInterface $logger) |
|
90 | } |
||
91 |