本文整理汇总了PHP中PHPCR\SessionInterface::getWorkspace方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::getWorkspace方法的具体用法?PHP SessionInterface::getWorkspace怎么用?PHP SessionInterface::getWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\SessionInterface
的用法示例。
在下文中一共展示了SessionInterface::getWorkspace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->renewSession();
// reset session
parent::setUp();
$this->workspace = $this->session->getWorkspace();
}
示例2: move
/**
* @param string $moved_path
* @param string $target_path
*
* @return array
*/
public function move($moved_path, $target_path)
{
$resulting_path = $target_path . '/' . PathHelper::getNodeName($moved_path);
$workspace = $this->session->getWorkspace();
$workspace->move($moved_path, $target_path . '/' . PathHelper::getNodeName($moved_path));
return array('id' => $resulting_path, 'url_safe_id' => ltrim($resulting_path, '/'));
}
示例3: __construct
public function __construct(SessionManagerInterface $sessionManager, PropertyEncoder $propertyEncoder, WebspaceManagerInterface $webspaceManager, LocalizationFinderInterface $localizationFinder, SuluNodeHelper $nodeHelper)
{
$this->sessionManager = $sessionManager;
$this->propertyEncoder = $propertyEncoder;
$this->webspaceManager = $webspaceManager;
$this->localizationFinder = $localizationFinder;
$this->nodeHelper = $nodeHelper;
$this->session = $sessionManager->getSession();
$this->qomFactory = $this->session->getWorkspace()->getQueryManager()->getQOMFactory();
}
示例4: setUp
public function setUp()
{
$this->session = $this->prophesize(SessionInterface::class);
$this->workspace = $this->prophesize(WorkspaceInterface::class);
$this->queryManager = $this->prophesize(QueryManagerInterface::class);
$this->dispatcher = $this->prophesize(EventDispatcherInterface::class);
$this->phpcrQuery = $this->prophesize(QueryInterface::class);
$this->phpcrResult = $this->prophesize(QueryResultInterface::class);
$this->queryCreateEvent = $this->prophesize(QueryCreateEvent::class);
$this->queryExecuteEvent = $this->prophesize(QueryExecuteEvent::class);
$this->query = $this->prophesize(Query::class);
$this->subscriber = new QuerySubscriber($this->session->reveal(), $this->dispatcher->reveal());
$this->session->getWorkspace()->willReturn($this->workspace->reveal());
$this->workspace->getQueryManager()->willReturn($this->queryManager->reveal());
}
示例5: up
public function up(SessionInterface $session)
{
$workspace = $session->getWorkspace();
$nodeTypeManager = $workspace->getNodeTypeManager();
$nodeTypeManager->registerNodeType(new HomeNodeType(), true);
$this->migrateHome($session, 'sulu:page', 'sulu:home', true);
}
示例6: transactional
/**
* {@inheritDoc}
*/
public function transactional($callback)
{
if (!is_callable($callback)) {
throw new InvalidArgumentException(sprintf('Parameter $callback must be a valid callable, "%s" given', gettype($callback)));
}
$transactionManager = null;
try {
$transactionManager = $this->session->getWorkspace()->getTransactionManager();
} catch (UnsupportedRepositoryOperationException $e) {
$result = call_user_func($callback, $this);
$this->flush();
return $result;
}
$transactionManager->begin();
try {
$result = call_user_func($callback, $this);
$this->flush();
} catch (\Exception $exception) {
$this->close();
$transactionManager->rollback();
throw $exception;
}
$transactionManager->commit();
return $result;
}
示例7: migrateExternalLinks
private function migrateExternalLinks(SessionInterface $session, $directionUp = true)
{
$workspace = $session->getWorkspace();
$queryManager = $workspace->getQueryManager();
$webspaceManager = $this->container->get('sulu_core.webspace.webspace_manager');
$propertyEncoder = $this->container->get('sulu_document_manager.property_encoder');
$webspaces = $webspaceManager->getWebspaceCollection();
/** @var Webspace $webspace */
foreach ($webspaces as $webspace) {
foreach ($webspace->getAllLocalizations() as $localization) {
$locale = $localization->getLocalization();
$query = $queryManager->createQuery(sprintf('SELECT * FROM [nt:base] WHERE [%s] = 4 AND [jcr:mixinTypes] = "sulu:page"', $propertyEncoder->localizedSystemName('nodeType', $locale)), 'JCR-SQL2');
$rows = $query->execute();
foreach ($rows as $row) {
/** @var NodeInterface $node */
$node = $row->getNode();
$templatePropertyName = $propertyEncoder->localizedSystemName('template', $locale);
try {
if (true === $directionUp) {
$node->setProperty($templatePropertyName, $webspace->getDefaultTemplate('page'));
} else {
$node->setProperty($templatePropertyName, 'external-link');
}
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
}
}
}
}
示例8: iterateStructureNodes
/**
* Iterates over all nodes of the given type, and upgrades them.
*
* @param StructureMetadata $structureMetadata The structure metadata, whose pages have to be upgraded
* @param array $properties The properties which are or contain URL fields
* @param bool $addScheme Adds the scheme to URLs if true, removes the scheme otherwise
*/
private function iterateStructureNodes(StructureMetadata $structureMetadata, array $properties, $addScheme)
{
foreach ($this->localizationManager->getLocalizations() as $localization) {
$rows = $this->session->getWorkspace()->getQueryManager()->createQuery(sprintf('SELECT * FROM [nt:unstructured] WHERE [%s] = "%s" OR [%s] = "%s"', $this->propertyEncoder->localizedSystemName('template', $localization->getLocalization()), $structureMetadata->getName(), 'template', $structureMetadata->getName()), 'JCR-SQL2')->execute();
foreach ($rows->getNodes() as $node) {
$this->upgradeNode($node, $localization->getLocalization(), $properties, $addScheme);
}
}
}
示例9: copy
/**
* Copy the document with the given path or ID to the path
* of the destination document (as a child).
*
* @param string $srcId
* @param string $destId
* @param string $name
*
* @return string
*/
public function copy($srcId, $destId, $name)
{
$workspace = $this->session->getWorkspace();
$srcPath = $this->normalizeToPath($srcId);
$parentDestPath = $this->normalizeToPath($destId);
$destPath = $parentDestPath . '/' . $name;
$workspace->copy($srcPath, $destPath);
return $destPath;
}
示例10: registerNodeTypes
/**
* Register the system node types on the given session.
*
* @param SessionInterface
*/
public function registerNodeTypes(SessionInterface $session)
{
$cnd = <<<CND
// register phpcr_locale namespace
<{$this->localeNamespace}='{$this->localeNamespaceUri}'>
// register phpcr namespace
<{$this->phpcrNamespace}='{$this->phpcrNamespaceUri}'>
[phpcr:managed]
mixin
- phpcr:class (STRING)
- phpcr:classparents (STRING) multiple
CND;
$nodeTypeManager = $session->getWorkspace()->getNodeTypeManager();
$nodeTypeManager->registerNodeTypesCnd($cnd, true);
}
示例11: registerNodeTypesCnd
/**
* Register node types with compact node definition format
*
* This is only a proxy to the transport
*
* @param string $cnd a string with cnd information
* @param boolean $allowUpdate whether to fail if node already exists or to update it
* @return bool true on success
*/
public function registerNodeTypesCnd($cnd, $allowUpdate)
{
if ($this->transport instanceof NodeTypeCndManagementInterface) {
return $this->transport->registerNodeTypesCnd($cnd, $allowUpdate);
}
if ($this->transport instanceof NodeTypeManagementInterface) {
$workspace = $this->session->getWorkspace();
$nsRegistry = $workspace->getNamespaceRegistry();
$parser = new CndParser($workspace->getNodeTypeManager());
$res = $parser->parseString($cnd);
$ns = $res['namespaces'];
$types = $res['nodeTypes'];
foreach ($ns as $prefix => $uri) {
$nsRegistry->registerNamespace($prefix, $uri);
}
return $workspace->getNodeTypeManager()->registerNodeTypes($types, $allowUpdate);
}
throw new UnsupportedRepositoryOperationException('Transport does not support registering node types');
}
示例12: migrateInternalLinks
private function migrateInternalLinks(SessionInterface $session, $directionUp = true)
{
$workspace = $session->getWorkspace();
$queryManager = $workspace->getQueryManager();
$webspaceManager = $this->container->get('sulu_core.webspace.webspace_manager');
$propertyEncoder = $this->container->get('sulu_document_manager.property_encoder');
$webspaces = $webspaceManager->getWebspaceCollection();
foreach ($webspaces as $webspace) {
foreach ($webspace->getAllLocalizations() as $localization) {
$locale = $localization->getLocalization();
$sql = <<<EOT
SELECT * FROM [nt:unstructured] WHERE %s = 2
EOT;
$query = $queryManager->createQuery(sprintf($sql, '[' . $propertyEncoder->localizedSystemName('nodeType', $locale) . ']'), 'JCR-SQL2');
$rows = $query->execute();
foreach ($rows as $row) {
$node = $row->getNode();
$internalLinkName = $propertyEncoder->localizedSystemName('internal_link', $locale);
try {
if (true === $directionUp) {
$internalUuid = $node->getPropertyValue($internalLinkName);
$internalNode = $session->getNodeByIdentifier($internalUuid);
$node->setProperty($internalLinkName, null);
$node->setProperty($internalLinkName, $internalNode);
} else {
$internalNode = $node->getPropertyValue($internalLinkName);
$internalNodeUuid = $internalNode->getIdentifier();
$node->setProperty($internalLinkName, null);
$node->setProperty($internalLinkName, $internalNodeUuid);
}
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
}
}
}
}
示例13: createQueryBuilder
/**
* Create the fluent query builder.
*
* After building your query, use DocumentManager::getDocumentsByQuery with the
* query returned by QueryBuilder::getQuery()
*
* @return QueryBuilder
*/
public function createQueryBuilder()
{
$qm = $this->session->getWorkspace()->getQueryManager();
return new QueryBuilder($qm->getQOMFactory());
}
示例14: registerNodeTypes
/**
* Register the content-type node types with the given PHPCR session.
*/
public function registerNodeTypes(SessionInterface $session)
{
$cnd = sprintf('<%s=\'https://github.com/symfony-cmf/content-type\'>', $this->encoder->getPrefix(), $this->encoder->getUri());
$nodeTypeManager = $session->getWorkspace()->getNodeTypeManager();
$nodeTypeManager->registerNodeTypesCnd($cnd, true);
}
示例15: cleanSession
private function cleanSession(OutputInterface $output, SessionInterface $session, $path, $dryRun)
{
$sessionName = $session->getWorkspace()->getName();
$output->writeln(sprintf('<info>Session</info> %s', $sessionName));
if (!$session->nodeExists($path)) {
$output->write(sprintf('<error>Resource-Locator "%s" not found in session "%s"</error>', $path, $sessionName));
return;
}
$node = $session->getNode($path);
$this->cleanup($output, $node, $path, $dryRun);
$output->writeln('');
}