protected function execute(InputInterface $input, OutputInterface $output) { $this->getContainer()->get('doctrine')->getManager()->getConnection()->prepare('SET FOREIGN_KEY_CHECKS = 0;')->execute(); $result = parent::execute($input, $output); $this->getContainer()->get('doctrine')->getManager()->getConnection()->prepare('SET FOREIGN_KEY_CHECKS = 1;')->execute(); return $result; }
/** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $input->setOption('append', true); $this->fixFixturesPath($input); $this->fixtureOption($input); parent::execute($input, $output); }
/** * Executes the current command. * * This method is not abstract because you can use this class * as a concrete class. In this case, instead of defining the * execute() method, you set the code to execute by passing * a Closure to the setCode() method. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|int null or 0 if everything went fine, or an error code * * @throws \LogicException When this abstract method is not implemented * * @see setCode() */ protected function execute(InputInterface $input, OutputInterface $output) { if (empty($this->databaseFilePath) || $input->getOption('no-booster')) { parent::execute($input, $output); return 0; } /** * Same code as parent implementation */ $dirOrFile = $input->getOption('fixtures'); $paths = []; if ($dirOrFile) { $paths = is_array($dirOrFile) ? $dirOrFile : [$dirOrFile]; } else { foreach ($this->kernel->getBundles() as $bundle) { $paths[] = $bundle->getPath() . '/DataFixtures/ORM'; } } /** * In order to take in account the kernel as well (same fixtures, * different kernel/different schema, make the tests crash */ $paths[] = get_class($this->kernel); sort($paths, SORT_STRING); $backupFileName = sys_get_temp_dir() . '/' . sha1(serialize($paths)) . '.backup.database'; if (file_exists($backupFileName)) { copy($backupFileName, $this->databaseFilePath); return 0; } parent::execute($input, $output); /** * If new file has been created, copy it with generated hash value. Now * this backup will be reusable for next iterations */ if (file_exists($this->databaseFilePath)) { copy($this->databaseFilePath, $backupFileName); } return 0; }