|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\MakerBundle\Maker;
|
13 | 13 |
|
14 |
| -use ApiPlatform\Core\Annotation\ApiResource; |
| 14 | +use ApiPlatform\Core\Annotation\ApiResource as LegacyApiResource; |
| 15 | +use ApiPlatform\Metadata\ApiResource; |
15 | 16 | use Doctrine\DBAL\Types\Type;
|
16 | 17 | use Symfony\Bundle\MakerBundle\ConsoleStyle;
|
17 | 18 | use Symfony\Bundle\MakerBundle\DependencyBuilder;
|
@@ -133,7 +134,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
|
133 | 134 |
|
134 | 135 | if (
|
135 | 136 | !$input->getOption('api-resource') &&
|
136 |
| - class_exists(ApiResource::class) && |
| 137 | + (class_exists(ApiResource::class) || class_exists(LegacyApiResource::class)) && |
137 | 138 | !class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
|
138 | 139 | ) {
|
139 | 140 | $description = $command->getDefinition()->getOption('api-resource')->getDescription();
|
@@ -317,10 +318,17 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
|
317 | 318 | public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void
|
318 | 319 | {
|
319 | 320 | if (null !== $input && $input->getOption('api-resource')) {
|
320 |
| - $dependencies->addClassDependency( |
321 |
| - ApiResource::class, |
322 |
| - 'api' |
323 |
| - ); |
| 321 | + if (class_exists(ApiResource::class)) { |
| 322 | + $dependencies->addClassDependency( |
| 323 | + ApiResource::class, |
| 324 | + 'api' |
| 325 | + ); |
| 326 | + } else { |
| 327 | + $dependencies->addClassDependency( |
| 328 | + LegacyApiResource::class, |
| 329 | + 'api' |
| 330 | + ); |
| 331 | + } |
324 | 332 | }
|
325 | 333 |
|
326 | 334 | if (null !== $input && $input->getOption('broadcast')) {
|
|
0 commit comments