Created
June 18, 2014 22:43
-
-
Save mishak87/7c1b560e3f5a4ab208fc to your computer and use it in GitHub Desktop.
With <3 for Hosiplan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Kdyby\Doctrine\Console; | |
use Kdyby; | |
use Kdyby\Doctrine\BatchImportException; | |
use Kdyby\Doctrine\Helpers; | |
use Rixxi; | |
use Symfony; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
class DbalBatchFile extends Symfony\Component\Console\Command\Command | |
{ | |
protected function configure() | |
{ | |
$this->setName('dbal:batch-file'); | |
$this->setAliases(['dbal:batch:file']); | |
$this->addArgument('file', InputArgument::REQUIRED, 'SQL batch file to run'); | |
$this->setDescription('Self explanatory...'); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
if (!is_readable($file = $input->getArgument('file'))) { | |
$output->writeLn(sprintf("<error>Cannot read file '%s'.</error>", $file)); | |
return 1; | |
} | |
$emHelper = $this->getHelper('em'); | |
/* @var $em \Doctrine\ORM\EntityManager */ | |
$em = $emHelper->getEntityManager(); | |
Helpers::loadFromFile($em->getConnection(), $file); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment