Skip to content

Commit 094a458

Browse files
committed
TASK: Check composer for registered psr4 nodetypes namespace
1 parent 38bce59 commit 094a458

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Classes/Command/NodetypeObjectsCommandController.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Neos\Flow\Cli\CommandController;
1010
use Neos\Flow\Core\Bootstrap;
1111
use Neos\Flow\Package\FlowPackageInterface;
12+
use Neos\Flow\Package\GenericPackage;
1213
use Neos\Flow\Package\PackageManager;
1314
use Neos\Utility\Files;
1415
use Neos\Utility\Unicode\Functions as UnicodeFunctions;
@@ -92,6 +93,31 @@ public function buildCommand(string $packageKey): void
9293
$this->output->outputLine($packageKey . " is not a Flow package");
9394
$this->quit(1);
9495
}
96+
if (!$package instanceof GenericPackage) {
97+
$this->output->outputLine($packageKey . " is not a Generic package");
98+
$this->quit(1);
99+
}
100+
101+
/**
102+
* @var array<int, array{namespace:string, classPath:string, mappingType:string}> $autoloadConfigurations
103+
*/
104+
$autoloadConfigurations = $package->getFlattenedAutoloadConfiguration();
105+
$namespace = null;
106+
foreach ($autoloadConfigurations as $autoloadConfiguration) {
107+
if (
108+
$autoloadConfiguration['mappingType'] === 'psr-4'
109+
&& str_ends_with($autoloadConfiguration['namespace'], '\\NodeTypes\\')
110+
&& $autoloadConfiguration['classPath'] === $package->getPackagePath() . 'NodeTypes/'
111+
) {
112+
$namespace = $autoloadConfiguration['namespace'];
113+
break;
114+
}
115+
}
116+
117+
if ($namespace === null) {
118+
$this->outputLine('<error>No PSR4-NodeTypes namespace for the NodeTypes folder is registered via composer</error>');
119+
$this->quit(1);
120+
}
95121

96122
$nodeTypes = $this->nodeTypeManager->getNodeTypes(false);
97123
foreach ($nodeTypes as $nodeType) {
@@ -113,7 +139,7 @@ public function buildCommand(string $packageKey): void
113139
$nodeTypeObjectFile->fileContent
114140
);
115141

116-
$this->outputLine(' - ' . $specification->nodeTypeName . '/' . $specification->className);
142+
$this->outputLine(' - ' . $specification->nodeTypeName . ' -> ' . $specification->className);
117143
}
118144
}
119145
}

0 commit comments

Comments
 (0)