Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
42 / 42 |
|
4.76% |
1 / 21 |
|
1.23% |
1 / 81 |
|
100.00% |
2 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LoadBaseDataCommand | |
100.00% |
42 / 42 |
|
4.76% |
1 / 21 |
|
1.23% |
1 / 81 |
|
100.00% |
2 / 2 |
29.09 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
41 / 41 |
|
0.00% |
0 / 20 |
|
0.00% |
0 / 80 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Command; |
| 4 | |
| 5 | use App\Application\UseCase\MaintainWord; |
| 6 | use App\Dto\Command\MaintainWordCommand; |
| 7 | use App\Dto\Csv\CsvQualifier; |
| 8 | use App\Dto\Csv\CsvSubject; |
| 9 | use App\Enum\Lang; |
| 10 | use App\Enum\OffenseLevel; |
| 11 | use App\Enum\QualifierPosition; |
| 12 | use App\Enum\WordGender; |
| 13 | use App\Enum\WordStatus; |
| 14 | use App\Service\Data\WordSluggerInterface; |
| 15 | use League\Csv\Reader; |
| 16 | use Symfony\Component\Console\Attribute\AsCommand; |
| 17 | use Symfony\Component\Console\Attribute\Option; |
| 18 | use Symfony\Component\Console\Command\Command; |
| 19 | use Symfony\Component\Console\Output\OutputInterface; |
| 20 | use Symfony\Component\DependencyInjection\Attribute\Autowire; |
| 21 | |
| 22 | /** |
| 23 | * @author Wilhelm Zwertvaegher |
| 24 | */ |
| 25 | #[AsCommand(name: 'app:load-base-data')] |
| 26 | class LoadBaseDataCommand extends Command |
| 27 | { |
| 28 | public function __construct( |
| 29 | private readonly MaintainWord $maintainWord, |
| 30 | private readonly WordSluggerInterface $wordSlugger, |
| 31 | #[Autowire('%base_data.subject_csv%')] |
| 32 | private readonly string $subjectCsvPath, |
| 33 | #[Autowire('%base_data.qualifier_csv%')] |
| 34 | private readonly string $qualifierCsvPath, |
| 35 | ) { |
| 36 | parent::__construct(); |
| 37 | } |
| 38 | |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 47 | // TODO : implement data deletion before loading |
| 48 | } |
| 49 | |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 98 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 28 | public function __construct( |
| 29 | private readonly MaintainWord $maintainWord, |
| 30 | private readonly WordSluggerInterface $wordSlugger, |
| 31 | #[Autowire('%base_data.subject_csv%')] |
| 32 | private readonly string $subjectCsvPath, |
| 33 | #[Autowire('%base_data.qualifier_csv%')] |
| 34 | private readonly string $qualifierCsvPath, |
| 35 | ) { |
| 36 | parent::__construct(); |
| 37 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |
| 3 | namespace App\Command; |
| 4 | |
| 5 | use App\Application\UseCase\MaintainWord; |
| 6 | use App\Dto\Command\MaintainWordCommand; |
| 7 | use App\Dto\Csv\CsvQualifier; |
| 8 | use App\Dto\Csv\CsvSubject; |
| 9 | use App\Enum\Lang; |
| 10 | use App\Enum\OffenseLevel; |
| 11 | use App\Enum\QualifierPosition; |
| 12 | use App\Enum\WordGender; |
| 13 | use App\Enum\WordStatus; |
| 14 | use App\Service\Data\WordSluggerInterface; |
| 15 | use League\Csv\Reader; |
| 16 | use Symfony\Component\Console\Attribute\AsCommand; |
| 17 | use Symfony\Component\Console\Attribute\Option; |
| 18 | use Symfony\Component\Console\Command\Command; |
| 19 | use Symfony\Component\Console\Output\OutputInterface; |
| 20 | use Symfony\Component\DependencyInjection\Attribute\Autowire; |
| 21 | |
| 22 | /** |
| 23 | * @author Wilhelm Zwertvaegher |
| 24 | */ |
| 25 | #[AsCommand(name: 'app:load-base-data')] |
| 26 | class LoadBaseDataCommand extends Command |
| 27 | { |
| 28 | public function __construct( |
| 29 | private readonly MaintainWord $maintainWord, |
| 30 | private readonly WordSluggerInterface $wordSlugger, |
| 31 | #[Autowire('%base_data.subject_csv%')] |
| 32 | private readonly string $subjectCsvPath, |
| 33 | #[Autowire('%base_data.qualifier_csv%')] |
| 34 | private readonly string $qualifierCsvPath, |
| 35 | ) { |
| 36 | parent::__construct(); |
| 37 | } |
| 38 | |
| 39 | public function __invoke( |
| 40 | OutputInterface $output, |
| 41 | #[Option('Append the data fixtures instead of deleting all data from the database first.')] bool $append = false, |
| 42 | ): int { |
| 43 | $output->writeln('Loading base data...'); |
| 44 | $output->writeln('Loading subjects...'); |
| 45 | |
| 46 | if (!$append) { |
| 47 | // TODO : implement data deletion before loading |
| 48 | } |
| 49 | |
| 50 | $reader = Reader::from($this->subjectCsvPath); |
| 51 | $reader->setHeaderOffset(0); |
| 52 | $subjectsSlugs = []; |
| 53 | |
| 54 | foreach ($reader->getRecordsAsObject(CsvSubject::class) as $record) { |
| 55 | $fullWordDto = ($this->maintainWord)( |
| 56 | new MaintainWordCommand( |
| 57 | label: trim($record->label), |
| 58 | gender: WordGender::fromString($record->gender), |
| 59 | lang: Lang::FR, |
| 60 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 61 | status: WordStatus::APPROVED, |
| 62 | asSubject: true, |
| 63 | handleDeletion: false |
| 64 | ) |
| 65 | ); |
| 66 | $output->writeln("Created subject {$fullWordDto->label} with word_id {$fullWordDto->id}"); |
| 67 | $subjectsSlugs[] = $fullWordDto->slug; |
| 68 | } |
| 69 | |
| 70 | $output->writeln('Loading qualifiers...'); |
| 71 | |
| 72 | $reader = Reader::from($this->qualifierCsvPath); |
| 73 | $reader->setHeaderOffset(0); |
| 74 | |
| 75 | foreach ($reader->getRecordsAsObject(CsvQualifier::class) as $record) { |
| 76 | $slug = $this->wordSlugger->slug($record->label); |
| 77 | |
| 78 | $fullWordDto = ($this->maintainWord)( |
| 79 | new MaintainWordCommand( |
| 80 | label: trim($record->label), |
| 81 | gender: WordGender::fromString($record->gender ?? 'AUTO'), |
| 82 | lang: Lang::FR, |
| 83 | offenseLevel: OffenseLevel::fromString($record->offenseLevel ?? 'MEDIUM'), |
| 84 | status: WordStatus::APPROVED, |
| 85 | asSubject: in_array($slug, $subjectsSlugs), |
| 86 | asQualifier: true, |
| 87 | qualifierPosition: QualifierPosition::from(trim($record->position)) ?? 'after', |
| 88 | handleDeletion: false |
| 89 | ) |
| 90 | ); |
| 91 | $output->writeln("Created qualifier {$fullWordDto->label} with id {$fullWordDto->id}"); |
| 92 | } |
| 93 | |
| 94 | $output->writeln('Base data loaded successfully.'); |
| 95 | |
| 96 | return Command::SUCCESS; |
| 97 | } |