Skip to content

Commit

Permalink
TASK: Simplify code in GraphProjectorCatchUpHookForCacheFlushing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 26, 2024
1 parent 3cdf712 commit 965cc34
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamId;
use Neos\ContentRepository\Core\Feature\Common\EmbedsNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\EmbedsWorkspaceName;
use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated;
Expand All @@ -38,7 +37,6 @@
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Event\WorkspaceWasRebased;
use Neos\ContentRepository\Core\Projection\CatchUpHookInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventEnvelope;
Expand Down Expand Up @@ -166,7 +164,6 @@ public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $even
if ($nodeAggregate) {
$this->scheduleCacheFlushJobForNodeAggregate(
$this->contentRepository,
$eventInstance->workspaceName,
$nodeAggregate,
$contentGraph->findAncestorNodeAggregateIds($eventInstance->getNodeAggregateId()),
);
Expand Down Expand Up @@ -195,7 +192,6 @@ public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $event
} elseif (
!($eventInstance instanceof NodeAggregateWasRemoved)
&& $eventInstance instanceof EmbedsNodeAggregateId
&& $eventInstance instanceof EmbedsContentStreamId
&& $eventInstance instanceof EmbedsWorkspaceName
) {
$contentGraph = $this->contentRepository->getContentGraph($eventInstance->getWorkspaceName());
Expand All @@ -206,7 +202,6 @@ public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $event
if ($nodeAggregate) {
$this->scheduleCacheFlushJobForNodeAggregate(
$this->contentRepository,
$eventInstance->getWorkspaceName(),
$nodeAggregate,
$contentGraph->findAncestorNodeAggregateIds($eventInstance->getNodeAggregateId())
);
Expand All @@ -216,14 +211,13 @@ public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $event

private function scheduleCacheFlushJobForNodeAggregate(
ContentRepository $contentRepository,
WorkspaceName $workspaceName,
NodeAggregate $nodeAggregate,
NodeAggregateIds $ancestorNodeAggregateIds
): void {
// we store this in an associative array deduplicate.
$this->flushNodeAggregateRequestsOnAfterCatchUp[$workspaceName->value . '__' . $nodeAggregate->nodeAggregateId->value] = FlushNodeAggregateRequest::create(
$this->flushNodeAggregateRequestsOnAfterCatchUp[$nodeAggregate->workspaceName->value . '__' . $nodeAggregate->nodeAggregateId->value] = FlushNodeAggregateRequest::create(
$contentRepository->id,
$workspaceName,
$nodeAggregate->workspaceName,
$nodeAggregate->nodeAggregateId,
$nodeAggregate->nodeTypeName,
$ancestorNodeAggregateIds
Expand Down

0 comments on commit 965cc34

Please sign in to comment.