-
Notifications
You must be signed in to change notification settings - Fork 148
Conversation
… wont include the element to the output
…ll Element object tree structure
// Stripes empty spaces, , <br/>, new lines | ||
$text = strip_tags($text); | ||
$text = preg_replace("/[\r\n\s]+/", "", $text); | ||
$text = str_replace(" ", "", $text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where the $text
param comes from, but for me in my attempts to strip whitespace for checking if a DOMElement::nodeValue
was empty, I needed to do:
$trimmed = trim($child->nodeValue, " \t\n\r\0\x0B\xC2\xA0");
if (!empty($trimmed)) {
return FALSE;
}
@everton-rosario are you finished with updates here? If so I'll try to find time to take it for a spin on our site. |
…ent is an Element that can contain other Elements. With this interface is possible to navigate the full tree and check the isValid() items.
…dren() methods that were previously created
@m4olivei Im almost done on this new feature. |
…face for polimorfic OO
… for the warnings during validation
if ($this->credits) { | ||
if (is_array($this->credits)) { | ||
foreach ($this->credits as $paragraph) { | ||
if (Type::is($paragraph, Element::getClassName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noted that on:
We are not enforcing the type of the array to be only Paragraph
s. Please add this validation there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be String or string[] as well. This would be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
*/ | ||
public function isValid() | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider returning invalid if it contains any textChildren (as it'll not be rendered).
This validator checks for all Element's required fields. If any element is invalid
isValid()
, it will generate a empty content on thetoDOMElement()
method.toDOMElements will have an if (!$this->isValid()) -> Wont output itself.
This way we dont: