本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeInterface::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getContext方法的具体用法?PHP NodeInterface::getContext怎么用?PHP NodeInterface::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Model\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRoot
/**
* Get the root node
*
* @return NodeInterface
*/
public function getRoot()
{
if (!$this->root) {
$this->root = $this->active->getContext()->getCurrentSiteNode();
}
return $this->root;
}
示例2: showAction
/**
* Shows the specified node and takes visibility and access restrictions into
* account.
*
* @param NodeInterface $node
* @return string View output for the specified node
* @Flow\SkipCsrfProtection We need to skip CSRF protection here because this action could be called with unsafe requests from widgets or plugins that are rendered on the node - For those the CSRF token is validated on the sub-request, so it is safe to be skipped here
* @Flow\IgnoreValidation("node")
* @throws NodeNotFoundException
*/
public function showAction(NodeInterface $node = NULL)
{
if ($node === NULL) {
throw new NodeNotFoundException('The requested node does not exist or isn\'t accessible to the current user', 1430218623);
}
if (!$node->getContext()->isLive() && !$this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess')) {
$this->redirect('index', 'Login', NULL, array('unauthorized' => TRUE));
}
$inBackend = $node->getContext()->isInBackend();
if ($node->getNodeType()->isOfType('TYPO3.Neos:Shortcut') && !$inBackend) {
$this->handleShortcutNode($node);
}
$this->view->assign('value', $node);
if ($inBackend) {
$this->overrideViewVariablesFromInternalArguments();
/** @var UserInterfaceMode $renderingMode */
$renderingMode = $node->getContext()->getCurrentRenderingMode();
$this->response->setHeader('Cache-Control', 'no-cache');
if ($renderingMode !== NULL) {
// Deprecated TypoScript context variable from version 2.0.
$this->view->assign('editPreviewMode', $renderingMode->getTypoScriptPath());
}
if (!$this->view->canRenderWithNodeAndPath()) {
$this->view->setTypoScriptPath('rawContent');
}
}
if ($this->session->isStarted() && $inBackend) {
$this->session->putData('lastVisitedNode', $node->getContextPath());
}
}
示例3: query
/**
* @param NodeInterface $contextNode
* @return QueryBuilder
*/
public function query(NodeInterface $contextNode)
{
$this->where[] = "(__parentPath LIKE '%#" . $contextNode->getPath() . "#%' OR __path LIKE '" . $contextNode->getPath() . "')";
$this->where[] = "(__workspace LIKE '%#" . $contextNode->getContext()->getWorkspace()->getName() . "#%')";
$this->where[] = "(__dimensionshash LIKE '%#" . md5(json_encode($contextNode->getContext()->getDimensions())) . "#%')";
$this->contextNode = $contextNode;
return $this;
}
开发者ID:kuborgh-mspindelhirn,项目名称:Flowpack.SimpleSearch.ContentRepositoryAdaptor,代码行数:12,代码来源:SqLiteQueryBuilder.php
示例4: generateUriPathSegment
/**
* Generates a URI path segment for a given node taking it's language dimension into account
*
* @param NodeInterface $node Optional node to determine language dimension
* @param string $text Optional text
* @return string
*/
public function generateUriPathSegment(NodeInterface $node = null, $text = null)
{
if ($node) {
$text = $text ?: $node->getLabel() ?: $node->getName();
$dimensions = $node->getContext()->getDimensions();
if (array_key_exists('language', $dimensions) && $dimensions['language'] !== array()) {
$locale = new Locale($dimensions['language'][0]);
$language = $locale->getLanguage();
}
} elseif (strlen($text) === 0) {
throw new Exception('Given text was empty.', 1457591815);
}
$text = $this->transliterationService->transliterate($text, isset($language) ? $language : null);
return Transliterator::urlize($text);
}
示例5: wrapContentProperty
/**
* Wrap the $content identified by $node with the needed markup for the backend.
*
* @param NodeInterface $node
* @param string $property
* @param string $content
* @return string
*/
public function wrapContentProperty(NodeInterface $node, $property, $content)
{
/** @var $contentContext ContentContext */
$contentContext = $node->getContext();
if ($contentContext->getWorkspaceName() === 'live' || !$this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess')) {
return $content;
}
if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
return $content;
}
$attributes = array();
$attributes['class'] = 'neos-inline-editable';
$attributes['property'] = 'typo3:' . $property;
$attributes['data-neos-node-type'] = $node->getNodeType()->getName();
return $this->htmlAugmenter->addAttributes($content, $attributes, 'span');
}
示例6: evaluate
/**
* {@inheritdoc}
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation
* @return mixed|null if the operation is final, the return value
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$imagePropertyName = $arguments[0];
if ($this->contextNode->hasProperty($imagePropertyName)) {
$image = $this->contextNode->getProperty($imagePropertyName);
if ($image instanceof ImageVariant) {
$image = $image->getOriginalAsset();
}
if ($image instanceof Image) {
$identifier = $image->getIdentifier();
$nodeData = $this->metaDataRepository->findOneByAssetIdentifier($identifier, $this->contextNode->getContext()->getWorkspace());
if ($nodeData instanceof NodeData) {
return $this->nodeFactory->createFromNodeData($nodeData, $this->contextNode->getContext());
}
}
}
return null;
}
示例7: isInDimensionPreset
/**
* Matches if the currently-selected preset in the passed $dimensionName is one of $presets.
*
* Example: isInDimensionPreset('language', 'de') checks whether the currently-selected language
* preset (in the Neos backend) is "de".
*
* Implementation Note: We deliberately work on the Dimension Preset Name, and not on the
* dimension values itself; as the preset is user-visible and the actual dimension-values
* for a preset are just implementation details.
*
* @param string $dimensionName
* @param string|array $presets
* @return boolean
*/
public function isInDimensionPreset($dimensionName, $presets)
{
if ($this->node === NULL) {
return TRUE;
}
$dimensionValues = $this->node->getContext()->getDimensions();
if (!isset($dimensionValues[$dimensionName])) {
return FALSE;
}
$preset = $this->contentDimensionPresetSource->findPresetByDimensionValues($dimensionName, $dimensionValues[$dimensionName]);
if ($preset === NULL) {
return FALSE;
}
$presetIdentifier = $preset['identifier'];
if (!is_array($presets)) {
$presets = array($presets);
}
return in_array($presetIdentifier, $presets);
}
示例8: createChildNodes
/**
* Creates missing child nodes for the given node.
*
* @param NodeInterface $node
* @return void
*/
public function createChildNodes(NodeInterface $node)
{
$nodeType = $node->getNodeType();
foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeType) {
try {
$node->createNode($childNodeName, $childNodeType);
} catch (NodeExistsException $exception) {
// If you have a node that has been marked as removed, but is needed again
// the old node is recovered
$childNodePath = NodePaths::addNodePathSegment($node->getPath(), $childNodeName);
$contextProperties = $node->getContext()->getProperties();
$contextProperties['removedContentShown'] = true;
$context = $this->contextFactory->create($contextProperties);
$childNode = $context->getNode($childNodePath);
if ($childNode->isRemoved()) {
$childNode->setRemoved(false);
}
}
}
}
示例9: evaluate
/**
* Returns the rendered content of this plugin
*
* @return string The rendered content as a string
* @throws StopActionException
*/
public function evaluate()
{
$currentContext = $this->tsRuntime->getCurrentContext();
$this->pluginViewNode = $currentContext['node'];
/** @var $parentResponse Response */
$parentResponse = $this->tsRuntime->getControllerContext()->getResponse();
$pluginResponse = new Response($parentResponse);
$pluginRequest = $this->buildPluginRequest();
if ($pluginRequest->getControllerObjectName() === '') {
$message = 'Master View not selected';
if ($this->pluginViewNode->getProperty('plugin')) {
$message = 'Plugin View not selected';
}
if ($this->pluginViewNode->getProperty('view')) {
$message = 'Master View or Plugin View not found';
}
return $this->pluginViewNode->getContext()->getWorkspaceName() !== 'live' || $this->objectManager->getContext()->isDevelopment() ? '<p>' . $message . '</p>' : '<!-- ' . $message . '-->';
}
$this->dispatcher->dispatch($pluginRequest, $pluginResponse);
return $pluginResponse->getContent();
}
示例10: showAction
/**
* Shows the specified node and takes visibility and access restrictions into
* account.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
* @return string View output for the specified node
*/
public function showAction(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
{
if ($node->getContext()->getWorkspace()->getName() !== 'live') {
// TODO: Introduce check if workspace is visible or accessible to the user
try {
$this->accessDecisionManager->decideOnResource('TYPO3_TYPO3_Backend_BackendController');
$this->nodeRepository->getContext()->setInvisibleContentShown(TRUE);
$this->nodeRepository->getContext()->setRemovedContentShown(TRUE);
} catch (\TYPO3\FLOW3\Security\Exception\AccessDeniedException $exception) {
$this->throwStatus(403);
}
}
if ($this->isWireframeModeEnabled($node)) {
$this->forward('showWireframe', NULL, NULL, array('node' => $node->getPath()));
}
if (!$node->isAccessible()) {
try {
$this->authenticationManager->authenticate();
} catch (\Exception $exception) {
}
}
if (!$node->isAccessible() && !$this->nodeRepository->getContext()->isInaccessibleContentShown()) {
$this->throwStatus(403);
}
if (!$node->isVisible() && !$this->nodeRepository->getContext()->isInvisibleContentShown()) {
$this->throwStatus(404);
}
if ($node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Shortcut')) {
while ($node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Shortcut')) {
$childNodes = $node->getChildNodes('TYPO3.Phoenix.ContentTypes:Page,TYPO3.Phoenix.ContentTypes:Shortcut');
$node = current($childNodes);
}
$this->redirect('show', NULL, NULL, array('node' => $node));
}
$this->nodeRepository->getContext()->setCurrentNode($node);
$this->view->assign('value', $node);
$this->response->setHeader('Cache-Control', 'public, s-maxage=600', FALSE);
}
示例11: setNode
/**
* Set the "context node" this operation was working on.
*
* @param NodeInterface $node
* @return void
*/
public function setNode(NodeInterface $node)
{
$this->nodeIdentifier = $node->getIdentifier();
$this->workspaceName = $node->getContext()->getWorkspaceName();
$this->dimension = $node->getContext()->getDimensions();
$context = $node->getContext();
if ($context instanceof ContentContext && $context->getCurrentSite() !== null) {
$siteIdentifier = $this->persistenceManager->getIdentifierByObject($context->getCurrentSite());
} else {
$siteIdentifier = null;
}
$this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('nodeContextPath' => $node->getContextPath(), 'nodeLabel' => $node->getLabel(), 'nodeType' => $node->getNodeType()->getName(), 'site' => $siteIdentifier));
$node = self::getClosestAggregateNode($node);
if ($node !== null) {
$this->documentNodeIdentifier = $node->getIdentifier();
$this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('documentNodeContextPath' => $node->getContextPath(), 'documentNodeLabel' => $node->getLabel(), 'documentNodeType' => $node->getNodeType()->getName()));
}
}
示例12: getMergedTypoScriptObjectTree
/**
* Returns a merged TypoScript object tree in the context of the given nodes
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $startNode Node marking the starting point
* @return array The merged object tree as of the given node
* @throws \TYPO3\Neos\Domain\Exception
*/
public function getMergedTypoScriptObjectTree(NodeInterface $startNode)
{
$contentContext = $startNode->getContext();
$siteResourcesPackageKey = $contentContext->getCurrentSite()->getSiteResourcesPackageKey();
$siteRootTypoScriptPathAndFilename = sprintf($this->siteRootTypoScriptPattern, $siteResourcesPackageKey);
$siteRootTypoScriptCode = $this->readExternalTypoScriptFile($siteRootTypoScriptPathAndFilename);
if ($siteRootTypoScriptCode === '') {
$siteRootTypoScriptPathAndFilename = sprintf($this->legacySiteRootTypoScriptPattern, $siteResourcesPackageKey);
$siteRootTypoScriptCode = $this->readExternalTypoScriptFile($siteRootTypoScriptPathAndFilename);
}
$mergedTypoScriptCode = '';
$mergedTypoScriptCode .= $this->generateNodeTypeDefinitions();
$mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->prepareAutoIncludeTypoScript());
$mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->prependTypoScriptIncludes);
$mergedTypoScriptCode .= $siteRootTypoScriptCode;
$mergedTypoScriptCode .= $this->getTypoScriptIncludes($this->appendTypoScriptIncludes);
return $this->typoScriptParser->parse($mergedTypoScriptCode, $siteRootTypoScriptPathAndFilename);
}
示例13: createRecursiveCopy
/**
* Create a recursive copy of this node below $referenceNode with $nodeName.
*
* $detachedCopy only has an influence if we are copying from one dimension to the other, possibly creating a new
* node variant:
*
* - If $detachedCopy is TRUE, the whole (recursive) copy is done without connecting original and copied node,
* so NOT CREATING a new node variant.
* - If $detachedCopy is FALSE, and the node does not yet have a variant in the target dimension, we are CREATING
* a new node variant.
*
* As a caller of this method, $detachedCopy should be TRUE if $this->getNodeType()->isAggregate() is TRUE, and FALSE
* otherwise.
*
* @param NodeInterface $referenceNode
* @param boolean $detachedCopy
* @param string $nodeName
* @return NodeInterface
*/
protected function createRecursiveCopy(NodeInterface $referenceNode, $nodeName, $detachedCopy)
{
$identifier = null;
$referenceNodeDimensions = $referenceNode->getDimensions();
$referenceNodeDimensionsHash = Utility::sortDimensionValueArrayAndReturnDimensionsHash($referenceNodeDimensions);
$thisDimensions = $this->getDimensions();
$thisNodeDimensionsHash = Utility::sortDimensionValueArrayAndReturnDimensionsHash($thisDimensions);
if ($detachedCopy === false && $referenceNodeDimensionsHash !== $thisNodeDimensionsHash && $referenceNode->getContext()->getNodeByIdentifier($this->getIdentifier()) === null) {
// If the target dimensions are different than this one, and there is no node shadowing this one in the target dimension yet, we use the same
// node identifier, effectively creating a new node variant.
$identifier = $this->getIdentifier();
}
$copiedNode = $referenceNode->createSingleNode($nodeName, null, $identifier);
$copiedNode->similarize($this, true);
/** @var $childNode Node */
foreach ($this->getChildNodes() as $childNode) {
// Prevent recursive copy when copying into itself
if ($childNode->getIdentifier() !== $copiedNode->getIdentifier()) {
$childNode->copyIntoInternal($copiedNode, $childNode->getName(), $detachedCopy);
}
}
return $copiedNode;
}
示例14: query
/**
* Sets the starting point for this query. Search result should only contain nodes that
* match the context of the given node and have it as parent node in their rootline.
*
* @param NodeInterface $contextNode
* @return QueryBuilderInterface
* @api
*/
public function query(NodeInterface $contextNode)
{
// on indexing, the __parentPath is tokenized to contain ALL parent path parts,
// e.g. /foo, /foo/bar/, /foo/bar/baz; to speed up matching.. That's why we use a simple "term" filter here.
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
$this->queryFilter('term', ['__parentPath' => $contextNode->getPath()]);
//
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
$this->queryFilter('terms', ['__workspace' => array_unique(['live', $contextNode->getContext()->getWorkspace()->getName()])]);
// match exact dimension values for each dimension, this works because the indexing flattens the node variants for all dimension preset combinations
$dimensionCombinations = $contextNode->getContext()->getDimensions();
if (is_array($dimensionCombinations)) {
$this->queryFilter('term', ['__dimensionCombinationHash' => md5(json_encode($dimensionCombinations))]);
}
$this->contextNode = $contextNode;
return $this;
}
开发者ID:kdambekalns,项目名称:Flowpack.ElasticSearch.ContentRepositoryAdaptor,代码行数:25,代码来源:ElasticSearchQueryBuilder.php
示例15: needsMetadata
/**
* @param NodeInterface $node
* @param boolean $renderCurrentDocumentMetadata
* @return boolean
*/
protected function needsMetadata(NodeInterface $node, $renderCurrentDocumentMetadata)
{
/** @var $contentContext ContentContext */
$contentContext = $node->getContext();
return $contentContext->isInBackend() === true && ($renderCurrentDocumentMetadata === true || $this->nodeAuthorizationService->isGrantedToEditNode($node) === true);
}