Skip to content

Commit

Permalink
Add basic workspace support
Browse files Browse the repository at this point in the history
  • Loading branch information
mchh committed Mar 28, 2023
1 parent f1232cb commit 68c9ca9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Classes/Controller/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function uploadAction()
$this->import->setDataFromCSV($file, $args['delimiter']);
$this->import->setParentNodeIdentifier($args['parentNodeIdentifier']);
$this->import->setTargetNodeType($args['targetNodeType']);
$this->import->setTargetWorkspace($args['targetWorkspace']);

$this->redirect('mapping');
}
Expand Down Expand Up @@ -116,8 +117,14 @@ public function importAction() {
$parentNodeIdentifier = $this->import->getParentNodeIdentifier();
$targetNodeType = $this->nodeTypeManager->getNodeType($this->import->getTargetNodeType());

$context = $this->contextFactory->create();
$q = new FlowQuery([$context->getCurrentSiteNode()]);
$workspace = $this->import->getTargetWorkspace();

/** @var ContentContext $contentContext */
$contentContext = $this->contextFactory->create([
'workspaceName' => $workspace,
]);

$q = new FlowQuery([$contentContext->getCurrentSiteNode()]);
$parentNode = $q->find($parentNodeIdentifier)->get(0);

$nodeTemplate = new NodeTemplate();
Expand Down
29 changes: 29 additions & 0 deletions Classes/Domain/Model/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Import
*/
protected $targetNodeType = '';

/**
* @var string
*/
protected $targetWorkspace = '';

/**
* Get data
*
Expand Down Expand Up @@ -111,6 +116,29 @@ public function setTargetNodeType($targetNodeType)
$this->targetNodeType = $targetNodeType;
}

/**
* Get targetWorkspace
*
* @return string
* @Flow\Session(autoStart = TRUE)
*/
public function getTargetWorkspace()
{
return $this->targetWorkspace;
}

/**
* Set targetWorkspace
*
* @param string $targetWorkspace
* @return void
* @Flow\Session(autoStart = TRUE)
*/
public function setTargetWorkspace($targetWorkspace)
{
$this->targetWorkspace = $targetWorkspace;
}

/**
* Remove all import data
*
Expand All @@ -121,5 +149,6 @@ public function flush()
unset($this->data);
unset($this->parentNodeIdentifier);
unset($this->targetNodeType);
unset($this->targetWorkspace);
}
}
6 changes: 6 additions & 0 deletions Resources/Private/Templates/Import/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<f:form.select class="neos-span12 form-control" name="targetNodeType" additionalAttributes="{required: 'required'}" options="{nodeTypes}"></f:form.select>
</div>
</div>
<div class="neos-control-group">
<label class="neos-control-label">Target Workspace</label>
<div class="neos-controls">
<f:form.textfield class="neos-span12 form-control" name="targetWorkspace" additionalAttributes="{required: 'required'}" value="" placeholder="Workspace name"></f:form.textfield>
</div>
</div>
</fieldset>
</div>
<div class="neos-footer">
Expand Down

0 comments on commit 68c9ca9

Please sign in to comment.