本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository类的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository类的具体用法?PHP NodeDataRepository怎么用?PHP NodeDataRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeDataRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByNodeTypeAndCurrentSite
/**
* Returns node by the specified node type
*
* @param string $nodeType Type of node to be searched.
* @param array $ignoreNodes Array of node paths which need to be ignored.
* @return \TYPO3\Flow\Persistence\QueryResultInterface
*/
public function findByNodeTypeAndCurrentSite($nodeType, $ignoreNodes = NULL)
{
if ($ignoreNodes === NULL) {
$ignoreNodes[] = '';
}
$query = $this->nodeDataRepository->createQuery();
$constraints = array($query->equals('nodeType', $nodeType), $query->logicalNot($query->in('path', $ignoreNodes)));
return $query->matching($query->logicalAnd($constraints))->execute();
}
示例2: pruneAll
/**
* Remove all nodes, workspaces, domains and sites.
*
* @return void
*/
public function pruneAll()
{
$sites = $this->siteRepository->findAll();
$this->nodeDataRepository->removeAll();
$this->workspaceRepository->removeAll();
$this->domainRepository->removeAll();
$this->siteRepository->removeAll();
foreach ($sites as $site) {
$this->emitSitePruned($site);
}
}
示例3: execute
/**
* Execute the migration
*
* @return void
*/
public function execute()
{
foreach ($this->nodeDataRepository->findAll() as $node) {
foreach ($this->configuration as $migrationDescription) {
if ($this->nodeFilterService->matchFilters($node, $migrationDescription['filters'])) {
$this->nodeTransformationService->execute($node, $migrationDescription['transformations']);
if (!$this->nodeDataRepository->isInRemovedNodes($node)) {
$this->nodeDataRepository->update($node);
}
}
}
}
}
示例4: saveNodesAndTearDownRootNodeAndRepository
protected function saveNodesAndTearDownRootNodeAndRepository()
{
if ($this->nodeDataRepository !== NULL) {
$this->nodeDataRepository->flushNodeRegistry();
}
/** @var \TYPO3\TYPO3CR\Domain\Factory\NodeFactory $nodeFactory */
$nodeFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Factory\\NodeFactory');
$nodeFactory->reset();
$this->contextFactory->reset();
$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();
$this->nodeDataRepository = NULL;
$this->rootNode = NULL;
}
示例5: pruneSite
/**
* Remove given site all nodes for that site and all domains associated.
*
* @param Site $site
* @return void
*/
public function pruneSite(Site $site)
{
$siteNodePath = NodePaths::addNodePathSegment(static::SITES_ROOT_PATH, $site->getNodeName());
$this->nodeDataRepository->removeAllInPath($siteNodePath);
$siteNodes = $this->nodeDataRepository->findByPath($siteNodePath);
foreach ($siteNodes as $siteNode) {
$this->nodeDataRepository->remove($siteNode);
}
$domainsForSite = $this->domainRepository->findBySite($site);
foreach ($domainsForSite as $domain) {
$this->domainRepository->remove($domain);
}
$this->siteRepository->remove($site);
$this->emitSitePruned($site);
}
示例6: importSite
/**
* @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
* @return void
* @throws \TYPO3\Setup\Exception
*/
public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
{
$formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
$this->nodeDataRepository->removeAll();
$this->workspaceRepository->removeAll();
$this->domainRepository->removeAll();
$this->siteRepository->removeAll();
$this->persistenceManager->persistAll();
}
if (!empty($formValues['packageKey'])) {
if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
}
$packageKey = $formValues['packageKey'];
$siteName = $formValues['siteName'];
$generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService');
$generatorService->generateSitePackage($packageKey, $siteName);
} elseif (!empty($formValues['site'])) {
$packageKey = $formValues['site'];
}
$this->deactivateOtherSitePackages($packageKey);
$this->packageManager->activatePackage($packageKey);
if (!empty($packageKey)) {
try {
$contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
$this->siteImportService->importFromPackage($packageKey, $contentContext);
} catch (\Exception $exception) {
$finisherContext->cancel();
$this->systemLogger->logException($exception);
throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864);
}
}
}
示例7: removeContentDimensionsFromRootAndSitesNode
/**
* Remove dimensions on nodes "/" and "/sites"
*
* This empties the content dimensions on those nodes, so when traversing via the Node API from the root node,
* the nodes below "/sites" are always reachable.
*
* @param string $workspaceName
* @param boolean $dryRun
* @return void
*/
public function removeContentDimensionsFromRootAndSitesNode($workspaceName, $dryRun)
{
$workspace = $this->workspaceRepository->findByIdentifier($workspaceName);
$rootNodes = $this->nodeDataRepository->findByPath('/', $workspace);
$sitesNodes = $this->nodeDataRepository->findByPath('/sites', $workspace);
$this->output->outputLine('Checking for root and site nodes with content dimensions set ...');
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $rootNode */
foreach ($rootNodes as $rootNode) {
if ($rootNode->getDimensionValues() !== []) {
if ($dryRun === false) {
$rootNode->setDimensions([]);
$this->nodeDataRepository->update($rootNode);
$this->output->outputLine('Removed content dimensions from root node');
} else {
$this->output->outputLine('Found root node with content dimensions set.');
}
}
}
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $sitesNode */
foreach ($sitesNodes as $sitesNode) {
if ($sitesNode->getDimensionValues() !== []) {
if ($dryRun === false) {
$sitesNode->setDimensions([]);
$this->nodeDataRepository->update($sitesNode);
$this->output->outputLine('Removed content dimensions from node "/sites"');
} else {
$this->output->outputLine('Found node "/sites"');
}
}
}
}
示例8: findNodesByPropertyKeyAndValue
/**
* @test
*/
public function findNodesByPropertyKeyAndValue()
{
$this->createNodesForNodeSearchTest();
$result = $this->nodeDataRepository->findByProperties(array('test2' => 'simpleTestValue'), 'TYPO3.TYPO3CR.Testing:NodeType', $this->liveWorkspace, $this->context->getDimensions());
$this->assertCount(1, $result);
$this->assertEquals('test-node-2', array_shift($result)->getName());
}
示例9: findByProperties
/**
* Search all properties for given $term
*
* TODO: Implement a better search when Flow offer the possibility
*
* @param string $term
* @param array $searchNodeTypes
* @param Context $context
* @param NodeInterface $startingPoint
* @return array <\TYPO3\TYPO3CR\Domain\Model\NodeInterface>
*/
public function findByProperties($term, array $searchNodeTypes, Context $context, NodeInterface $startingPoint = null)
{
if (strlen($term) === 0) {
throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
}
$searchResult = array();
$nodeTypeFilter = implode(',', $searchNodeTypes);
$nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null);
foreach ($nodeDataRecords as $nodeData) {
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
if ($node !== null) {
$searchResult[$node->getPath()] = $node;
}
}
return $searchResult;
}
示例10: doDiscardNode
/**
* Method which does the actual work of discarding, includes a protection against endless recursions and
* multiple discarding of the same node.
*
* @param NodeInterface $node The node to discard
* @param array &$alreadyDiscardedNodeIdentifiers List of node identifiers which already have been discarded during one discardNode() run
* @return void
* @throws \TYPO3\TYPO3CR\Exception\WorkspaceException
*/
protected function doDiscardNode(NodeInterface $node, array &$alreadyDiscardedNodeIdentifiers = [])
{
if ($node->getWorkspace()->getBaseWorkspace() === null) {
throw new WorkspaceException('Nodes in a in a workspace without a base workspace cannot be discarded.', 1395841899);
}
if ($node->getPath() === '/') {
return;
}
if (array_search($node->getIdentifier(), $alreadyDiscardedNodeIdentifiers) !== false) {
return;
}
$alreadyDiscardedNodeIdentifiers[] = $node->getIdentifier();
$possibleShadowNodeData = $this->nodeDataRepository->findOneByMovedTo($node->getNodeData());
if ($possibleShadowNodeData instanceof NodeData) {
if ($possibleShadowNodeData->getMovedTo() !== null) {
$parentBasePath = $node->getPath();
$affectedChildNodeDataInSameWorkspace = $this->nodeDataRepository->findByParentAndNodeType($parentBasePath, null, $node->getWorkspace(), null, false, true);
foreach ($affectedChildNodeDataInSameWorkspace as $affectedChildNodeData) {
/** @var NodeData $affectedChildNodeData */
$affectedChildNode = $this->nodeFactory->createFromNodeData($affectedChildNodeData, $node->getContext());
$this->doDiscardNode($affectedChildNode, $alreadyDiscardedNodeIdentifiers);
}
}
$this->nodeDataRepository->remove($possibleShadowNodeData);
}
$this->nodeDataRepository->remove($node);
$this->emitNodeDiscarded($node);
}
示例11: removeUnusedImageVariant
/**
* Removes unused ImageVariants after a Node property changes to a different ImageVariant.
* This is triggered via the nodePropertyChanged event.
*
* Note: This method it triggered by the "nodePropertyChanged" signal, @see \TYPO3\TYPO3CR\Domain\Model\Node::emitNodePropertyChanged()
*
* @param NodeInterface $node the affected node
* @param string $propertyName name of the property that has been changed/added
* @param mixed $oldValue the property value before it was changed or NULL if the property is new
* @param mixed $value the new property value
* @return void
*/
public function removeUnusedImageVariant(NodeInterface $node, $propertyName, $oldValue, $value)
{
if ($oldValue === $value || !$oldValue instanceof ImageVariant) {
return;
}
$identifier = $this->persistenceManager->getIdentifierByObject($oldValue);
$results = $this->nodeDataRepository->findNodesByRelatedEntities(array(ImageVariant::class => [$identifier]));
// This case shouldn't happen as the query will usually find at least the node that triggered this call, still if there is no relation we can remove the ImageVariant.
if ($results === []) {
$this->assetRepository->remove($oldValue);
return;
}
// If the result contains exactly the node that got a new ImageVariant assigned then we are safe to remove the asset here.
if ($results === [$node->getNodeData()]) {
$this->assetRepository->remove($oldValue);
}
}
示例12: sortByDateTimeDescending
/**
* @test
*/
public function sortByDateTimeDescending()
{
$nodesToSort = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array())];
$correctOrder = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array())];
$flowQuery = new \TYPO3\Eel\FlowQuery\FlowQuery($nodesToSort);
$operation = new SortOperation();
$operation->evaluate($flowQuery, ['_lastPublicationDateTime', 'DESC']);
$this->assertEquals($correctOrder, $flowQuery->getContext());
}
示例13: getNodes
/**
* Find all nodes of a specific node type
*
* @param string $nodeType
* @param ContentContext $context current content context, see class doc comment for details
* @return array<NodeInterface> all nodes of type $nodeType in the current $context
*/
protected function getNodes($nodeType, ContentContext $context)
{
$nodes = array();
$siteNode = $context->getCurrentSiteNode();
foreach ($this->nodeDataRepository->findByParentAndNodeTypeRecursively($siteNode->getPath(), $nodeType, $context->getWorkspace()) as $nodeData) {
$nodes[] = $this->nodeFactory->createFromNodeData($nodeData, $context);
}
return $nodes;
}
示例14: createVariantForContext
/**
* Given a context a new node is returned that is like this node, but
* lives in the new context.
*
* @param \TYPO3\TYPO3CR\Domain\Service\Context $context
* @return NodeInterface
*/
public function createVariantForContext($context)
{
$nodeData = clone $this->nodeData;
$nodeData->adjustToContext($context);
$this->nodeDataRepository->add($nodeData);
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
return $node;
}
示例15: addTargetNodeToArguments
/**
* @Flow\Around("method(TYPO3\Flow\Mvc\Routing\Router->resolve())")
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
* @return mixed
*/
public function addTargetNodeToArguments(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
{
if (!isset($this->settings['targetNodeMappings']) || !is_array($this->settings['targetNodeMappings'])) {
return $joinPoint->getAdviceChain()->proceed($joinPoint);
}
$arguments = $joinPoint->getMethodArgument('routeValues');
foreach ($this->settings['targetNodeMappings'] as $pluginNamespace => $pluginTargetNodeMappings) {
$pluginNamespace = '--' . $pluginNamespace;
if (!isset($arguments[$pluginNamespace]) || !is_array($arguments[$pluginNamespace])) {
continue;
}
$pluginArguments = $arguments[$pluginNamespace];
foreach ($pluginTargetNodeMappings as $pluginTargetNodeMapping) {
if (isset($pluginTargetNodeMapping['package']) && (!isset($pluginArguments['@package']) || strtolower($pluginArguments['@package']) !== strtolower($pluginTargetNodeMapping['package']))) {
continue;
}
if (isset($pluginTargetNodeMapping['controller']) && (!isset($pluginArguments['@controller']) || strtolower($pluginArguments['@controller']) !== strtolower($pluginTargetNodeMapping['controller']))) {
continue;
}
if (isset($pluginTargetNodeMapping['action']) && (!isset($pluginArguments['@action']) || strtolower($pluginArguments['@action']) !== strtolower($pluginTargetNodeMapping['action']))) {
continue;
}
if (isset($pluginTargetNodeMapping['targetNamespace'])) {
unset($arguments[$pluginNamespace]);
$arguments['--' . $pluginTargetNodeMapping['targetNamespace']] = $pluginArguments;
}
$nodeIdentifier = $pluginTargetNodeMapping['targetNode'];
$node = $this->nodeDataRepository->findOneByIdentifier($nodeIdentifier, $this->createContext()->getWorkspace());
if ($node === NULL) {
throw new \TYPO3\Flow\Exception('no node with identifier "' . $nodeIdentifier . '" found', 1334172725);
}
$arguments['node'] = $node->getContextPath();
$arguments['@package'] = 'TYPO3.Neos';
$arguments['@controller'] = 'Frontend\\Node';
$arguments['@format'] = 'html';
$arguments['@action'] = 'show';
$joinPoint->setMethodArgument('routeValues', $arguments);
return $joinPoint->getAdviceChain()->proceed($joinPoint);
}
}
return $joinPoint->getAdviceChain()->proceed($joinPoint);
}