Skip to content

Commit

Permalink
Merge pull request #4416 from neos/bugfix/4017-remove-contentstream-e…
Browse files Browse the repository at this point in the history
…xport-cli-command

TASK: Remove `contentstream:import` and `contentstream:export` CLI commands
  • Loading branch information
bwaidelich authored Aug 11, 2023
2 parents 31462c7 + 81e4157 commit a301d85
Showing 1 changed file with 0 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,103 +15,6 @@ class ContentStreamCommandController extends CommandController
*/
protected $contentRepositoryRegistry;

/**
* @throws \Neos\Flow\Cli\Exception\StopCommandException
*/
public function exportCommand(string $contentStream, string $contentRepository = 'default', int $startSequenceNumber = 0): void
{
$contentRepositoryId = ContentRepositoryId::fromString($contentRepository);
throw new \RuntimeException('TODO IMPL??');
// TODO??$events = $this->contentRepositoryEventStore->load(
// StreamName::fromString($contentStream),
// $startSequenceNumber
//);
}

/**
* Imports events to a content stream from the given file.
* Note that the events in the file need to come from the same content stream you import to for now!
*
* @throws \Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamAlreadyExists
* @throws \Neos\ContentRepository\Core\Feature\WorkspaceCreation\Exception\WorkspaceAlreadyExists
* @throws \Neos\EventSourcing\EventListener\Exception\EventCouldNotBeAppliedException
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/
public function importCommand(string $contentStream, string $file = null): void
{
throw new \RuntimeException('TODO IMPL??');
// TODO
// if ($file !== null) {
// $fileStream = fopen($file, 'r');
// $this->outputLine('Reading from file: "%s"', [$file]);
// } else {
// $fileStream = fopen('php://stdin', 'r');
// $this->outputLine('Reading import data from standard in.');
// }
// if (!$fileStream) {
// throw new \InvalidArgumentException('Failed to open file ' . $file);
// }
// $normalizer = new EventNormalizer(new EventTypeResolver());
//
// $contentStreamToImportTo = ContentStreamId::fromString($contentStream);
// $eventStreamName = ContentStreamEventStreamName::fromContentStreamId($contentStreamToImportTo)
// ->getEventStreamName();
//
// $this->outputLine('Clearing workspace projection to create the workspace to import to.');
// $workspaceProjection = $this->projectionManager->getProjection('workspace');
// $this->projectionManager->replay($workspaceProjection->getIdentifier());
//
// $commandResult = $this->workspaceCommandHandler->handleCreateRootWorkspace(
// new CreateRootWorkspace(
// WorkspaceName::forLive(),
// WorkspaceTitle::fromString('Live'),
// WorkspaceDescription::fromString(''),
// UserIdentifier::forSystemUser(),
// $contentStreamToImportTo
// )
// );
//
// $this->outputLine('Created workspace "Live" for the given content stream identifier');
//
// $i = 0;
// $domainEvents = DomainEvents::createEmpty();
//
// $this->outputLine('starting import');
// $this->output->progressStart();
// for ($line = fgets($fileStream); $line !== false; $line = fgets($fileStream)) {
// $this->output->progressAdvance();
// $i++;
// if ($line === '[' || $line === ']') {
// continue;
// }
//
// $rawEventLine = ltrim($line, ',');
// $rawEventProperties = json_decode($rawEventLine, true);
// if (!is_array($rawEventProperties)) {
// continue;
// }
//
// $domainEvent = $normalizer->denormalize($rawEventProperties['payload'], $rawEventProperties['type']);
// $domainEvent = DecoratedEvent::addMetadata($domainEvent, $rawEventProperties['metadata']);
//
// $domainEvents = $domainEvents->appendEvent($domainEvent);
//
// if ($i === 10) {
// $this->contentRepositoryEventStore->commit($eventStreamName, $domainEvents);
// $domainEvents = DomainEvents::createEmpty();
// $i = 0;
// }
// }
// $this->output->progressFinish();
//
// $this->contentRepositoryEventStore->commit($eventStreamName, $domainEvents);
// fclose($fileStream);
// $this->outputLine('');
// $this->outputLine('Finished importing events.');
// $this->outputLine('Your events and projections are probably out of sync now,'
// . ' <error>make sure you replay all projections via "./flow projection:replayall"</error>.');
}

/**
* Remove all content streams which are not needed anymore from the projections.
*
Expand Down

0 comments on commit a301d85

Please sign in to comment.