-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #394 from Flowpack/fix-node-move-issues
BUGFIX: Moving nodes must not lead to duplicated documents
- Loading branch information
Showing
9 changed files
with
165 additions
and
97 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Classes/Service/DocumentIdentifier/DocumentIdentifierGeneratorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\DocumentIdentifier; | ||
|
||
/* | ||
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
|
||
interface DocumentIdentifierGeneratorInterface | ||
{ | ||
/** | ||
* Generates a stable identifier out of the given node | ||
* | ||
* @param NodeInterface $node | ||
* @param string|null $targetWorkspaceName | ||
* @return string | ||
*/ | ||
public function generate(NodeInterface $node, ?string $targetWorkspaceName = null): string; | ||
} |
27 changes: 27 additions & 0 deletions
27
Classes/Service/DocumentIdentifier/NodeIdentifierBasedDocumentIdentifierGenerator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\DocumentIdentifier; | ||
|
||
/* | ||
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
|
||
class NodeIdentifierBasedDocumentIdentifierGenerator implements DocumentIdentifierGeneratorInterface | ||
{ | ||
public function generate(NodeInterface $node, ?string $targetWorkspaceName = null): string | ||
{ | ||
$workspaceName = $targetWorkspaceName ?: $node->getWorkspace()->getName(); | ||
$nodeIdentifier = $node->getIdentifier(); | ||
|
||
return sha1($nodeIdentifier . $workspaceName); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Classes/Service/DocumentIdentifier/NodePathBasedDocumentIdentifierGenerator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\DocumentIdentifier; | ||
|
||
/* | ||
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
|
||
class NodePathBasedDocumentIdentifierGenerator implements DocumentIdentifierGeneratorInterface | ||
{ | ||
public function generate(NodeInterface $node, ?string $targetWorkspaceName = null): string | ||
{ | ||
$contextPath = $node->getContextPath(); | ||
|
||
if ($targetWorkspaceName !== null) { | ||
$contextPath = str_replace($node->getContext()->getWorkspace()->getName(), $targetWorkspaceName, $contextPath); | ||
} | ||
|
||
return sha1($contextPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters