35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace NoccyLabs\Bundle\GdLabelBundle\Command;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
class RenderCommand extends ContainerAwareCommand
|
|
{
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName("label:render");
|
|
$this->setDescription("Render a label");
|
|
$this->addOption("define", "D", InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, "key=value pairs to pass to use in the template");
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$renderer = $this->getContainer()->get("gdlabel.renderer");
|
|
|
|
$params = [];
|
|
foreach ($input->getOption("define") as $opt) {
|
|
list ($key, $value) = explode("=", $opt, 2);
|
|
$params[$key] = $value;
|
|
}
|
|
|
|
echo $renderer->renderToData("@InventoryBundle/Resources/labels/inventoryreceipt.xml", $params);
|
|
}
|
|
|
|
}
|