-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathNodeTemplateCommandController.php
More file actions
45 lines (39 loc) · 1.39 KB
/
NodeTemplateCommandController.php
File metadata and controls
45 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace Flowpack\NodeTemplates\Application\Command;
use Flowpack\NodeTemplates\Domain\NodeTemplateDumper\NodeTemplateDumper;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Neos\Domain\Service\ContentContextFactory;
class NodeTemplateCommandController extends CommandController
{
/**
* @Flow\Inject
* @var ContentContextFactory
*/
protected $contentContextFactory;
/**
* @Flow\Inject
* @var NodeTemplateDumper
*/
protected $nodeTemplateDumper;
/**
* Dump the node tree structure into a NodeTemplate YAML structure.
* References to Nodes and non-primitive property values are commented out in the YAML.
*
* @param string $startingNodeId specified root node of the node tree
* @param string $workspaceName
* @return void
*/
public function createFromNodeSubtreeCommand(string $startingNodeId, string $workspaceName = 'live'): void
{
$subgraph = $this->contentContextFactory->create([
'workspaceName' => $workspaceName
]);
$node = $subgraph->getNodeByIdentifier($startingNodeId);
if (!$node) {
throw new \InvalidArgumentException("Node $startingNodeId doesnt exist in workspace $workspaceName.");
}
echo $this->nodeTemplateDumper->createNodeTemplateYamlDumpFromSubtree($node);
}
}