本文整理汇总了PHP中PHPCR\NodeInterface::getProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getProperty方法的具体用法?PHP NodeInterface::getProperty怎么用?PHP NodeInterface::getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSize
/**
* Get the size of the <strong>stored</strong> data stream in this
* resource.
*
* You should call this method instead of anything else to know the file
* size as PHPCR implementations are expected to be able to provide this
* information without needing to to load the actual data stream.
*
* Do not use this right after updating data before flushing, as it will
* only look at the stored data.
*
* @return int the resource size in bytes.
*/
public function getSize()
{
if (null === $this->node) {
throw new BadMethodCallException('Do not call Resource::getSize on unsaved objects, as it only reads the stored size.');
}
return $this->node->getProperty('jcr:data')->getLength();
}
示例2: remove
/**
* {@inheritdoc}
*/
public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
{
// if exist remove property of node
if ($node->hasProperty($property->getName())) {
$node->getProperty($property->getName())->remove();
}
}
示例3: removeTranslation
/**
* {@inheritdoc}
*/
public function removeTranslation($document, NodeInterface $node, ClassMetadata $metadata, $locale)
{
foreach ($metadata->translatableFields as $field) {
$propName = $this->getTranslatedPropertyName($locale, $field);
$prop = $node->getProperty($propName);
$prop->remove();
}
}
示例4: saveData
/**
*
*
* @param NodeInterface $contentNode
* @param string $filesystemPath
* @return Boolean
*/
protected function saveData($contentNode, $filesystemPath)
{
$data = $contentNode->getProperty('jcr:data')->getString();
$dirname = dirname($filesystemPath);
if (!file_exists($dirname)) {
mkdir($dirname, 0755, true);
}
return file_put_contents($filesystemPath, $data);
}
示例5: getClassName
/**
* Determine the class name from a given node
*
* @param DocumentManager
* @param NodeInterface $node
* @param string $className
*
* @return string
*
* @throws \RuntimeException if no class name could be determined
*/
public function getClassName(DocumentManager $dm, NodeInterface $node, $className = null)
{
if (empty($className) && $node->hasProperty('phpcr:class')) {
$className = $node->getProperty('phpcr:class')->getString();
}
// default to the built in generic document class
if (empty($className)) {
$className = 'Doctrine\\ODM\\PHPCR\\Document\\Generic';
}
return $className;
}
示例6: testGetWeakReferencesName
/**
* @group getWeakReferences
*/
public function testGetWeakReferencesName()
{
$target = $this->rootNode->getNode('tests_general_base/idExample/jcr:content/weakreference_target');
$source = $this->rootNode->getProperty('tests_general_base/idExample/jcr:content/weakreference_source1/ref1');
$iterator = $target->getWeakReferences('ref1');
$this->assertInstanceOf('Iterator', $iterator);
$this->assertCount(1, $iterator, 'Wrong number of weak references to weakreference_target');
foreach ($iterator as $prop) {
$this->assertInstanceOf('\\PHPCR\\PropertyInterface', $prop);
$this->assertEquals($prop, $source);
}
}
示例7: testRemove
public function testRemove()
{
$type = new ContactSelectionContentType($this->template, $this->contactManager->reveal(), $this->accountManager->reveal(), $this->serializer->reveal(), new CustomerIdConverter(), new IndexComparator());
$nodeProperty = $this->prophesize(\PHPCR\PropertyInterface::class);
$nodeProperty->remove()->shouldBeCalled();
$nodeProperty->setValue(Argument::any())->shouldNotBeCalled();
$nodeProperty->getValue(Argument::any())->shouldNotBeCalled();
$this->property->getName()->willReturn('test');
$this->property->getValue()->shouldNotBeCalled();
$this->node->hasProperty('test')->willReturn(true);
$this->node->getProperty('test')->willReturn($nodeProperty->reveal());
$this->node->setProperty(Argument::any(), Argument::any())->shouldNotBeCalled();
$type->remove($this->node->reveal(), $this->property->reveal(), $this->webspaceKey, $this->locale, $this->segmentKey);
}
示例8: getClassName
/**
* {@inheritDoc}
*/
public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, $className = null)
{
$className = $this->expandClassName($dm, $className);
if ($node->hasProperty('phpcr:class')) {
$nodeClassName = $node->getProperty('phpcr:class')->getString();
if (!empty($className) && $nodeClassName !== $className && !is_subclass_of($nodeClassName, $className)) {
throw ClassMismatchException::incompatibleClasses($node->getPath(), $nodeClassName, $className);
}
$className = $nodeClassName;
}
// default to the built in generic document class
if (empty($className)) {
$className = 'Doctrine\\ODM\\PHPCR\\Document\\Generic';
}
return $className;
}
示例9: removeAssoc
/**
* Remove an associative array form the properties stored with the node
*
* @param NodeInterface $node the node where to store the assoc array
* @param array $mapping the field's mapping
*/
public function removeAssoc(NodeInterface $node, array $mapping)
{
if ($node->hasProperty($mapping['assoc'])) {
$node->getProperty($mapping['assoc'])->remove();
}
if ($node->hasProperty($mapping['assocNulls'])) {
$node->getProperty($mapping['assocNulls'])->remove();
}
}
示例10: processNodeWithType
/**
* Validate this node with the nodetype and generate not yet existing
* autogenerated properties as necessary.
*
* @param NodeInterface $node
* @param NodeType $nodeTypeDefinition
*
* @return AddNodeOperation[] Additional operations to handle autocreated nodes.
*
* @throws \InvalidArgumentException
* @throws RepositoryException
* @throws ItemExistsException
* @throws LockException
* @throws ConstraintViolationException
* @throws PathNotFoundException
* @throws VersionException
* @throws ValueFormatException
*/
private function processNodeWithType(NodeInterface $node, NodeType $nodeTypeDefinition)
{
$additionalOperations = array();
foreach ($nodeTypeDefinition->getDeclaredChildNodeDefinitions() as $childDef) {
/* @var $childDef NodeDefinitionInterface */
if (!$node->hasNode($childDef->getName())) {
if ('*' === $childDef->getName()) {
continue;
}
if ($childDef->isMandatory() && !$childDef->isAutoCreated()) {
throw new RepositoryException(sprintf('Child "%s" is mandatory, but is not present while saving "%s" at path "%s"', $childDef->getName(), $nodeTypeDefinition->getName(), $node->getPath()));
}
if ($childDef->isAutoCreated()) {
$requiredPrimaryTypeNames = $childDef->getRequiredPrimaryTypeNames();
$primaryType = count($requiredPrimaryTypeNames) ? current($requiredPrimaryTypeNames) : null;
$newNode = $node->addNode($childDef->getName(), $primaryType);
$absPath = $node->getPath() . '/' . $childDef->getName();
$operation = new AddNodeOperation($absPath, $newNode);
$additionalOperations[] = $operation;
}
}
}
foreach ($nodeTypeDefinition->getDeclaredPropertyDefinitions() as $propertyDef) {
/* @var $propertyDef PropertyDefinitionInterface */
if ('*' === $propertyDef->getName()) {
continue;
}
if (!$node->hasProperty($propertyDef->getName())) {
if ($propertyDef->isMandatory() && !$propertyDef->isAutoCreated()) {
throw new RepositoryException(sprintf('Property "%s" is mandatory, but is not present while saving "%s" at "%s"', $propertyDef->getName(), $nodeTypeDefinition->getName(), $node->getPath()));
}
if ($propertyDef->isAutoCreated()) {
switch ($propertyDef->getName()) {
case 'jcr:uuid':
$value = UUIDHelper::generateUUID();
break;
case 'jcr:createdBy':
case 'jcr:lastModifiedBy':
$value = $this->userId;
break;
case 'jcr:created':
case 'jcr:lastModified':
$value = new \DateTime();
break;
case 'jcr:etag':
// TODO: http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.7.12.1%20mix:etag
$value = 'TODO: generate from binary properties of this node';
break;
default:
$defaultValues = $propertyDef->getDefaultValues();
if ($propertyDef->isMultiple()) {
$value = $defaultValues;
} elseif (isset($defaultValues[0])) {
$value = $defaultValues[0];
} else {
// When implementing versionable or activity, we need to handle more properties explicitly
throw new RepositoryException(sprintf('No default value for autocreated property "%s" at "%s"', $propertyDef->getName(), $node->getPath()));
}
}
$node->setProperty($propertyDef->getName(), $value, $propertyDef->getRequiredType());
}
} elseif ($propertyDef->isAutoCreated()) {
$prop = $node->getProperty($propertyDef->getName());
if (!$prop->isModified() && !$prop->isNew()) {
switch ($propertyDef->getName()) {
case 'jcr:lastModified':
if ($this->autoLastModified) {
$prop->setValue(new \DateTime());
}
break;
case 'jcr:lastModifiedBy':
if ($this->autoLastModified) {
$prop->setValue($this->userId);
}
break;
case 'jcr:etag':
// TODO: update etag if needed
break;
}
}
}
}
//.........这里部分代码省略.........
示例11: removeTranslation
/**
* {@inheritdoc}
*/
public function removeTranslation($document, NodeInterface $node, ClassMetadata $metadata, $locale)
{
foreach ($metadata->translatableFields as $field) {
$mapping = $metadata->mappings[$field];
$propName = $this->getTranslatedPropertyName($locale, $mapping['property']);
if ($node->hasProperty($propName)) {
$prop = $node->getProperty($propName);
$prop->remove();
$mapping = $metadata->mappings[$field];
if (true === $mapping['multivalue'] && isset($mapping['assoc'])) {
$transMapping = $this->getTranslatedPropertyNameAssoc($locale, $mapping);
$this->dm->getUnitOfWork()->removeAssoc($node, $transMapping);
}
}
}
if ($node->hasProperty($this->prefix . ':' . $locale . self::NULLFIELDS)) {
$node->setProperty($this->prefix . ':' . $locale . self::NULLFIELDS, null);
}
}
示例12: remove
/**
* {@inheritdoc}
*/
public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
{
foreach ($node->getProperties($property->getName() . '-*') as $nodeProperty) {
$node->getProperty($nodeProperty->getName())->remove();
}
}
示例13: remove
/**
* {@inheritdoc}
*/
public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
{
if ($node->hasProperty($property->getName())) {
$property = $node->getProperty($property->getName());
$property->remove();
}
}
示例14: remove
/**
* {@inheritdoc}
*/
public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey = null)
{
$this->strategy->deleteByPath($property->getValue(), $webspaceKey, $languageCode, $segmentKey);
if ($node->hasProperty($property->getName())) {
$node->getProperty($property->getName())->remove();
}
}
示例15: renderNodeProperty
/**
* Renders a property of a node
*
* @param \PHPCR\NodeInterface $node
* @param string $property
* @return string String representation of the property
*/
public function renderNodeProperty(NodeInterface $node, $property)
{
return $node->getProperty($property)->getString();
}