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')); }
protected function fromXML(DOMElement $node) { parent::fromXML($node); $this->allowsSameNameSiblings = Helper::getBoolAttribute($node, 'sameNameSiblings'); $this->defaultPrimaryTypeName = $node->getAttribute('defaultPrimaryType'); if (empty($this->defaultPrimaryTypeName)) { $this->defaultPrimaryTypeName = null; } $xp = new DOMXPath($node->ownerDocument); $requiredPrimaryTypes = $xp->query('requiredPrimaryTypes/requiredPrimaryType', $node); if (0 < $requiredPrimaryTypes->length) { foreach ($requiredPrimaryTypes as $requiredPrimaryType) { $this->requiredPrimaryTypeNames[] = $requiredPrimaryType->nodeValue; } } else { $this->requiredPrimaryTypeNames[] = self::DEFAULT_PRIMARY_NODE; } }
protected function fromXML(DOMElement $node) { parent::fromXML($node); $this->requiredType = \PHPCR\PropertyType::valueFromName($node->getAttribute('requiredType')); $this->isMultiple = Helper::getBoolAttribute($node, 'multiple'); $this->isFullTextSearchable = Helper::getBoolAttribute($node, 'fullTextSearchable'); $this->isQueryOrderable = Helper::getBoolAttribute($node, 'queryOrderable'); $xp = new DOMXPath($node->ownerDocument); $valueConstraints = $xp->query('valueConstraints/valueConstraint', $node); foreach ($valueConstraints as $valueConstraint) { $this->valueConstraints[] = $valueConstraint->nodeValue; } $availableQueryOperators = $xp->query('availableQueryOperators/availableQueryOperator', $node); foreach ($availableQueryOperators as $availableQueryOperator) { $this->availableQueryOperators[] = $availableQueryOperator->nodeValue; } $defaultValues = $xp->query('defaultValues/defaultValue', $node); foreach ($defaultValues as $defaultValue) { $this->defaultValues[] = $defaultValue->nodeValue; } }
/** * Convert NodeTypeDefintion XML into array. * * @param \DOMElement $node * @return array */ public function getNodeTypeDefinitionFromXml(DOMElement $node) { $data = array(); // nodetype $data['name'] = $node->getAttribute('name'); $data['isAbstract'] = Helper::getBoolAttribute($node, 'isAbstract'); $data['isMixin'] = Helper::getBoolAttribute($node, 'isMixin'); $data['isQueryable'] = Helper::getBoolAttribute($node, 'isQueryable'); $data['hasOrderableChildNodes'] = Helper::getBoolAttribute($node, 'hasOrderableChildNodes'); $data['primaryItemName'] = $node->getAttribute('primaryItemName') ?: null; $data['declaredSuperTypeNames'] = array(); $xp = new DOMXPath($node->ownerDocument); $supertypes = $xp->query('supertypes/supertype', $node); foreach ($supertypes as $supertype) { $data['declaredSuperTypeNames'][] = $supertype->nodeValue; } $data['declaredPropertyDefinitions'] = array(); $properties = $xp->query('propertyDefinition', $node); foreach ($properties as $propertyDefinition) { $data['declaredPropertyDefinitions'][] = $this->getPropertyDefinitionFromXml($propertyDefinition); } $data['declaredNodeDefinitions'] = array(); $declaredNodeDefinitions = $xp->query('childNodeDefinition', $node); foreach ($declaredNodeDefinitions as $nodeDefinition) { $data['declaredNodeDefinitions'][] = $this->getNodeDefinitionFromXml($nodeDefinition); } return $data; }
/** * Reads the node type definition from an xml element * * @param DOMElement $node The dom element to read information from */ protected function fromXml(DOMElement $node) { $this->name = $node->getAttribute('name'); $this->isAbstract = Helper::getBoolAttribute($node, 'isAbstract'); $this->isMixin = Helper::getBoolAttribute($node, 'isMixin'); $this->isQueryable = Helper::getBoolAttribute($node, 'isQueryable'); $this->hasOrderableChildNodes = Helper::getBoolAttribute($node, 'hasOrderableChildNodes'); $this->primaryItemName = $node->getAttribute('primaryItemName'); if (empty($this->primaryItemName)) { $this->primaryItemName = null; } $this->declaredSuperTypeNames = array(); $xp = new DOMXPath($node->ownerDocument); $supertypes = $xp->query('supertypes/supertype', $node); foreach ($supertypes as $supertype) { $this->declaredSuperTypeNames[] = $supertype->nodeValue; } $this->declaredPropertyDefinitions = new ArrayObject(); $properties = $xp->query('propertyDefinition', $node); foreach ($properties as $property) { $this->declaredPropertyDefinitions[] = $this->factory->get('NodeType\\PropertyDefinition', array($property, $this->nodeTypeManager)); } $this->declaredNodeDefinitions = new ArrayObject(); $declaredNodeDefinitions = $xp->query('childNodeDefinition', $node); foreach ($declaredNodeDefinitions as $nodeDefinition) { $this->declaredNodeDefinitions[] = $this->factory->get('NodeType\\NodeDefinition', array($nodeDefinition, $this->nodeTypeManager)); } }
/** * Returns the property of this node with name $name. If $type is set, * attempts to convert the value to the specified type. * * This is a shortcut for getProperty().getXXX() * * @param string $name Name of this property * @param integer $type Type conversion request, optional. Must be a constant from PropertyType * @return mixed The value of the property with $name. * @throws \PHPCR\PathNotFoundException if no property exists at the specified path or if the current Session does not have read access to the specified property. * @throws \PHPCR\ValueFormatException if the type or format of the property can not be converted to the specified type. * @throws \PHPCR\RepositoryException If another error occurs. * @api */ public function getPropertyValue($name, $type = null) { $val = $this->getProperty($name)->getNativeValue(); if (!is_null($type)) { $val = Helper::convertType($val, $type); } return $val; }