Skip to content

Commit

Permalink
TASK: Query nodes for UI flowqueries directly from the db
Browse files Browse the repository at this point in the history
This way we only need one query to get all requested nodes
instead of a query for each one.
  • Loading branch information
Sebobo committed Jun 26, 2024
1 parent 1261a8f commit cde3bab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 22 additions & 0 deletions Classes/ContentRepository/Service/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
* source code.
*/

use Doctrine\ORM\EntityManagerInterface;
use Neos\ContentRepository\Domain\Factory\NodeFactory;
use Neos\ContentRepository\Domain\Model\NodeData;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Model\Workspace;
use Neos\ContentRepository\Domain\Repository\NodeDataRepository;
use Neos\ContentRepository\Domain\Service\Context;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
use Neos\ContentRepository\Domain\Utility\NodePaths;
Expand Down Expand Up @@ -47,6 +51,24 @@ class NodeService
*/
protected $domainRepository;

/**
* @Flow\Inject
* @var NodeDataRepository
*/
protected $nodeDataRepository;

/**
* @Flow\Inject
* @var EntityManagerInterface
*/
protected $entityManager;

/**
* @Flow\Inject
* @var NodeFactory
*/
protected $nodeFactory;

/**
* @var array<string, Context>
*/
Expand Down
8 changes: 2 additions & 6 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,9 @@ public function flowQueryAction(array $chain): string
$finisher = array_pop($chain);

$nodeContextPaths = array_unique(array_column($createContext['payload'], '$node'));
$nodes = $this->nodeService->getNodesFromContextPaths($nodeContextPaths);

$flowQuery = new FlowQuery(array_map(
function ($contextPath) {
return $this->nodeService->getNodeFromContextPath($contextPath);
},
$nodeContextPaths
));
$flowQuery = new FlowQuery($nodes);

foreach ($chain as $operation) {
$flowQuery = call_user_func_array([$flowQuery, $operation['type']], $operation['payload']);
Expand Down

0 comments on commit cde3bab

Please sign in to comment.