本文整理汇总了PHP中PHPCR\NodeInterface::getReferences方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getReferences方法的具体用法?PHP NodeInterface::getReferences怎么用?PHP NodeInterface::getReferences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::getReferences方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* {@inheritdoc}
*/
protected function initialize()
{
if (true === $this->initialized) {
return;
}
$references = $this->node->getReferences();
// TODO: Performance: calling getParent adds overhead when the collection is
// initialized, but if we don't do this, we won't know how many items are in the
// collection, as one node could have many referring properties.
foreach ($references as $reference) {
/* @var PropertyInterface $reference */
$referrerNode = $reference->getParent();
$this->documents[$referrerNode->getIdentifier()] = $referrerNode;
}
$this->initialized = true;
}
示例2: changePathToHistory
/**
* changes path node to history node.
*
* @param NodeInterface $node
* @param SessionInterface $session
* @param string $absSrcPath
* @param string $absDestPath
*/
private function changePathToHistory(NodeInterface $node, SessionInterface $session, $absSrcPath, $absDestPath)
{
// get new path node
$relPath = str_replace($absSrcPath, '', $node->getPath());
$newPath = PathHelper::normalizePath($absDestPath . $relPath);
$newPathNode = $session->getNode($newPath);
// set history to true and set content to new path
$node->setProperty('sulu:content', $newPathNode);
$node->setProperty('sulu:history', true);
// get referenced history
/** @var PropertyInterface $property */
foreach ($node->getReferences('sulu:content') as $property) {
$property->getParent()->setProperty('sulu:content', $newPathNode);
}
}
示例3: iterateRouteNodes
/**
* Iterates over all route nodes assigned by the given node, and executes the callback on it.
*
* @param NodeInterface $node
* @param callable $callback will be called foreach route node (stops and return value if not false)
* @param string $webspaceKey
* @param string $languageCode
* @param string $segmentKey
*
* @return \PHPCR\NodeInterface
*/
private function iterateRouteNodes(NodeInterface $node, $callback, $webspaceKey, $languageCode, $segmentKey = null)
{
if ($node->isNew()) {
return;
}
$routePath = $this->sessionManager->getRoutePath($webspaceKey, $languageCode);
// search for references with name 'content'
foreach ($node->getReferences('sulu:content') as $ref) {
if ($ref instanceof \PHPCR\PropertyInterface) {
$routeNode = $ref->getParent();
if (0 !== strpos($routeNode->getPath(), $routePath)) {
continue;
}
$resourceLocator = $this->getResourceLocator($ref->getParent()->getPath(), $webspaceKey, $languageCode, $segmentKey);
$result = $callback($resourceLocator, $routeNode);
if (false !== $result) {
return $result;
}
}
}
return;
}
示例4: getReferences
/**
* {@inheritdoc}
*/
public function getReferences($name = null)
{
return $this->node->getReferences($name);
}
示例5: removeReferencesForNode
/**
* @param $node
*/
private function removeReferencesForNode(NodeInterface $node)
{
$references = $node->getReferences();
foreach ($references as $reference) {
$referrer = $reference->getParent();
$metadata = $this->metadataFactory->getMetadataForPhpcrNode($referrer);
if ($metadata->getClass() === RouteDocument::class) {
continue;
}
$this->dereferenceProperty($node, $reference);
}
}