当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::hasProperty方法代码示例

本文整理汇总了PHP中PHPCR\NodeInterface::hasProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::hasProperty方法的具体用法?PHP NodeInterface::hasProperty怎么用?PHP NodeInterface::hasProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPCR\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::hasProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHasValue

 public function testHasValue()
 {
     $type = new ContactSelectionContentType($this->template, $this->contactManager->reveal(), $this->accountManager->reveal(), $this->serializer->reveal(), new CustomerIdConverter(), new IndexComparator());
     $this->property->getName()->willReturn('test');
     $this->node->hasProperty('test')->willReturn(true);
     $this->assertTrue($type->hasValue($this->node->reveal(), $this->property->reveal(), $this->webspaceKey, $this->locale, $this->segmentKey));
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:7,代码来源:ContactSelectionContentTypeTest.php

示例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();
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:10,代码来源:SimpleContentType.php

示例3: 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;
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:22,代码来源:DocumentClassMapper.php

示例4: read

 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = '';
     if ($node->hasProperty($property->getName())) {
         /** @var \DateTime $propertyValue */
         $propertyValue = $node->getPropertyValue($property->getName());
         $value = $propertyValue->format('Y-m-d');
     }
     $property->setValue($value);
     return $value;
 }
开发者ID:ollietb,项目名称:sulu,代码行数:14,代码来源:Date.php

示例5: loadTranslation

 /**
  * {@inheritdoc}
  */
 public function loadTranslation($document, NodeInterface $node, ClassMetadata $metadata, $locale)
 {
     if ($node->hasProperty($this->prefix . ':' . $locale . self::NULLFIELDS)) {
         $nullFields = $node->getPropertyValue($this->prefix . ':' . $locale . self::NULLFIELDS);
         $nullFields = array_flip($nullFields);
     } else {
         $nullFields = array();
     }
     foreach ($metadata->translatableFields as $field) {
         $propName = $this->getTranslatedPropertyName($locale, $field);
         if (isset($nullFields[$field])) {
             $value = null;
         } elseif ($node->hasProperty($propName)) {
             $value = $node->getPropertyValue($propName);
         } else {
             // Could not find the translation in the given language
             return false;
         }
         $metadata->reflFields[$field]->setValue($document, $value);
     }
     return true;
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:25,代码来源:AttributeTranslationStrategy.php

示例6: resolveMetadataForNode

 /**
  * {@inheritdoc}
  */
 public function resolveMetadataForNode(NodeInterface $node)
 {
     if (false === $node->hasProperty('jcr:mixinTypes')) {
         return;
     }
     $mixinTypes = (array) $node->getPropertyValue('jcr:mixinTypes');
     foreach ($mixinTypes as $mixinType) {
         if (true == $this->metadataFactory->hasMetadataForPhpcrType($mixinType)) {
             return $this->metadataFactory->getMetadataForPhpcrType($mixinType);
         }
     }
     return;
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:16,代码来源:MixinStrategy.php

示例7: read

 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $this->defaultValue;
     if ($node->hasProperty($property->getName())) {
         $value = $node->getPropertyValue($property->getName());
     }
     // the RedirectType subscriber sets the internal link as a reference
     if ($value instanceof NodeInterface) {
         $value = $value->getIdentifier();
     }
     $property->setValue($value);
     return $value;
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:16,代码来源:SingleInternalLink.php

示例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;
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:19,代码来源:DocumentClassMapper.php

示例9: 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;
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:jackalope,项目名称:jackalope,代码行数:101,代码来源:NodeProcessor.php

示例10: 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);
     }
 }
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:22,代码来源:AttributeTranslationStrategy.php

示例11: remove

 /**
  * {@inheritdoc}
  */
 public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     if ($node->hasProperty($property->getName())) {
         $property = $node->getProperty($property->getName());
         $property->remove();
     }
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:10,代码来源:CategoryList.php

示例12: exportSystemViewRecursive

 /**
  * Recursively output node and all its children into the file in the system
  * view format
  *
  * @param NodeInterface $node   the node to output
  * @param resource      $stream The stream resource (i.e. acquired with fopen) to
  *      which the XML serialization of the subgraph will be output. Must
  *      support the fwrite method.
  * @param boolean $skipBinary A boolean governing whether binary properties
  *      are to be serialized.
  * @param boolean $noRecurse A boolean governing whether the subgraph at
  *      absPath is to be recursed.
  * @param boolean $root Whether this is the root node of the resulting
  *      document, meaning the namespace declarations have to be included in
  *      it.
  */
 private static function exportSystemViewRecursive(NodeInterface $node, NamespaceRegistryInterface $ns, $stream, $skipBinary, $noRecurse, $root = false)
 {
     fwrite($stream, '<sv:node');
     if ($root) {
         self::exportNamespaceDeclarations($ns, $stream);
     }
     fwrite($stream, ' sv:name="' . (0 === $node->getDepth() ? 'jcr:root' : htmlspecialchars($node->getName())) . '">');
     // the order MUST be primary type, then mixins, if any, then jcr:uuid if its a referenceable node
     fwrite($stream, '<sv:property sv:name="jcr:primaryType" sv:type="Name"><sv:value>' . htmlspecialchars($node->getPropertyValue('jcr:primaryType')) . '</sv:value></sv:property>');
     if ($node->hasProperty('jcr:mixinTypes')) {
         fwrite($stream, '<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">');
         foreach ($node->getPropertyValue('jcr:mixinTypes') as $type) {
             fwrite($stream, '<sv:value>' . htmlspecialchars($type) . '</sv:value>');
         }
         fwrite($stream, '</sv:property>');
     }
     if ($node->isNodeType('mix:referenceable')) {
         fwrite($stream, '<sv:property sv:name="jcr:uuid" sv:type="String"><sv:value>' . $node->getIdentifier() . '</sv:value></sv:property>');
     }
     foreach ($node->getProperties() as $name => $property) {
         /** @var $property \PHPCR\PropertyInterface */
         if ($name == 'jcr:primaryType' || $name == 'jcr:mixinTypes' || $name == 'jcr:uuid') {
             // explicitly handled before
             continue;
         }
         if (PropertyType::BINARY == $property->getType() && $skipBinary) {
             // do not output binary data in the xml
             continue;
         }
         fwrite($stream, '<sv:property sv:name="' . htmlentities($name) . '" sv:type="' . PropertyType::nameFromValue($property->getType()) . '"' . ($property->isMultiple() ? ' sv:multiple="true"' : '') . '>');
         $values = $property->isMultiple() ? $property->getString() : array($property->getString());
         foreach ($values as $value) {
             if (PropertyType::BINARY == $property->getType()) {
                 $val = base64_encode($value);
             } else {
                 $val = htmlspecialchars($value);
                 //TODO: can we still have invalid characters after this? if so base64 and property, xsi:type="xsd:base64Binary"
             }
             fwrite($stream, "<sv:value>{$val}</sv:value>");
         }
         fwrite($stream, "</sv:property>");
     }
     if (!$noRecurse) {
         foreach ($node as $child) {
             if (!($child->getDepth() == 1 && NodeHelper::isSystemItem($child))) {
                 self::exportSystemViewRecursive($child, $ns, $stream, $skipBinary, $noRecurse);
             }
         }
     }
     fwrite($stream, '</sv:node>');
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:67,代码来源:ImportExport.php

示例13: upgradeNode

 private function upgradeNode(NodeInterface $node, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0)
 {
     $locale = $localization->getLocale();
     $localizedTemplatePropertyName = $this->propertyEncoder->localizedSystemName('template', $locale);
     if (!$node->hasProperty($localizedTemplatePropertyName)) {
         return;
     }
     $structureMetadata = $this->structureMetadataFactory->getStructureMetadata($this->metadataFactory->getMetadataForPhpcrNode($node)->getAlias(), $node->getPropertyValue($localizedTemplatePropertyName));
     $property = $structureMetadata->getPropertyByTagName('sulu.rlp');
     if (!$property) {
         return;
     }
     $nodeType = $node->getPropertyValue($this->propertyEncoder->localizedSystemName('nodeType', $locale));
     if ($property->getContentTypeName() !== 'resource_locator' && $nodeType !== Structure::NODE_TYPE_CONTENT) {
         return;
     }
     $baseRoutePath = $this->sessionManager->getRoutePath($webspace->getKey(), $localization->getLocale());
     foreach ($node->getReferences('sulu:content') as $routeProperty) {
         if (strpos($routeProperty->getPath(), $baseRoutePath) !== 0) {
             continue;
         }
         $routeNode = $routeProperty->getParent();
         if ($routeNode->getPropertyValue('sulu:history') === true) {
             continue;
         }
         $resourceLocator = substr($routeNode->getPath(), strlen($baseRoutePath));
         if ($resourceLocator) {
             // only set if resource locator is not empty
             // if the resource locator is empty it is the homepage, whose url should not be changed
             $node->setProperty($this->propertyEncoder->localizedContentName($property->getName(), $locale), $resourceLocator);
             $prefix = '   ';
             for ($i = 0; $i < $depth; ++$i) {
                 $prefix .= '-';
             }
             $title = $node->getPropertyValue($this->propertyEncoder->localizedContentName('title', $locale));
             $output->writeln($prefix . '> "' . $title . '": ' . $resourceLocator);
         }
         break;
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:40,代码来源:MaintainResourceLocatorCommand.php

示例14: upgradeProperty

 /**
  * Upgrades the given property to the new date representation.
  *
  * @param PropertyMetadata $property
  * @param NodeInterface $node
  * @param bool $up
  */
 private function upgradeProperty(PropertyMetadata $property, NodeInterface $node, $locale, $up)
 {
     $name = sprintf('i18n:%s-%s', $locale, $property->getName());
     if (!$node->hasProperty($name)) {
         return;
     }
     $value = $node->getPropertyValue($name);
     if ($up) {
         $value = $this->upgradeDate($value);
     } else {
         $value = $this->downgradeDate($value);
     }
     $node->setProperty($name, $value);
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:21,代码来源:Version201511240843.php

示例15: 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();
     }
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:10,代码来源:ResourceLocator.php


注:本文中的PHPCR\NodeInterface::hasProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。