Initial commit
This commit is contained in:
34
src/Command/RenderCommand.php
Normal file
34
src/Command/RenderCommand.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user