本文整理汇总了PHP中PHPCR\NodeInterface::getProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getProperties方法的具体用法?PHP NodeInterface::getProperties怎么用?PHP NodeInterface::getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::getProperties方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serializePhpcrNode
/**
* @param JsonSerializationVisitor $visitor
* @param NodeInterface $nodeInterface
* @param array $type
* @param Context $context
*/
public function serializePhpcrNode(JsonSerializationVisitor $visitor, NodeInterface $node, array $type, Context $context)
{
$res = array();
foreach ($node->getProperties() as $name => $property) {
$res[$name] = $property->getValue();
}
return $res;
}
示例2: upgradeNode
/**
* Removes non translated properties.
*
* @param NodeInterface $node
*/
private function upgradeNode(NodeInterface $node)
{
foreach ($node->getProperties('i18n:-*') as $property) {
$property->remove();
}
foreach ($node->getNodes() as $childNode) {
$this->upgradeNode($childNode);
}
}
示例3: testGetPropertiesNameGlobs
public function testGetPropertiesNameGlobs()
{
$iterator = $this->node->getProperties(array('jcr:cr*', 'jcr:prim*'));
$this->assertInstanceOf('Iterator', $iterator);
$props = array();
foreach ($iterator as $prop) {
array_push($props, $prop->getName());
}
$this->assertContains('jcr:created', $props);
$this->assertContains('jcr:primaryType', $props);
}
示例4: getLocalesFor
/**
* {@inheritdoc}
*/
public function getLocalesFor($document, NodeInterface $node, ClassMetadata $metadata)
{
$locales = array();
foreach ($node->getProperties("*{$this->prefix}*") as $prop) {
$matches = null;
if (preg_match('/' . $this->prefix . ':(..)-[^-]*/', $prop->getName(), $matches)) {
if (is_array($matches) && count($matches) > 1 && !in_array($matches[1], $locales)) {
$locales[] = $matches[1];
}
}
}
return $locales;
}
示例5: it_can_normalize_a_node_to_an_array
public function it_can_normalize_a_node_to_an_array(NodeInterface $node, PropertyInterface $p1, PropertyInterface $p2, PropertyInterface $p3)
{
$node->getProperties()->willReturn([$p1, $p2, $p3]);
$p1->getName()->willReturn('my:property.1');
$p1->getType()->willReturn(PropertyType::STRING);
$p1->getValue()->willReturn('P1 Val');
$p2->getName()->willReturn('my:property.2');
$p2->getType()->willReturn(PropertyType::DOUBLE);
$p2->getValue()->willReturn('P2 Val');
$p3->getName()->willReturn('my:property.3');
$p3->getType()->willReturn(PropertyType::STRING);
$p3->getValue()->willReturn('P3 Val');
$this->normalize($node)->shouldReturn(['my:property.1' => ['type' => 'String', 'value' => 'P1 Val'], 'my:property.2' => ['type' => 'Double', 'value' => 'P2 Val'], 'my:property.3' => ['type' => 'String', 'value' => 'P3 Val']]);
}
示例6: traverse
private function traverse(NodeInterface $node, $readProperties = false)
{
if ($readProperties) {
foreach ($node->getProperties() as $property) {
try {
$property->getValue();
} catch (\PHPCR\RepositoryException $e) {
}
}
}
foreach ($node->getNodes() as $child) {
$this->traverse($child, $readProperties);
}
}
示例7: setNodeWorkflowStageToTestForCopy
/**
* Sets the workflowstage and the published date for the given node and all of its children to test resp. null. This
* is done for every language in which the given properties exist.
*
* @param NodeInterface $node
*/
private function setNodeWorkflowStageToTestForCopy(NodeInterface $node)
{
$workflowStageNameFilter = $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, '*');
foreach ($node->getProperties($workflowStageNameFilter) as $property) {
/** @var PropertyInterface $property */
$property->setValue(WorkflowStage::TEST);
}
$publishedNameFilter = $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, '*');
foreach ($node->getProperties($publishedNameFilter) as $property) {
/** @var PropertyInterface $property */
$property->setValue(null);
}
foreach ($node->getNodes() as $node) {
/** @var NodeInterface $node */
$this->setNodeWorkflowStageToTestForCopy($node);
}
}
示例8: remove
/**
* {@inheritdoc}
*/
public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
{
foreach ($node->getProperties($property->getName() . '-*') as $nodeProperty) {
$node->getProperty($nodeProperty->getName())->remove();
}
}
示例9: getLocalizedPropertyValues
/**
* Return all the localized values of the localized property indicated
* by $name.
*
* @param NodeInterface $node
* @param string $name Name of localized property
*/
public function getLocalizedPropertyValues(NodeInterface $node, $name)
{
$values = [];
foreach ($node->getProperties() as $property) {
/* @var PropertyInterface $property */
preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-' . $name . '/', $property->getName(), $matches);
if ($matches) {
$values[$matches[1]] = $property->getValue();
}
}
return $values;
}
示例10: exportDocumentViewRecursive
/**
* Recursively output node and all its children into the file in the
* document view format
*
* @param NodeInterface $node the node to output
* @param NamespaceRegistryInterface $ns The namespace registry to export namespaces too
* @param resource $stream the resource to write data out to
* @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 exportDocumentViewRecursive(NodeInterface $node, NamespaceRegistryInterface $ns, $stream, $skipBinary, $noRecurse, $root = false)
{
$nodename = self::escapeXmlName($node->getName());
fwrite($stream, "<{$nodename}");
if ($root) {
self::exportNamespaceDeclarations($ns, $stream);
}
foreach ($node->getProperties() as $name => $property) {
/** @var $property \PHPCR\PropertyInterface */
if ($property->isMultiple()) {
// skip multiple properties. jackrabbit does this too. cheap but whatever. use system view for a complete export
continue;
}
if (PropertyType::BINARY == $property->getType()) {
if ($skipBinary) {
continue;
}
$value = base64_encode($property->getString());
} else {
$value = htmlspecialchars($property->getString());
}
fwrite($stream, ' ' . self::escapeXmlName($name) . '="' . $value . '"');
}
if ($noRecurse || !$node->hasNodes()) {
fwrite($stream, '/>');
} else {
fwrite($stream, '>');
foreach ($node as $child) {
if (!($child->getDepth() == 1 && NodeHelper::isSystemItem($child))) {
self::exportDocumentViewRecursive($child, $ns, $stream, $skipBinary, $noRecurse);
}
}
fwrite($stream, "</{$nodename}>");
}
}
示例11: removeLocalizedNodeProperties
/**
* Removes all localized properties in the given locale from the given node.
*
* @param NodeInterface $node
* @param string $locale
*/
private function removeLocalizedNodeProperties(NodeInterface $node, $locale)
{
// remove all localized system properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) {
$property->remove();
}
// remove all localized content properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) {
$property->remove();
}
}
示例12: getProperties
/**
* {@inheritdoc}
*/
public function getProperties($nameFilter = null)
{
return $this->node->getProperties($nameFilter);
}
示例13: parsePhpcrNode
private function parsePhpcrNode(NodeInterface $node)
{
$this->parsePhpcrNodeProperties($node->getProperties());
}
示例14: formatNodePropertiesInline
public function formatNodePropertiesInline(NodeInterface $node)
{
$out = array();
foreach ($node->getProperties() as $property) {
$out[] = sprintf('%s: %s', $property->getName(), $this->formatValue($property));
}
return implode(', ', $out);
}