-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDoctrineSchemaFixturesLoadCommand.php
More file actions
55 lines (41 loc) · 1.66 KB
/
Copy pathDoctrineSchemaFixturesLoadCommand.php
File metadata and controls
55 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
namespace Macpaw\PostgresSchemaBundle\Command\Doctrine;
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand;
use Doctrine\DBAL\Connection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
class DoctrineSchemaFixturesLoadCommand extends AbstractNestingDoctrineSchemaCommand
{
public function __construct(
LoadDataFixturesDoctrineCommand $parentCommand,
Connection $connection,
) {
parent::__construct('doctrine:schema:fixtures:load', $parentCommand, $connection);
}
protected function execute(
InputInterface $input,
OutputInterface $output,
): int {
try {
$schema = $this->getSchemaFromInput($input);
if (!$this->isSchemaExist($schema)) {
$output->writeln("<error>Schema '{$schema}' doesn't exist</error>");
return Command::FAILURE;
}
$this->switchToSchema($schema);
$output->writeln("<info>Load fixtures for '{$schema}'...</info>");
$returnCode = $this->runCommand('doctrine:fixtures:load', $input, $output);
if ($returnCode !== Command::SUCCESS) {
$output->writeln("<error>Fixtures load failed with return code: {$returnCode}</error>");
return Command::FAILURE;
}
} catch (Throwable $e) {
$output->writeln("<error>Error executing fixtures load: {$e->getMessage()}</error>");
return Command::FAILURE;
}
return Command::SUCCESS;
}
}