本文整理汇总了PHP中PHPCR\SessionInterface::save方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::save方法的具体用法?PHP SessionInterface::save怎么用?PHP SessionInterface::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\SessionInterface
的用法示例。
在下文中一共展示了SessionInterface::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$webspaceKey = $input->getArgument('webspaceKey');
$locale = $input->getArgument('locale');
$basePath = $input->getOption('base-path');
$dryRun = $input->getOption('dry-run');
$this->session = $this->getContainer()->get('doctrine_phpcr')->getManager()->getPhpcrSession();
$this->sessionManager = $this->getContainer()->get('sulu.phpcr.session');
$this->output = $output;
$path = $this->sessionManager->getRoutePath($webspaceKey, $locale);
$relativePath = $basePath !== null ? '/' . ltrim($basePath, '/') : '/';
$fullPath = rtrim($path . $relativePath, '/');
if (!$this->session->nodeExists($fullPath)) {
$this->output->write('<error>Resource-Locator "' . $relativePath . '" not found</error>');
return;
}
$node = $this->session->getNode($fullPath);
$this->cleanup($node, $path, $dryRun);
if (false === $dryRun) {
$this->output->writeln('<info>Saving ...</info>');
$this->session->save();
$this->output->writeln('<info>Done</info>');
} else {
$this->output->writeln('<info>Dry run complete</info>');
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var Webspace $webspace */
foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
$this->upgradeWebspace($webspace, $output);
}
$this->liveSession->save();
}
示例3: handleSession
private function handleSession(SessionInterface $session, $fileName)
{
if ($session->getRootNode()->hasNode('cmf')) {
$session->getNode('/cmf')->remove();
$session->save();
}
$session->importXML('/', $fileName, ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
$session->save();
}
示例4: testRemove
public function testRemove()
{
$this->property->expects($this->any())->method('getName')->will($this->returnValue('i18n:de-hotels'));
$pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
$this->contentType->remove($pageNode, $this->property, 'sulu_io', 'de', null);
$this->session->save();
$this->assertFalse($pageNode->hasProperty('i18n:de-hotels'));
}
示例5: removeTestNode
protected function removeTestNode()
{
$root = $this->session->getRootNode();
if ($root->hasNode($this->testNodeName)) {
$root->getNode($this->testNodeName)->remove();
$this->session->save();
}
}
示例6: testDelete
public function testDelete()
{
$structure = $this->prepareHistoryTestData();
$this->repository->delete('/test', 'sulu_io', 'en');
$this->session->save();
$result = $this->repository->getHistory($structure->getUuid(), 'sulu_io', 'en');
$this->assertEquals(1, count($result['_embedded']['resourcelocators']));
$this->assertEquals('/test-1', $result['_embedded']['resourcelocators'][0]['resourceLocator']);
}
示例7: removeTestNode
/**
* Remove a PHPCR node under the root node
*
* @param string $name The name of the node to remove
*
* @return void
*/
protected function removeTestNode($name)
{
$root = $this->session->getNode('/');
if ($root->hasNode($name)) {
$root->getNode($name)->remove();
$this->session->save();
$this->dm->clear();
}
}
示例8: execute
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$webspaceKey = $input->getArgument('webspaceKey');
$locale = $input->getArgument('locale');
$basePath = $input->getOption('base-path');
$dryRun = $input->getOption('dry-run');
$path = $this->sessionManager->getRoutePath($webspaceKey, $locale);
$relativePath = $basePath !== null ? '/' . ltrim($basePath, '/') : '/';
$fullPath = rtrim($path . $relativePath, '/');
$this->cleanSession($output, $this->defaultSession, $fullPath, $dryRun);
$this->cleanSession($output, $this->liveSession, $fullPath, $dryRun);
if (false === $dryRun) {
$this->defaultSession->save();
$this->liveSession->save();
$output->writeln('<info>Save complete</info>');
} else {
$output->writeln('<info>Dry run complete</info>');
}
}
示例9: testFindByUUID
public function testFindByUUID()
{
$this->doc->topic = 'Un autre sujet';
$this->doc->locale = 'fr';
$this->dm->persist($this->doc);
$this->dm->flush();
$node = $this->session->getNode('/functional/' . $this->testNodeName);
$node->addMixin('mix:referenceable');
$this->session->save();
$this->document = $this->dm->findTranslation($this->class, $node->getIdentifier(), 'fr');
$this->assertInstanceOf($this->class, $this->document);
}
示例10: build
/**
* {@inheritdoc}
*/
public function build()
{
foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
$contentPath = $this->sessionManager->getContentPath($webspace->getKey());
$this->context->getOutput()->writeln('Default workspace');
$this->traverse($this->defaultSession->getNode($contentPath));
$this->context->getOutput()->writeln('');
$this->context->getOutput()->writeln('Live workspace');
$this->traverse($this->liveSession->getNode($contentPath));
}
$this->defaultSession->save();
$this->liveSession->save();
}
示例11: testFindWithInternalLinkToItself
public function testFindWithInternalLinkToItself()
{
$this->initPhpcr();
$link = $this->createPage('test-1', 'de');
$page = $this->createInternalLinkPage('test-2', 'de', $link);
$node = $this->session->getNodeByIdentifier($page->getUuid());
$node->setProperty('i18n:de-internal_link', $node);
$this->session->save();
// should load content with requested node and not try to follow internal link
$result = $this->contentRepository->find($page->getUuid(), 'de', 'sulu_io', MappingBuilder::create()->addProperties(['title'])->getMapping());
$this->assertEquals($page->getUuid(), $result->getId());
$this->assertEquals('/test-2', $result->getPath());
$this->assertEquals('test-2', $result['title']);
}
示例12: migrateHome
private function migrateHome(SessionInterface $session, $from, $to, $referenceWebspace)
{
$webspaceManager = $this->container->get('sulu_core.webspace.webspace_manager');
$pathRegistry = $this->container->get('sulu_document_manager.path_segment_registry');
$webspaces = $webspaceManager->getWebspaceCollection();
foreach ($webspaces as $webspace) {
$webspacePath = sprintf('/%s/%s', $pathRegistry->getPathSegment('base'), $webspace->getKey());
$homeNodeName = $pathRegistry->getPathSegment('content');
$webspace = $session->getNode($webspacePath);
if ($referenceWebspace) {
$webspace->addMixin('mix:referenceable');
} else {
$webspace->removeMixin('mix:referenceable');
}
$homeNode = $webspace->getNode($homeNodeName);
$tmpNode = $session->getRootNode()->addNode('/tmp');
$tmpNode->addMixin('mix:referenceable');
$session->save();
$homeNodeReferences = $homeNode->getReferences();
$homeNodeReferenceValues = [];
foreach ($homeNodeReferences as $homeNodeReference) {
/* @var Property $homeNodeReference */
$homeNodeReferenceValues[$homeNodeReference->getPath()] = $homeNodeReference->getValue();
$homeNodeReference->setValue($tmpNode);
}
$session->save();
$homeNode->removeMixin($from);
$session->save();
$homeNode->addMixin($to);
$session->save();
foreach ($homeNodeReferences as $homeNodeReference) {
$homeNodeReference->setValue($homeNodeReferenceValues[$homeNodeReference->getPath()], PropertyType::REFERENCE);
}
$session->save();
$tmpNode->remove();
}
}
示例13: iterateStructures
/**
* Structures are updated according to their xml definition.
*
* @param bool $up Indicates that this is up or down
*/
private function iterateStructures($up)
{
$properties = [];
// find templates containing date fields
$structureMetadatas = array_merge($this->structureMetadataFactory->getStructures('page'), $this->structureMetadataFactory->getStructures('snippet'));
$structureMetadatas = array_filter($structureMetadatas, function (StructureMetadata $structureMetadata) use(&$properties) {
$structureName = $structureMetadata->getName();
$this->findDateProperties($structureMetadata, $properties);
return !empty($properties[$structureName]) || !empty($blockProperties[$structureName]);
});
foreach ($structureMetadatas as $structureMetadata) {
$this->iterateStructureNodes($structureMetadata, $properties[$structureMetadata->getName()], $up);
}
$this->session->save();
}
示例14: testOverride
public function testOverride()
{
$property = new Property('url', [], 'resource_locator');
$property->setValue('/test');
$node = $this->sessionManager->getContentNode('sulu_io')->addNode('test');
$node->addMixin('sulu:content');
$this->session->save();
$this->resourceLocator->write($node, $property, 1, 'sulu_io', 'en');
$this->assertEquals('/test', $node->getPropertyValue('url'));
$this->assertTrue($this->session->getRootNode()->hasNode('cmf/sulu_io/routes/en/test'));
$property->setValue('/test-2');
$this->resourceLocator->write($node, $property, 1, 'sulu_io', 'en');
$this->assertEquals('/test-2', $node->getPropertyValue('url'));
$this->assertTrue($this->session->getRootNode()->hasNode('cmf/sulu_io/routes/en/test-2'));
}
示例15: reorderNode
/**
* {@inheritdoc}
*/
public function reorderNode($sourcePath, $position)
{
$node = $this->getNode($sourcePath);
$parent = $node->getParent();
$nodeNames = $parent->getNodeNames();
if ($position == 0) {
$parent->orderBefore($node->getName(), $nodeNames[$position]);
} elseif (isset($nodeNames[$position + 1])) {
$parent->orderBefore($node->getName(), $nodeNames[$position + 1]);
} else {
$lastName = $nodeNames[count($nodeNames) - 1];
$parent->orderBefore($node->getName(), $lastName);
$parent->orderBefore($lastName, $node->getName());
}
$this->session->save();
}