diff --git a/src/Commands/field/FieldCreateCommand.php b/src/Commands/field/FieldCreateCommand.php index 3839bacbec..34814317b0 100644 --- a/src/Commands/field/FieldCreateCommand.php +++ b/src/Commands/field/FieldCreateCommand.php @@ -26,7 +26,9 @@ use Drush\Event\FieldCreateFieldConfigValuesEvent; use Drush\Event\FieldCreateFieldStorageConfigValuesEvent; use Drush\Event\FieldCreateInputOptionsEvent; +use Drush\Log\SuccessInterface; use Psr\EventDispatcher\EventDispatcherInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Completion\CompletionInput; @@ -69,6 +71,7 @@ public function __construct( private readonly ModuleHandlerInterface $moduleHandler, private readonly EntityFieldManagerInterface $entityFieldManager, private readonly EventDispatcherInterface $eventDispatcher, + private readonly LoggerInterface $logger, private readonly ?ContentTranslationManagerInterface $contentTranslationManager = null, ) { parent::__construct(); @@ -493,7 +496,8 @@ protected function getEntityDisplay(string $context): ?EntityDisplayInterface protected function logResult(FieldConfigInterface $field): void { - $this->io()->success( + assert($this->logger instanceof SuccessInterface); + $this->logger->success( sprintf( "Successfully created field '%s' on %s type with bundle '%s'", $field->get('field_name'), @@ -512,7 +516,7 @@ protected function logResult(FieldConfigInterface $field): void ]; if ($this->moduleHandler->moduleExists('field_ui')) { - $this->io()->success( + $this->logger->success( dt('Further customisation can be done through the edit form.', [ '%editForm' => Url::fromRoute($routeName, $routeParams)->setAbsolute(true)->toString(), ]),