‪TYPO3CMS  ‪main
DatasetImportCommand.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Console\Attribute\AsCommand;
21 use Symfony\Component\Console\Command\Command;
22 use Symfony\Component\Console\Input\InputArgument;
23 use Symfony\Component\Console\Input\InputInterface;
24 use Symfony\Component\Console\Output\OutputInterface;
25 use Symfony\Component\Console\Style\SymfonyStyle;
26 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\DataSet;
27 
31 #[AsCommand('dataset:import', 'Import Dataset')]
32 class ‪DatasetImportCommand extends Command
33 {
34  protected function ‪configure(): void
35  {
36  $this->addArgument('path', InputArgument::REQUIRED, 'Path to CSV dataset to import');
37  }
38 
39  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
40  {
41  if (!class_exists(DataSet::class)) {
42  $io = new SymfonyStyle($input, ‪$output);
43  $io->getErrorStyle()->error('Missing typo3/testing-framework dependency.');
44  return Command::FAILURE;
45  }
46  DataSet::import($input->getArgument('path'));
47  return Command::SUCCESS;
48  }
49 
50 }
‪TYPO3Tests\DatasetImport\Command\DatasetImportCommand\configure
‪configure()
Definition: DatasetImportCommand.php:34
‪$output
‪$output
Definition: annotationChecker.php:114
‪TYPO3Tests\DatasetImport\Command
Definition: DatasetImportCommand.php:18
‪TYPO3Tests\DatasetImport\Command\DatasetImportCommand
Definition: DatasetImportCommand.php:33
‪TYPO3Tests\DatasetImport\Command\DatasetImportCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: DatasetImportCommand.php:39