Skip to content

Commit

Permalink
remove version properties in export.xml (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored Dec 16, 2020
1 parent 3f928b7 commit 16fd883
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/vendor/
.idea
composer.lock
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"jackalope/jackalope-jackrabbit": "^1.2"
},
"require-dev": {
"dflydev/embedded-composer": "@dev",
"nanbando/core": "^0.1|dev-master",
"phpunit/phpunit": "^5.3"
"phpunit/phpunit": "^6.0"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 16 additions & 1 deletion src/JackrabbitPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,27 @@ public function restore(
*/
private function export(SessionInterface $session, $path, $stream)
{
$memoryStream = \fopen('php://memory', 'w+');
$session->exportSystemView(
$path,
$stream,
$memoryStream,
true,
false
);

\rewind($memoryStream);
$content = \stream_get_contents($memoryStream);

$document = new \DOMDocument();
$document->loadXML($content);
$xpath = new \DOMXPath($document);
$xpath->registerNamespace('sv', 'http://www.jcp.org/jcr/sv/1.0');

foreach ($xpath->query('//sv:property[@sv:name="sulu:versions" or @sv:name="jcr:versionHistory" or @sv:name="jcr:baseVersion" or @sv:name="jcr:predecessors" or @sv:name="jcr:isCheckedOut"]') as $element) {
$element->parentNode->removeChild($element);
}

\fwrite($stream, $document->saveXML());
}

/**
Expand Down

0 comments on commit 16fd883

Please sign in to comment.