Skip to content

Commit 65801a9

Browse files
MichaelBraunerweaverryan
authored andcommitted
[make:entity] Fix error when API-Platform is installed.
1 parent 4f57a44 commit 65801a9

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

src/Maker/MakeEntity.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,32 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
114114

115115
$argument = $command->getDefinition()->getArgument('name');
116116
$question = $this->createEntityClassQuestion($argument->getDescription());
117-
$value = $io->askQuestion($question);
117+
$entityClassName = $io->askQuestion($question);
118118

119-
$input->setArgument('name', $value);
119+
$input->setArgument('name', $entityClassName);
120120

121121
if (
122122
!$input->getOption('api-resource') &&
123123
class_exists(ApiResource::class) &&
124-
!class_exists($this->generator->createClassNameDetails($value, 'Entity\\')->getFullName())
124+
!class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
125125
) {
126126
$description = $command->getDefinition()->getOption('api-resource')->getDescription();
127127
$question = new ConfirmationQuestion($description, false);
128-
$value = $io->askQuestion($question);
128+
$isApiResource = $io->askQuestion($question);
129129

130-
$input->setOption('api-resource', $value);
130+
$input->setOption('api-resource', $isApiResource);
131131
}
132132

133133
if (
134134
!$input->getOption('broadcast') &&
135135
class_exists(Broadcast::class) &&
136-
!class_exists($this->generator->createClassNameDetails($value, 'Entity\\')->getFullName())
136+
!class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
137137
) {
138138
$description = $command->getDefinition()->getOption('broadcast')->getDescription();
139139
$question = new ConfirmationQuestion($description, false);
140-
$value = $io->askQuestion($question);
140+
$isBroadcast = $io->askQuestion($question);
141141

142-
$input->setOption('broadcast', $value);
142+
$input->setOption('broadcast', $isBroadcast);
143143
}
144144
}
145145

tests/Maker/MakeEntityTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,5 +593,28 @@ public function getTestDetails()
593593
$this->assertStringContainsString(\PHP_VERSION_ID >= 80000 ? '#[Broadcast]' : '@Broadcast', $content);
594594
}),
595595
];
596+
597+
yield 'entity_new_with_api_and_broadcast_dependencies' => [MakerTestDetails::createTest(
598+
$this->getMakerInstance(MakeEntity::class),
599+
[
600+
// entity class name
601+
'User',
602+
// Mark the entity as not an API Platform resource
603+
'n',
604+
// Mark the entity as not broadcasted
605+
'n',
606+
// add not additional fields
607+
'',
608+
])
609+
->setRequiredPhpVersion(70200)
610+
->addExtraDependencies('api')
611+
->addExtraDependencies('ux-turbo-mercure')
612+
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
613+
->configureDatabase()
614+
->updateSchemaAfterCommand()
615+
->assert(function (string $output, string $directory) {
616+
$this->assertFileExists($directory.'/src/Entity/User.php');
617+
}),
618+
];
596619
}
597620
}

0 commit comments

Comments
 (0)