Skip to content

Commit 31da601

Browse files
committed
Merge branch 'main' into neos-9
* main: TASK: Check composer for registered psr4 nodetypes namespace # Conflicts: # Classes/Command/NodetypeObjectsCommandController.php
2 parents e3be0c7 + 094a458 commit 31da601

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

Classes/Command/NodetypeObjectsCommandController.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
99
use Neos\Flow\Cli\CommandController;
1010
use Neos\Flow\Package\FlowPackageInterface;
11+
use Neos\Flow\Package\GenericPackage;
1112
use Neos\Flow\Package\PackageManager;
1213
use Neos\Utility\Files;
1314
use PackageFactory\NodeTypeObjects\Factory\NodeTypeObjectFileFactory;
@@ -89,6 +90,32 @@ public function buildCommand(string $packageKey, string $crId = 'default'): void
8990
$this->output->outputLine($packageKey . " is not a Flow package");
9091
$this->quit(1);
9192
}
93+
if (!$package instanceof GenericPackage) {
94+
$this->output->outputLine($packageKey . " is not a Generic package");
95+
$this->quit(1);
96+
}
97+
98+
/**
99+
* @var array<int, array{namespace:string, classPath:string, mappingType:string}> $autoloadConfigurations
100+
*/
101+
$autoloadConfigurations = $package->getFlattenedAutoloadConfiguration();
102+
$namespace = null;
103+
foreach ($autoloadConfigurations as $autoloadConfiguration) {
104+
if (
105+
$autoloadConfiguration['mappingType'] === 'psr-4'
106+
&& str_ends_with($autoloadConfiguration['namespace'], '\\NodeTypes\\')
107+
&& $autoloadConfiguration['classPath'] === $package->getPackagePath() . 'NodeTypes/'
108+
) {
109+
$namespace = $autoloadConfiguration['namespace'];
110+
break;
111+
}
112+
}
113+
114+
if ($namespace === null) {
115+
$this->outputLine('<error>No PSR4-NodeTypes namespace for the NodeTypes folder is registered via composer</error>');
116+
$this->quit(1);
117+
}
118+
92119
$contentRepository = $this->contentRepositoryRegistry->get(ContentRepositoryId::fromString($crId));
93120
$nodeTypeManager = $contentRepository->getNodeTypeManager();
94121
$nodeTypes = $nodeTypeManager->getNodeTypes(false);
@@ -111,7 +138,7 @@ public function buildCommand(string $packageKey, string $crId = 'default'): void
111138
$nodeTypeObjectFile->fileContent
112139
);
113140

114-
$this->outputLine(' - ' . $specification->nodeTypeName . '/' . $specification->className);
141+
$this->outputLine(' - ' . $specification->nodeTypeName . ' -> ' . $specification->className);
115142
}
116143
}
117144
}

0 commit comments

Comments
 (0)