Skip to content

Commit

Permalink
Merge pull request #38 from mireo91/master
Browse files Browse the repository at this point in the history
TASK: Elasticsearch-contentrepositoryadaptor ^5.0 compatibility
  • Loading branch information
daniellienert authored Mar 4, 2020
2 parents 1f86be5 + 733af7b commit 6442ddf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion Classes/Indexer/NodeIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,26 @@ class NodeIndexer extends ContentRepositoryAdaptor\Indexer\NodeIndexer
*/
public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
{
if( $node->isRemoved() ){
$this->removeNode($node, $targetWorkspaceName);
return;
}
if ($this->enableLiveAsyncIndexing !== true) {
parent::indexNode($node, $targetWorkspaceName);

return;
}

if ($this->settings['indexAllWorkspaces'] === false) {
if ($targetWorkspaceName !== null && $targetWorkspaceName !== 'live') {
return;
}

if ($targetWorkspaceName === null && $node->getContext()->getWorkspaceName() !== 'live') {
return;
}
}

$indexingJob = new IndexingJob($this->indexNamePostfix, $targetWorkspaceName, $this->nodeAsArray($node));
$this->jobManager->queue(NodeIndexQueueCommandController::LIVE_QUEUE_NAME, $indexingJob);
}
Expand All @@ -72,6 +86,16 @@ public function removeNode(NodeInterface $node, $targetWorkspaceName = null)
return;
}

if ($this->settings['indexAllWorkspaces'] === false) {
if ($targetWorkspaceName !== null && $targetWorkspaceName !== 'live') {
return;
}

if ($targetWorkspaceName === null && $node->getContext()->getWorkspaceName() !== 'live') {
return;
}
}

$removalJob = new RemovalJob($this->indexNamePostfix, $targetWorkspaceName, $this->nodeAsArray($node));
$this->jobManager->queue(NodeIndexQueueCommandController::LIVE_QUEUE_NAME, $removalJob);
}
Expand All @@ -88,7 +112,7 @@ protected function nodeAsArray(NodeInterface $node)
[
'persistenceObjectIdentifier' => $this->persistenceManager->getIdentifierByObject($node->getNodeData()),
'identifier' => $node->getIdentifier(),
'dimensions' => $node->getDimensions(),
'dimensions' => $node->getContext()->getDimensions(),
'workspace' => $node->getWorkspace()->getName(),
'nodeType' => $node->getNodeType()->getName(),
'path' => $node->getPath()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"flowpack/jobqueue-common": "^3.0 || dev-master",
"flowpack/elasticsearch-contentrepositoryadaptor": "^4.0"
"flowpack/elasticsearch-contentrepositoryadaptor": "^4.0 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 6442ddf

Please sign in to comment.