Skip to content

Commit 081d15b

Browse files
remuslazardaniellienert
authored andcommitted
Make the calculateDocumentIdentifier method public and static
we want to use that in other places as well to stay DRY
1 parent 6f35b71 commit 081d15b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Classes/Indexer/NodeIndexer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null): voi
243243
}
244244
}
245245

246-
$documentIdentifier = $this->calculateDocumentIdentifier($node, $targetWorkspaceName);
246+
$documentIdentifier = NodeIndexer::calculateDocumentIdentifier($node, $targetWorkspaceName);
247247
$nodeType = $node->getNodeType();
248248

249249
$mappingType = $this->getIndex()->findType($nodeType->getName());
@@ -346,11 +346,11 @@ protected function toBulkRequest(NodeInterface $node, array $requests = null): v
346346
* Returns a stable identifier for the Elasticsearch document representing the node
347347
*
348348
* @param NodeInterface $node
349-
* @param string $targetWorkspaceName
349+
* @param null $targetWorkspaceName
350350
* @return string
351351
* @throws IllegalObjectTypeException
352352
*/
353-
protected function calculateDocumentIdentifier(NodeInterface $node, $targetWorkspaceName = null): string
353+
public static function calculateDocumentIdentifier(NodeInterface $node, $targetWorkspaceName = null): string
354354
{
355355
$workspaceName = $targetWorkspaceName ?: $node->getWorkspace()->getName();
356356
$nodeIdentifier = $node->getIdentifier();
@@ -384,7 +384,7 @@ public function removeNode(NodeInterface $node, string $targetWorkspaceName = nu
384384
}
385385
}
386386

387-
$documentIdentifier = $this->calculateDocumentIdentifier($node, $targetWorkspaceName);
387+
$documentIdentifier = NodeIndexer::calculateDocumentIdentifier($node, $targetWorkspaceName);
388388

389389
$this->toBulkRequest($node, $this->documentDriver->delete($node, $documentIdentifier));
390390
$this->toBulkRequest($node, $this->indexerDriver->fulltext($node, [], $targetWorkspaceName));

0 commit comments

Comments
 (0)