Skip to content

Commit

Permalink
[7-15] 公演情報のシリアライズ確認用テストコマンド
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Dec 28, 2015
1 parent b665387 commit 2611a24
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/lists/ch07/07-15.txt
@@ -0,0 +1,32 @@
<?php
namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('cs:test')
->setDescription('test')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$em = $container->get('doctrine')->getManager();
$repository = $em->getRepository('AppBundle:Concert');
$concertList = $repository->findAll();

$serializer = $container->get('jms_serializer');
$json = $serializer->serialize($concertList, 'json');

dump($json);
}
}
32 changes: 32 additions & 0 deletions src/AppBundle/Command/TestCommand.php
@@ -0,0 +1,32 @@
<?php
namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('cs:test')
->setDescription('test')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$em = $container->get('doctrine')->getManager();
$repository = $em->getRepository('AppBundle:Concert');
$concertList = $repository->findAll();

$serializer = $container->get('jms_serializer');
$json = $serializer->serialize($concertList, 'json');

dump($json);
}
}

0 comments on commit 2611a24

Please sign in to comment.