*/ class FixturesDumpCommand extends AbstractPropelCommand { /** * Default fixtures directory. * @var string */ private $defaultFixturesDir = 'app/propel/fixtures'; /** * @see Command */ protected function configure() { $this ->setDescription('Dump data from database into YAML fixtures file.') ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') ->setHelp(<<propel:fixtures:dump dumps data from database into YAML fixtures file. php app/console propel:fixtures:dump The --connection parameter allows you to change the connection to use. The default connection is the active connection (propel.dbal.default_connection). EOT ) ->setName('propel:fixtures:dump') ; } /** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { $this->writeSection($output, '[Propel] You are running the command: propel:fixtures:dump'); list($name, $defaultConfig) = $this->getConnection($input, $output); $path = realpath($this->getApplication()->getKernel()->getRootDir() . '/../') . '/' . $this->defaultFixturesDir; $filename = $path . '/fixtures_' . time() . '.yml'; $dumper = new YamlDataDumper($this->getApplication()->getKernel()->getRootDir()); try { $dumper->dump($filename, $name); } catch (\Exception $e) { $this->writeSection($output, array( '[Propel] Exception', '', $e->getMessage()), 'fg=white;bg=red'); return false; } $output->writeln(''); $output->writeln(sprintf('>> File+ %s', $filename)); return true; } }