1515 */
1616
1717use Faker \Factory ;
18- use TYPO3 \CMS \Extbase \Mvc \Controller \CommandController ;
18+ use Symfony \Component \Console \Command \Command ;
19+ use Symfony \Component \Console \Input \InputArgument ;
20+ use Symfony \Component \Console \Input \InputInterface ;
21+ use Symfony \Component \Console \Output \OutputInterface ;
22+ use TYPO3 \CMS \Core \Core \Bootstrap ;
23+ use TYPO3 \CMS \Core \Utility \GeneralUtility ;
24+ use TYPO3 \CMS \Extbase \Object \ObjectManager ;
1925use TYPO3 \CMS \Extbase \SignalSlot \Exception \InvalidSlotException ;
2026use TYPO3 \CMS \Extbase \SignalSlot \Exception \InvalidSlotReturnException ;
21- use \ WIND \Randomdata \Exception \ConfigurationFileNotFoundException ;
22- use \ WIND \Randomdata \Exception \FieldsNotFoundForItemException ;
23- use \ WIND \Randomdata \Exception \PidNotFoundForItemException ;
24- use \ WIND \Randomdata \Exception \TableNotFoundInTcaException ;
25- use \ WIND \Randomdata \Exception \UnknownActionException ;
26- use \ WIND \Randomdata \Exception \CountNotFoundForItemException ;
27- use \ WIND \Randomdata \Exception \DataHandlerException ;
28- use \ WIND \Randomdata \Exception \ProviderException ;
27+ use WIND \Randomdata \Exception \ConfigurationFileNotFoundException ;
28+ use WIND \Randomdata \Exception \FieldsNotFoundForItemException ;
29+ use WIND \Randomdata \Exception \PidNotFoundForItemException ;
30+ use WIND \Randomdata \Exception \TableNotFoundInTcaException ;
31+ use WIND \Randomdata \Exception \UnknownActionException ;
32+ use WIND \Randomdata \Exception \CountNotFoundForItemException ;
33+ use WIND \Randomdata \Exception \DataHandlerException ;
34+ use WIND \Randomdata \Exception \ProviderException ;
2935use WIND \Randomdata \Service \RandomdataService ;
3036
3137/**
3238 * Randomdata Command Controller
3339 */
34- class RandomdataCommandController extends CommandController
40+ class RandomdataCommandController extends Command
3541{
3642 /**
37- * Generate random data
43+ * Configure
3844 *
39- * @param string $file YAML configuration file
40- * @param string $locale Locale used to generate data
41- * @param bool $quiet Only output errors if true
4245 * @return void
46+ */
47+ public function configure ()
48+ {
49+ $ this ->setDescription ('Generate random data ' );
50+ $ this ->setHelp ('This command allows your to create random data or replace existing data with random data ' );
51+ $ this ->addArgument ('file ' , InputArgument::REQUIRED , 'YAML configuration file ' );
52+ $ this ->addArgument ('locale ' , InputArgument::OPTIONAL , 'Locale used to generate data ' , Factory::DEFAULT_LOCALE );
53+ }
54+
55+ /**
56+ * Execute
57+ *
58+ * @param InputInterface $input
59+ * @param OutputInterface $output
60+ * @return int|void|null
4361 * @throws \RuntimeException
4462 * @throws ConfigurationFileNotFoundException
4563 * @throws FieldsNotFoundForItemException
@@ -52,10 +70,13 @@ class RandomdataCommandController extends CommandController
5270 * @throws InvalidSlotException
5371 * @throws InvalidSlotReturnException
5472 */
55- public function generateCommand ( $ file , $ locale = Factory:: DEFAULT_LOCALE , $ quiet = false )
73+ public function execute ( InputInterface $ input , OutputInterface $ output )
5674 {
75+ Bootstrap::initializeBackendAuthentication ();
76+ /** @var ObjectManager $objectManager */
77+ $ objectManager = GeneralUtility::makeInstance (ObjectManager::class);
5778 /** @var RandomdataService $randomdataService */
58- $ randomdataService = $ this -> objectManager ->get (RandomdataService::class);
59- $ randomdataService ->generate ($ file , $ locale , $ quiet );
79+ $ randomdataService = $ objectManager ->get (RandomdataService::class);
80+ $ randomdataService ->generate ($ input -> getArgument ( ' file ' ) , $ input -> getArgument ( ' locale ' ) , $ output );
6081 }
6182}
0 commit comments