Skip to content

Commit 6442ddf

Browse files
Merge pull request #38 from mireo91/master
TASK: Elasticsearch-contentrepositoryadaptor ^5.0 compatibility
2 parents 1f86be5 + 733af7b commit 6442ddf

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Classes/Indexer/NodeIndexer.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,26 @@ class NodeIndexer extends ContentRepositoryAdaptor\Indexer\NodeIndexer
5050
*/
5151
public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
5252
{
53+
if( $node->isRemoved() ){
54+
$this->removeNode($node, $targetWorkspaceName);
55+
return;
56+
}
5357
if ($this->enableLiveAsyncIndexing !== true) {
5458
parent::indexNode($node, $targetWorkspaceName);
5559

5660
return;
5761
}
5862

63+
if ($this->settings['indexAllWorkspaces'] === false) {
64+
if ($targetWorkspaceName !== null && $targetWorkspaceName !== 'live') {
65+
return;
66+
}
67+
68+
if ($targetWorkspaceName === null && $node->getContext()->getWorkspaceName() !== 'live') {
69+
return;
70+
}
71+
}
72+
5973
$indexingJob = new IndexingJob($this->indexNamePostfix, $targetWorkspaceName, $this->nodeAsArray($node));
6074
$this->jobManager->queue(NodeIndexQueueCommandController::LIVE_QUEUE_NAME, $indexingJob);
6175
}
@@ -72,6 +86,16 @@ public function removeNode(NodeInterface $node, $targetWorkspaceName = null)
7286
return;
7387
}
7488

89+
if ($this->settings['indexAllWorkspaces'] === false) {
90+
if ($targetWorkspaceName !== null && $targetWorkspaceName !== 'live') {
91+
return;
92+
}
93+
94+
if ($targetWorkspaceName === null && $node->getContext()->getWorkspaceName() !== 'live') {
95+
return;
96+
}
97+
}
98+
7599
$removalJob = new RemovalJob($this->indexNamePostfix, $targetWorkspaceName, $this->nodeAsArray($node));
76100
$this->jobManager->queue(NodeIndexQueueCommandController::LIVE_QUEUE_NAME, $removalJob);
77101
}
@@ -88,7 +112,7 @@ protected function nodeAsArray(NodeInterface $node)
88112
[
89113
'persistenceObjectIdentifier' => $this->persistenceManager->getIdentifierByObject($node->getNodeData()),
90114
'identifier' => $node->getIdentifier(),
91-
'dimensions' => $node->getDimensions(),
115+
'dimensions' => $node->getContext()->getDimensions(),
92116
'workspace' => $node->getWorkspace()->getName(),
93117
'nodeType' => $node->getNodeType()->getName(),
94118
'path' => $node->getPath()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"require": {
77
"flowpack/jobqueue-common": "^3.0 || dev-master",
8-
"flowpack/elasticsearch-contentrepositoryadaptor": "^4.0"
8+
"flowpack/elasticsearch-contentrepositoryadaptor": "^4.0 || ^5.0"
99
},
1010
"autoload": {
1111
"psr-4": {

0 commit comments

Comments
 (0)