Skip to content

Commit f81ac80

Browse files
committed
Update route type handling in GenerateContextCommand based on PHP version
1 parent dee7395 commit f81ac80

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Command/GenerateContextCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,17 @@ private function updateRoutesConfig(string $context, OutputInterface $output): v
160160
$this->filesystem->dumpFile($routesPath, "");
161161
}
162162

163+
$routeType = version_compare(PHP_VERSION, '8.1.0', '>=') ? 'attribute' : 'annotation';
163164
$routesContent = file_get_contents($routesPath);
164165
$contextRoutes = <<<YAML
165166
{$context}_controllers:
166167
resource: ../../src/{$context}/Presenter/Controller/
167-
type: attribute
168-
prefix: /{$context}
169-
168+
type: {$routeType}
170169
YAML;
171170

172171
if (!str_contains($routesContent, $context . '_controllers:')) {
173172
$this->filesystem->appendToFile($routesPath, "\n" . $contextRoutes);
174-
$output->writeln(sprintf('<info>Configuration des routes mise à jour pour %s</info>', $context));
173+
$output->writeln(sprintf('<info>Configuration des routes mise à jour pour %s (type: %s)</info>', $context, $routeType));
175174
}
176175
}
177176
}

0 commit comments

Comments
 (0)