本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeInterface::getNodeType方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getNodeType方法的具体用法?PHP NodeInterface::getNodeType怎么用?PHP NodeInterface::getNodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Model\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::getNodeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
示例2: resolveShortcutTarget
/**
* Resolves a shortcut node to the target. The return value can be
*
* * a NodeInterface instance if the target is a node or a node:// URI
* * a string (in case the target is a plain text URI or an asset:// URI)
* * NULL in case the shortcut cannot be resolved
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
* @return NodeInterface|string|NULL
*/
public function resolveShortcutTarget(NodeInterface $node)
{
$infiniteLoopPrevention = 0;
while ($node->getNodeType()->isOfType('TYPO3.Neos:Shortcut') && $infiniteLoopPrevention < 50) {
$infiniteLoopPrevention++;
switch ($node->getProperty('targetMode')) {
case 'selectedTarget':
$target = $node->getProperty('target');
if ($this->linkingService->hasSupportedScheme($target)) {
$targetObject = $this->linkingService->convertUriToObject($target, $node);
if ($targetObject instanceof NodeInterface) {
$node = $targetObject;
} elseif ($targetObject instanceof AssetInterface) {
return $this->linkingService->resolveAssetUri($target);
}
} else {
return $target;
}
break;
case 'parentNode':
$node = $node->getParent();
break;
case 'firstChildNode':
default:
$childNodes = $node->getChildNodes('TYPO3.Neos:Document');
if ($childNodes !== array()) {
$node = reset($childNodes);
} else {
return null;
}
}
}
return $node;
}
示例3: handle
/**
* Set the node title for the newly created Document node
*
* @param NodeInterface $node The newly created node
* @param array $data incoming data from the creationDialog
* @return void
*/
public function handle(NodeInterface $node, array $data)
{
if (isset($data['title']) && $node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
$node->setProperty('title', $data['title']);
$node->setProperty('uriPathSegment', NodeUtility::renderValidNodeName($data['title']));
}
}
示例4: afterNodeCreate
/**
* Hooks into `afterNodeCreate` event dispatched from CR,
* when new node has been created.
*
* @param NodeInterface $node
*/
public function afterNodeCreate(NodeInterface $node)
{
if (!($nodeType = $node->getNodeType())) {
return;
}
// array with [beforeNodes, childNodes, afterNodes] keys
$config = $this->getAssistanceConfigForNodeType($nodeType->getName());
switch ($nodeType->getName()) {
case 'TYPO3.Neos.NodeTypes:Image':
$this->configureImage($node, $nodeType, $config);
break;
case 'M12.Foundation:GridRow1Col':
case 'M12.Foundation:GridRow2Col':
case 'M12.Foundation:GridRow3Col':
case 'M12.Foundation:GridRow4Col':
$this->configureGridRow($node, $nodeType);
break;
case 'M12.Foundation:GridColumn':
break;
// assistance text nodes are created from $this->configureGridRow()
// assistance text nodes are created from $this->configureGridRow()
case 'M12.Foundation:RevealModal':
$this->configureLinkingButton($node, $nodeType, $config, 'htmlDataRevealId');
break;
case 'M12.Foundation:Dropdown':
case 'M12.Foundation:DropdownContent':
$this->configureLinkingButton($node, $nodeType, $config, 'htmlDataDropdownId');
break;
default:
$this->configureCreateAssistanceChildNodes($node, $nodeType, $config);
break;
}
}
示例5: getClosestDocument
/**
* Helper method to retrieve the closest document for a node
*
* @param NodeInterface $node
* @return NodeInterface
*/
public function getClosestDocument(NodeInterface $node)
{
if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
return $node;
}
$flowQuery = new FlowQuery(array($node));
return $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
}
示例6: nearestContentCollection
/**
* Check if the given node is already a collection, find collection by nodePath otherwise, throw exception
* if no content collection could be found
*
* @param NodeInterface $node
* @param string $nodePath
* @return NodeInterface
* @throws Exception
*/
public function nearestContentCollection(NodeInterface $node, $nodePath)
{
$contentCollectionType = 'TYPO3.Neos:ContentCollection';
if ($node->getNodeType()->isOfType($contentCollectionType)) {
return $node;
} else {
if ((string) $nodePath === '') {
throw new Exception(sprintf('No content collection of type %s could be found in the current node and no node path was provided. You might want to configure the nodePath property with a relative path to the content collection.', $contentCollectionType), 1409300545);
}
$subNode = $node->getNode($nodePath);
if ($subNode !== null && $subNode->getNodeType()->isOfType($contentCollectionType)) {
return $subNode;
} else {
throw new Exception(sprintf('No content collection of type %s could be found in the current node (%s) or at the path "%s". You might want to adjust your node type configuration and create the missing child node through the "flow node:repair --node-type %s" command.', $contentCollectionType, $node->getPath(), $nodePath, (string) $node->getNodeType()), 1389352984);
}
}
}
示例7: matches
/**
* Returns TRUE if the given node is of the node type this filter expects.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
* @return boolean
*/
public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
{
if ($this->withSubTypes === TRUE) {
return $this->nodeTypeManager->getNodeType($node->getNodeType())->isOfType($this->nodeTypeName);
} else {
$nodeData = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($node, 'nodeData', TRUE);
$nodeType = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($nodeData, 'nodeType', TRUE);
return $nodeType === $this->nodeTypeName;
}
}
示例8: registerNodePathChange
/**
* Schedules flushing of the routing cache entry for the given $nodeData
* Note: This is not done recursively because the nodePathChanged signal is triggered for any affected node data instance
*
* @param NodeInterface $node The affected node data instance
* @return void
*/
public function registerNodePathChange(NodeInterface $node)
{
if (in_array($node->getIdentifier(), $this->tagsToFlush)) {
return;
}
if (!$node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
return;
}
$this->tagsToFlush[] = $node->getIdentifier();
}
示例9: registerNodeChange
/**
* Register a node change for a later cache flush. This method is triggered by a signal sent via TYPO3CR's Node
* model or the Neos Publishing Service.
*
* @param NodeInterface $node The node which has changed in some way
* @return void
*/
public function registerNodeChange(NodeInterface $node)
{
$this->tagsToFlush[ContentCache::TAG_EVERYTHING] = 'which were tagged with "Everything".';
$nodeTypesToFlush = $this->getAllImplementedNodeTypes($node->getNodeType());
foreach ($nodeTypesToFlush as $nodeType) {
$nodeTypeName = $nodeType->getName();
$this->tagsToFlush['NodeType_' . $nodeTypeName] = sprintf('which were tagged with "NodeType_%s" because node "%s" has changed and was of type "%s".', $nodeTypeName, $node->getPath(), $node->getNodeType()->getName());
}
$this->tagsToFlush['Node_' . $node->getIdentifier()] = sprintf('which were tagged with "Node_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath());
$originalNode = $node;
while ($node->getDepth() > 1) {
$node = $node->getParent();
// Workaround for issue #56566 in TYPO3.TYPO3CR
if ($node === null) {
break;
}
$tagName = 'DescendantOf_' . $node->getIdentifier();
$this->tagsToFlush[$tagName] = sprintf('which were tagged with "%s" because node "%s" has changed.', $tagName, $originalNode->getPath());
}
}
示例10: setUniqueUriPathSegment
/**
* Sets the best possible uriPathSegment for the given Node.
* Will use an already set uriPathSegment or alternatively the node name as base,
* then checks if the uriPathSegment already exists on the same level and appends a counter until a unique path segment was found.
*
* @param NodeInterface $node
* @return void
*/
public static function setUniqueUriPathSegment(NodeInterface $node)
{
if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
$q = new FlowQuery(array($node));
$q = $q->context(array('invisibleContentShown' => true, 'removedContentShown' => true, 'inaccessibleContentShown' => true));
$possibleUriPathSegment = $initialUriPathSegment = !$node->hasProperty('uriPathSegment') ? $node->getName() : $node->getProperty('uriPathSegment');
$i = 1;
while ($q->siblings('[instanceof TYPO3.Neos:Document][uriPathSegment="' . $possibleUriPathSegment . '"]')->count() > 0) {
$possibleUriPathSegment = $initialUriPathSegment . '-' . $i++;
}
$node->setProperty('uriPathSegment', $possibleUriPathSegment);
}
}
示例11: breadcrumbNodesForNode
/**
* @param NodeInterface $node
* @return array
*/
protected function breadcrumbNodesForNode(NodeInterface $node)
{
$documentNodes = [];
$flowQuery = new FlowQuery(array($node));
$nodes = array_reverse($flowQuery->parents('[instanceof TYPO3.Neos:Document]')->get());
/** @var NodeInterface $node */
foreach ($nodes as $documentNode) {
$documentNodes[] = $documentNode;
}
if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
$documentNodes[] = $node;
}
return $documentNodes;
}
示例12: generateCacheTags
/**
* Generates cache tags to be flushed for a node which is flushed on shutdown.
*
* Code duplicated from Neos' ContentCacheFlusher class
*
* @param NodeInterface|NodeData $node The node which has changed in some way
* @return void
*/
protected function generateCacheTags($node)
{
$this->tagsToFlush[ContentCache::TAG_EVERYTHING] = 'which were tagged with "Everything".';
$nodeTypesToFlush = $this->getAllImplementedNodeTypes($node->getNodeType());
foreach ($nodeTypesToFlush as $nodeType) {
/** @var NodeType $nodeType */
$nodeTypeName = $nodeType->getName();
$this->tagsToFlush['NodeType_' . $nodeTypeName] = sprintf('which were tagged with "NodeType_%s" because node "%s" has changed and was of type "%s".', $nodeTypeName, $node->getPath(), $node->getNodeType()->getName());
}
$this->tagsToFlush['Node_' . $node->getIdentifier()] = sprintf('which were tagged with "Node_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath());
while ($node->getDepth() > 1) {
$node = $node->getParent();
if ($node === NULL) {
break;
}
$this->tagsToFlush['DescendantOf_' . $node->getIdentifier()] = sprintf('which were tagged with "DescendantOf_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath());
}
if ($node instanceof NodeInterface && $node->getContext() instanceof ContentContext) {
$firstActiveDomain = $node->getContext()->getCurrentSite()->getFirstActiveDomain();
if ($firstActiveDomain) {
$this->domainsToFlush[] = $firstActiveDomain->getHostPattern();
}
}
}
示例13: nodeIsOfType
/**
* @param string|array $nodeTypes
* @return boolean
*/
public function nodeIsOfType($nodeTypes)
{
if ($this->node === NULL) {
return TRUE;
}
if (!is_array($nodeTypes)) {
$nodeTypes = array($nodeTypes);
}
foreach ($nodeTypes as $nodeType) {
if ($this->node->getNodeType()->isOfType($nodeType)) {
return TRUE;
}
}
return FALSE;
}
示例14: nodeIsOfType
/**
* Matches if the selected node is of the given NodeType(s). If multiple types are specified, only one entry has to match
*
* Example: nodeIsOfType(['TYPO3.TYPO3CR:NodeType1', 'TYPO3.TYPO3CR:NodeType2']) matches if the selected node is of (sub) type *TYPO3.TYPO3CR:NodeType1* or *TYPO3.TYPO3CR:NodeType1*
*
* @param string|array $nodeTypes A single or an array of fully qualified NodeType name(s), e.g. "TYPO3.Neos:Document"
* @return boolean TRUE if the selected node matches the $nodeTypes, otherwise FALSE
*/
public function nodeIsOfType($nodeTypes)
{
if ($this->node === null) {
return true;
}
if (!is_array($nodeTypes)) {
$nodeTypes = array($nodeTypes);
}
foreach ($nodeTypes as $nodeType) {
if ($this->node->getNodeType()->isOfType($nodeType)) {
return true;
}
}
return false;
}
示例15: trackAction
/**
* Increase read counter of the node by one
*
* @param NodeInterface $node Node to increase the read counter for
*
* @throws BadRequestException
* @return mixed[]
*/
public function trackAction(NodeInterface $node)
{
// we can only count pages that include the mixin
if ($node->getNodeType()->isOfType('Futjikato.ReadCounter:CounterMixin')) {
$node->setProperty('readcounter', $node->getProperty('readcounter') + 1);
/**
* Action changes data but is accessible via GET. this issues a error if we do not manually
* persists the object in the persistence manager
*/
$this->persistenceManager->persistAll();
// by default the flow JSON view uses the 'value' variable
$this->view->assign('value', array('readcounter' => $node->getProperty('readcounter')));
} else {
throw new BadRequestException('Node does not contain Futjikato.ReadCounter:CounterMixin.');
}
}