Skip to content

Commit

Permalink
!!!TASK: Respect current site node by default if no specific starting…
Browse files Browse the repository at this point in the history
…Point is set #10
  • Loading branch information
jobee committed Jan 3, 2022
1 parent 9aadf57 commit 368b347
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Classes/DataSource/NodeDataDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ public function getData(NodeInterface $node = null, array $arguments = [])
// Context variables
$workspaceName = $node->getContext()->getWorkspaceName();
$dimensions = $node->getContext()->getDimensions();
if (isset($arguments['startingPoint'])) {
$rootNode = $node->getContext()->getNode($arguments['startingPoint']);
} else {
$rootNode = $node->getContext()->getCurrentSiteNode();
}
$rootNodePath = $rootNode->getPath();

// Check for an existing cache entry
$cacheEntryIdentifier = md5(json_encode([$workspaceName, $dimensions, $arguments]));
$cacheEntryIdentifier = md5(json_encode([$workspaceName, $dimensions, $rootNodePath, $arguments]));
if ($this->cache->has($cacheEntryIdentifier)) {
$this->logger->debug(
sprintf('Retrieve cached data source for "%s" on [%s %s] %s', json_encode($arguments), $workspaceName, json_encode($dimensions), $node->getLabel()),
sprintf('Retrieve cached data source for "%s" in [Workspace: %s] [Dimensions: %s] [Root: %s] [Label: %s]', json_encode($arguments), $workspaceName, json_encode($dimensions), $rootNodePath, $node->getLabel()),
LogEnvironment::fromMethodName(__METHOD__)
);
$result = $this->cache->get($cacheEntryIdentifier);
Expand All @@ -97,12 +103,6 @@ public function getData(NodeInterface $node = null, array $arguments = [])
if (isset($arguments['previewPropertyName']))
$previewPropertyName = $arguments['previewPropertyName'];

if (isset($arguments['startingPoint'])) {
$rootNode = $node->getContext()->getNode($arguments['startingPoint']);
} else {
$rootNode = $node->getContext()->getRootNode();
}

$groupByNodeType = null;
if (isset($arguments['groupBy'])) {
$groupByNodeType = $arguments['groupBy'];
Expand All @@ -123,7 +123,7 @@ public function getData(NodeInterface $node = null, array $arguments = [])
$this->cache->set($cacheEntryIdentifier, $result, $cacheEntryTags);

$this->logger->debug(
sprintf('Build new data source for "%s" on [%s %s] %s', json_encode($arguments), $workspaceName, json_encode($dimensions), $node->getLabel()),
sprintf('Build new data source for "%s" in [Workspace: %s] [Dimensions: %s] [Root: %s] [Label: %s]', json_encode($arguments), $workspaceName, json_encode($dimensions), $rootNodePath, $node->getLabel()),
LogEnvironment::fromMethodName(__METHOD__)
);

Expand Down

0 comments on commit 368b347

Please sign in to comment.