Commit e1a70f73 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

add command to get json export for a given massive game

parent 7c1d8f51
<?php
namespace MagicWordBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class GetMassiveJSONCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('magicword:massive-json')
->setDescription('get json export for a given massive game')
->addArgument('massiveId', InputArgument::REQUIRED)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getEntityManager('default');
$exportManager = $this->getContainer()->get('mw_manager.export');
$massiveId = $input->getArgument('massiveId');
$massive = $em->getRepository('MagicWordBundle:GameType\Massive')->find($massiveId);
if ($massive) {
$output->writeln('<info>#########################</info>');
$array = $exportManager->exportGame($massive);
$output->writeln(json_encode($array));
$output->writeln('<info>#########################</info>');
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment