Skip to content

Commit

Permalink
Another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and jordisala1991 committed May 6, 2023
1 parent fe5fd24 commit 8d93092
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Admin/AbstractAdmin.php
Expand Up @@ -799,6 +799,13 @@ final public function getFormBuilder(): FormBuilderInterface
*/
final public function defineFormBuilder(FormBuilderInterface $formBuilder): void
{
if (!$this->hasSubject()) {
throw new \LogicException(sprintf(
'Admin "%s" has no subject.',
static::class
));
}

$mapper = new FormMapper($this->getFormContractor(), $formBuilder, $this);

$this->configureFormFields($mapper);
Expand Down
3 changes: 3 additions & 0 deletions src/Command/ExplainAdminCommand.php
Expand Up @@ -45,6 +45,9 @@ public function execute(InputInterface $input, OutputInterface $output): int
{
$admin = $this->pool->getInstance($input->getArgument('admin'));

// Some admin methods might require a subject.
$admin->setSubject($admin->getNewInstance());

$output->writeln('<comment>AdminBundle Information</comment>');
$output->writeln(sprintf('<info>% -20s</info> : %s', 'id', $admin->getCode()));
$output->writeln(sprintf('<info>% -20s</info> : %s', 'Admin', $admin::class));
Expand Down

0 comments on commit 8d93092

Please sign in to comment.