From a57670994706689eeb460473894eb193c8bccc22 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 14 Dec 2021 16:09:42 +0100 Subject: [PATCH] Use dependency injection within command Do not fetch service with legacy API, instead use proper Dependency Injection. Relates: #9532 --- .../Command/DestinationDataImportCommand.php | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Classes/Command/DestinationDataImportCommand.php b/Classes/Command/DestinationDataImportCommand.php index e3ae723..db22734 100644 --- a/Classes/Command/DestinationDataImportCommand.php +++ b/Classes/Command/DestinationDataImportCommand.php @@ -7,12 +7,22 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use Wrm\Events\Service\DestinationDataImportService; class DestinationDataImportCommand extends Command { + /** + * @var DestinationDataImportService + */ + private $destinationDataImportService; + + public function __construct( + DestinationDataImportService $destinationDataImportService + ) { + parent::__construct(); + $this->destinationDataImportService = $destinationDataImportService; + } + public function configure(): void { $this->setDescription('Import Destination Data Events'); @@ -48,13 +58,11 @@ class DestinationDataImportCommand extends Command { Bootstrap::initializeBackendAuthentication(); - return GeneralUtility::makeInstance(ObjectManager::class) - ->get(DestinationDataImportService::class) - ->import( - $input->getArgument('rest-experience'), - $input->getArgument('storage-pid'), - $input->getArgument('region-uid'), - $input->getArgument('files-folder') - ); + return $this->destinationDataImportService->import( + $input->getArgument('rest-experience'), + $input->getArgument('storage-pid'), + $input->getArgument('region-uid'), + $input->getArgument('files-folder') + ); } }