本文整理汇总了PHP中PHPCR\NodeInterface::setProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::setProperty方法的具体用法?PHP NodeInterface::setProperty怎么用?PHP NodeInterface::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeMetadata
/**
* {@inheritDoc}
*/
public function writeMetadata(DocumentManagerInterface $dm, NodeInterface $node, $className)
{
$className = $this->expandClassName($dm, $className);
if ('Doctrine\\ODM\\PHPCR\\Document\\Generic' !== $className) {
$node->setProperty('phpcr:class', $className, PropertyType::STRING);
$class = $dm->getClassMetadata($className);
$node->setProperty('phpcr:classparents', $class->getParentClasses(), PropertyType::STRING);
}
}
示例2: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$value = $property->getValue();
if ($value !== null && $value !== false && $value !== 'false' && $value !== '') {
$node->setProperty($property->getName(), true);
} else {
$node->setProperty($property->getName(), false);
}
}
示例3: testSaveWithoutData
public function testSaveWithoutData()
{
$content = [];
$this->node->setProperty(Argument::any(), Argument::any())->will(function ($arguments) use(&$content) {
$content[$arguments[0]] = $arguments[1];
});
$data = [];
$this->extension->setLanguageCode('de', 'i18n', null);
$this->extension->save($this->node->reveal(), $data, 'default', 'de');
$this->assertEquals(['i18n:de-seo-title' => '', 'i18n:de-seo-description' => '', 'i18n:de-seo-keywords' => '', 'i18n:de-seo-canonicalUrl' => '', 'i18n:de-seo-noIndex' => false, 'i18n:de-seo-noFollow' => false, 'i18n:de-seo-hideInSitemap' => false], $content);
}
示例4: fromJsonLD
protected function fromJsonLD(NodeInterface $node, array $data)
{
unset($data['@'], $data['a']);
foreach ($data as $key => $value) {
$node->setProperty($key, $value);
}
}
示例5: saveTranslation
/**
* {@inheritdoc}
*/
public function saveTranslation(array $data, NodeInterface $node, ClassMetadata $metadata, $locale)
{
$nullFields = array();
foreach ($data as $field => $propValue) {
$propName = $this->getTranslatedPropertyName($locale, $field);
$node->setProperty($propName, $propValue);
if (null === $propValue) {
$nullFields[] = $field;
}
}
if (empty($nullFields)) {
$nullFields = null;
}
$node->setProperty($this->prefix . ':' . $locale . self::NULLFIELDS, $nullFields);
// no '-' to avoid nameclashes
}
示例6: setProperty
/**
* {@inheritdoc}
*/
public function setProperty($name, $value, $type = PropertyType::UNDEFINED)
{
$oldValue = $this->getPropertyValueWithDefault($name, null);
if ($oldValue !== null && gettype($value) !== gettype($oldValue)) {
$this->node->getProperty($name)->remove();
}
return $this->node->setProperty($name, $value, $type);
}
示例7: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$value = $property->getValue();
if ($value !== null) {
$node->setProperty($property->getName(), $this->removeValidation($this->removeIllegalCharacters($value)));
} else {
$this->remove($node, $property, $webspaceKey, $languageCode, $segmentKey);
}
}
示例8: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$tagIds = [];
$tags = $property->getValue() === null ? [] : $property->getValue();
foreach ($tags as $tag) {
$tagIds[] = $this->tagManager->findOrCreateByName($tag, $userId)->getId();
}
$node->setProperty($property->getName(), $tagIds);
}
示例9: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$value = $property->getValue();
if ($value != null) {
$value = \DateTime::createFromFormat('Y-m-d', $value);
$node->setProperty($property->getName(), $value);
} else {
$this->remove($node, $property, $webspaceKey, $languageCode, $segmentKey);
}
}
示例10: processNode
/**
* Process - or update - a given node.
*
* Provides common processing for both touch and update commands.
*
* @param OutputInterface $output used for status updates.
* @param NodeInterface $node the node to manipulate.
* @param array $operations to execute on that node.
*/
public function processNode(OutputInterface $output, NodeInterface $node, array $operations)
{
$operations = array_merge(array('setProp' => array(), 'removeProp' => array(), 'addMixins' => array(), 'removeMixins' => array(), 'applyClosures' => array(), 'dump' => false), $operations);
foreach ($operations['setProp'] as $set) {
$parts = explode('=', $set);
$output->writeln(sprintf('<comment> > Setting property </comment>%s<comment> to </comment>%s', $parts[0], $parts[1]));
$node->setProperty($parts[0], $parts[1]);
}
foreach ($operations['removeProp'] as $unset) {
$output->writeln(sprintf('<comment> > Unsetting property </comment>%s', $unset));
$node->setProperty($unset, null);
}
foreach ($operations['addMixins'] as $addMixin) {
$output->writeln(sprintf('<comment> > Adding mixin </comment>%s', $addMixin));
$node->addMixin($addMixin);
}
foreach ($operations['removeMixins'] as $removeMixin) {
$output->writeln(sprintf('<comment> > Removing mixin </comment>%s', $removeMixin));
$node->removeMixin($removeMixin);
}
foreach ($operations['applyClosures'] as $closure) {
if ($closure instanceof \Closure) {
$output->writeln('<comment> > Applying closure</comment>');
} else {
$closureString = $closure;
$closure = create_function('$session, $node', $closure);
$output->writeln(sprintf('<comment> > Applying closure: %s</comment>', strlen($closureString) > 75 ? substr($closureString, 0, 72) . '...' : $closureString));
}
$closure($this->session, $node);
}
if ($operations['dump']) {
$output->writeln('<info>Node dump: </info>');
/** @var $property PropertyInterface */
foreach ($node->getProperties() as $property) {
$value = $property->getValue();
if (!is_string($value)) {
$value = print_r($value, true);
}
$output->writeln(sprintf('<comment> - %s = </comment>%s', $property->getName(), $value));
}
}
}
示例11: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$value = $property->getValue();
if ($value instanceof ArrayableInterface) {
$value = $value->toArray();
}
// if whole smart-content container is pushed
if (isset($value['data'])) {
unset($value['data']);
}
// set value to node
$node->setProperty($property->getName(), json_encode($value));
}
示例12: 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);
}
示例13: write
/**
* {@inheritdoc}
*/
public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
{
$categoryIds = [];
$value = $property->getValue();
if (null === $value) {
$node->setProperty($property->getName(), null);
return;
}
foreach ($value as $category) {
if (is_numeric($category)) {
// int value for id
$categoryIds[] = $category;
} else {
// full category object use only id to save
$categoryIds[] = $category['id'];
}
}
$node->setProperty($property->getName(), $categoryIds);
}
示例14: setMixins
/**
* Set the mapped mixins.
*
* @param ClassMetadata $metadata
* @param NodeInterface $node
* @param object $document The document to update autogenerated fields.
*/
private function setMixins(Mapping\ClassMetadata $metadata, NodeInterface $node, $document)
{
$repository = $this->session->getRepository();
if ($metadata->versionable === 'full') {
if ($repository->getDescriptor(RepositoryInterface::OPTION_VERSIONING_SUPPORTED)) {
$node->addMixin('mix:versionable');
} elseif ($repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)) {
$node->addMixin('mix:simpleVersionable');
}
} elseif ($metadata->versionable === 'simple' && $repository->getDescriptor(RepositoryInterface::OPTION_SIMPLE_VERSIONING_SUPPORTED)) {
$node->addMixin('mix:simpleVersionable');
}
if (!$node->isNodeType('mix:referenceable') && $metadata->referenceable) {
$node->addMixin('mix:referenceable');
}
// manually set the uuid if it is not present yet, so we can assign it to documents
if ($node->isNodeType('mix:referenceable') && !$node->hasProperty('jcr:uuid')) {
$uuid = false;
$uuidFieldName = $metadata->getUuidFieldName();
if ($uuidFieldName) {
$uuid = $metadata->getFieldValue($document, $uuidFieldName);
}
if (!$uuid) {
$uuid = $this->generateUuid();
}
$node->setProperty('jcr:uuid', $uuid);
if ($uuidFieldName && !$metadata->getFieldValue($document, $uuidFieldName)) {
$metadata->setFieldValue($document, $uuidFieldName, $uuid);
}
}
}
示例15: writeMetadata
/**
* Write any relevant meta data into the node to be able to map back to a class name later
*
* @param DocumentManager
* @param NodeInterface $node
* @param string $className
*/
public function writeMetadata(DocumentManager $dm, NodeInterface $node, $className)
{
$node->setProperty('phpcr:class', $className, PropertyType::STRING);
}