Inheritance: extends Symfony\Component\Console\Helper\Helper, implements Symfony\Component\Console\Input\InputAwareInterface
示例#1
0
 public function initialize(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if ($command instanceof TemplateFeature) {
         $input = $event->getInput();
         $template = $input->getOption('template');
         if ($template) {
             $validTemplates = $this->templateHelper->getNamesForDomain($command->getTemplateDomain());
             if (!in_array($template, $validTemplates, true)) {
                 throw new \InvalidArgumentException(sprintf('The specified template "%s" does not exist, try one of: ' . PHP_EOL . ' - %s', $template, implode(PHP_EOL . ' - ', $validTemplates)));
             }
         }
     }
 }
示例#2
0
 /**
  * @test
  */
 public function binds_and_renders()
 {
     $this->input->setOption('test-option', 'test-option');
     $this->template->getName()->willReturn('test/foobar')->shouldBeCalled();
     $this->template->bind(['author' => 'cslucano'])->shouldBeCalled();
     $this->template->render()->willReturn('foo')->shouldBeCalled();
     $this->helper->registerTemplate($this->template->reveal());
     $res = $this->helper->bindAndRender(['author' => 'cslucano'], 'test', 'foobar');
     $this->assertEquals('foo', $res);
 }