@@ 17-39 (lines=23) @@ | ||
14 | use Symfony\Component\Console\Input\InputInterface; |
|
15 | use Symfony\Component\Console\Output\OutputInterface; |
|
16 | ||
17 | class ExportPlaylistCommand extends ContainerAwareCommand |
|
18 | { |
|
19 | protected function configure() |
|
20 | { |
|
21 | $this |
|
22 | // the name of the command (the part after "bin/console") |
|
23 | ->setName('ticket:export-playlist') |
|
24 | // the short description shown while running "php bin/console list" |
|
25 | ->setDescription('Export playlist') |
|
26 | // the full command description shown when running the command with |
|
27 | // the "--help" option |
|
28 | ->setHelp("Export playlist to CSV file") |
|
29 | ->addArgument('file', InputArgument::REQUIRED, 'Name of the CSV file.'); |
|
30 | } |
|
31 | ||
32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
33 | { |
|
34 | $file = $input->getArgument('file'); |
|
35 | $exporter = new PlaylistExporter($this->getContainer()->get('database_connection')); |
|
36 | $exporter->exportToFile($file); |
|
37 | $output->writeln("Wrote playlist to $file"); |
|
38 | } |
|
39 | } |
|
40 |
@@ 17-41 (lines=25) @@ | ||
14 | use Symfony\Component\Console\Input\InputInterface; |
|
15 | use Symfony\Component\Console\Output\OutputInterface; |
|
16 | ||
17 | class LoadSongsCommand extends ContainerAwareCommand |
|
18 | { |
|
19 | protected function configure() |
|
20 | { |
|
21 | $this |
|
22 | // the name of the command (the part after "bin/console") |
|
23 | ->setName('ticket:load-songs') |
|
24 | // the short description shown while running "php bin/console list" |
|
25 | ->setDescription('Load songlist') |
|
26 | // the full command description shown when running the command with |
|
27 | // the "--help" option |
|
28 | ->setHelp("Load songlist from XLS file") |
|
29 | ->addArgument('file', InputArgument::REQUIRED, 'Name of the CSV file.'); |
|
30 | } |
|
31 | ||
32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
33 | { |
|
34 | ||
35 | $loader = new SongLoader(); |
|
36 | ||
37 | $file = $input->getArgument('file'); |
|
38 | $songsLoaded = $loader->run($file, $this->getContainer()->get('database_connection')); |
|
39 | $output->writeln("Loaded $songsLoaded songs from $file"); |
|
40 | } |
|
41 | } |
|
42 |