public static getBoolAttribute ( DOMElement $node, string $attribute ) : boolean | ||
$node | DOMElement | to fetch from |
$attribute | string | name to fetch |
리턴 | boolean | the value converted to bool |
public static function getBoolAttribute(DOMElement $node, $attribute)
{
if (!$node->hasAttribute($attribute)) {
throw new RepositoryException("Expected attribute {$attribute} not found on " . $node->getNodePath());
}
return 'false' !== $node->getAttribute($attribute);
}
protected function fromXML(DOMElement $node) { $this->declaringNodeType = $node->getAttribute('declaringNodeType'); $this->name = $node->getAttribute('name'); $this->isAutoCreated = Helper::getBoolAttribute($node, 'isAutoCreated'); $this->isMandatory = Helper::getBoolAttribute($node, 'mandatory'); $this->isProtected = Helper::getBoolAttribute($node, 'isProtected'); $this->onParentVersion = \PHPCR\Version\OnParentVersionAction::valueFromName($node->getAttribute('onParentVersion')); }