本文整理汇总了PHP中PHPCR\NodeInterface::addMixin方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::addMixin方法的具体用法?PHP NodeInterface::addMixin怎么用?PHP NodeInterface::addMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::addMixin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareTestData
private function prepareTestData()
{
$products = $this->session->getNode('/cmf/sulu_io/routes/de')->addNode('products');
$products->addMixin('mix:referenceable');
$machines = $products->addNode('machines');
$machines->addMixin('mix:referenceable');
$machines1 = $products->addNode('machines-1');
$machines1->addMixin('mix:referenceable');
$drill = $machines->addNode('drill');
$drill->addMixin('mix:referenceable');
$drill1 = $machines->addNode('drill-1');
$drill1->addMixin('mix:referenceable');
$contents = $this->session->getNode('/cmf/sulu_io/contents');
$this->content1 = $contents->addNode('content1');
$this->content1->addMixin('mix:referenceable');
$this->content2 = $contents->addNode('content2');
$this->content2->addMixin('mix:referenceable');
$this->session->save();
}
示例2: 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));
}
}
}
示例3: 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);
}
}
}
示例4: addMixin
/**
* {@inheritdoc}
*/
public function addMixin($mixinName)
{
return $this->node->addMixin($mixinName);
}
示例5: setMixins
private function setMixins(Mapping\ClassMetadata $metadata, NodeInterface $node)
{
if ($metadata->versionable === 'full') {
$node->addMixin('mix:versionable');
} else {
if ($metadata->versionable === 'simple') {
$node->addMixin('mix:simpleVersionable');
}
if ($metadata->referenceable) {
$node->addMixin('mix:referenceable');
}
}
// we manually set the uuid to allow creating referenced and referencing document without flush in between.
if ($node->isNodeType('mix:referenceable') && !$node->hasProperty('jcr:uuid')) {
// TODO do we need to check with the storage backend if the generated id really is unique?
$node->setProperty('jcr:uuid', UUIDHelper::generateUUID());
}
}