-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRandomdataCommandController.php
More file actions
executable file
·85 lines (79 loc) · 3.01 KB
/
RandomdataCommandController.php
File metadata and controls
executable file
·85 lines (79 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace WIND\Randomdata\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Faker\Factory;
use TYPO3\CMS\Extbase\Exception;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use Symfony\Component\Console\Command\Command;
use WIND\Randomdata\Service\RandomdataService;
use WIND\Randomdata\Exception\ProviderException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use WIND\Randomdata\Exception\DataHandlerException;
use Symfony\Component\Console\Output\OutputInterface;
use WIND\Randomdata\Exception\UnknownActionException;
use WIND\Randomdata\Exception\PidNotFoundForItemException;
use WIND\Randomdata\Exception\TableNotFoundInTcaException;
use WIND\Randomdata\Exception\CountNotFoundForItemException;
use WIND\Randomdata\Exception\FieldsNotFoundForItemException;
use TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException;
use WIND\Randomdata\Exception\ConfigurationFileNotFoundException;
use TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException;
/**
* Randomdata Command Controller
*/
class RandomdataCommandController extends Command
{
/**
* Configure
*
* @return void
*/
public function configure()
{
$this->setDescription('Generate random data');
$this->setHelp('This command allows your to create random data or replace existing data with random data');
$this->addArgument('file', InputArgument::REQUIRED, 'YAML configuration file');
$this->addArgument('locale', InputArgument::OPTIONAL, 'Locale used to generate data', Factory::DEFAULT_LOCALE);
}
/**
* Execute
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws \RuntimeException
* @throws ConfigurationFileNotFoundException
* @throws FieldsNotFoundForItemException
* @throws PidNotFoundForItemException
* @throws TableNotFoundInTcaException
* @throws UnknownActionException
* @throws CountNotFoundForItemException
* @throws DataHandlerException
* @throws ProviderException
* @throws InvalidSlotException
* @throws InvalidSlotReturnException
* @throws Exception
*/
public function execute(InputInterface $input, OutputInterface $output): int
{
Bootstrap::initializeBackendAuthentication();
/** @var RandomdataService $randomdataService */
$randomdataService = GeneralUtility::makeInstance(RandomdataService::class);
$randomdataService->generate($input->getArgument('file'), $input->getArgument('locale'), $output);
return 0;
}
}