/** * 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(); } } }
/** * Returns the level at which this node is located. * Counting starts with 0 for "/", 1 for "/foo", 2 for "/foo/bar" etc. * * @return integer * @api */ public function getDepth() { return $this->nodeData->getDepth(); }
/** * @test */ public function getDepthReturnsThePathDepthOfTheNode() { $node = new NodeData('/', $this->mockWorkspace); $this->assertEquals(0, $node->getDepth()); $node = new NodeData('/foo', $this->mockWorkspace); $this->assertEquals(1, $node->getDepth()); $node = new NodeData('/foo/bar', $this->mockWorkspace); $this->assertEquals(2, $node->getDepth()); $node = new NodeData('/foo/bar/baz/quux', $this->mockWorkspace); $this->assertEquals(4, $node->getDepth()); }