Skip to content

Commit

Permalink
Merge pull request #4472 from neos/task/migrateNodeTypesCommandContro…
Browse files Browse the repository at this point in the history
…ller
  • Loading branch information
ahaeslich authored Sep 8, 2023
2 parents a9d9aff + cb06b7b commit 3a94d61
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Neos\ContentRepository\Command;
namespace Neos\ContentRepositoryRegistry\Command;

/*
* This file is part of the Neos.ContentRepository package.
Expand All @@ -12,26 +12,34 @@
* source code.
*/

use Neos\ContentRepository\Domain\Service\NodeTypeManager;
use Neos\ContentRepository\Core\Factory\ContentRepositoryId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Symfony\Component\Yaml\Yaml;

#[Flow\Scope("singleton")]
class NodeTypesCommandController extends CommandController
{
#[Flow\Inject]
protected NodeTypeManager $nodeTypeManager;
public function __construct(
private readonly ContentRepositoryRegistry $contentRepositoryRegistry
) {
parent::__construct();
}

/**
* Shows the merged configuration (including supertypes) of a NodeType
*
* @param string $nodeTypeName The name of the NodeType to show
* @param ?string $path Path of the NodeType-configuration which will be shown
* @param string $contentRepository Identifier of the Content Repository to determine the set of NodeTypes
*/
public function showCommand(string $nodeTypeName, ?string $path = null): void
public function showCommand(string $nodeTypeName, ?string $path = null, string $contentRepository = 'default'): void
{
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
$contentRepositoryId = ContentRepositoryId::fromString($contentRepository);
$nodeTypeManager = $this->contentRepositoryRegistry->get($contentRepositoryId)->getNodeTypeManager();

$nodeType = $nodeTypeManager->getNodeType($nodeTypeName);
if (!$nodeType) {
$this->outputLine('<b>NodeType "%s" was not found!</b>', [$nodeTypeName]);
$this->quit();
Expand All @@ -53,12 +61,16 @@ public function showCommand(string $nodeTypeName, ?string $path = null): void
*
* @param string|null $filter Only NodeType-names containing this string will be listed
* @param bool $includeAbstract List abstract NodeTypes
* @param string $contentRepository Identifier of the Content Repository to determine the set of NodeTypes
*/
public function listCommand(?string $filter = null, bool $includeAbstract = true): void
public function listCommand(?string $filter = null, bool $includeAbstract = true, string $contentRepository = 'default'): void
{
$contentRepositoryId = ContentRepositoryId::fromString($contentRepository);
$nodeTypeManager = $this->contentRepositoryRegistry->get($contentRepositoryId)->getNodeTypeManager();

$nodeTypesFound = 0;
$nodeTypeNameSpacesWithNodeTypeNames = [];
foreach ($this->nodeTypeManager->getNodeTypes($includeAbstract) as $nodeType) {
foreach ($nodeTypeManager->getNodeTypes($includeAbstract) as $nodeType) {
$nodeTypeName = $nodeType->getName();
if (!$filter || str_contains($nodeTypeName, $filter)) {
[$nameSpace] = explode(":", $nodeTypeName, 2);
Expand Down

0 comments on commit 3a94d61

Please sign in to comment.