getNamesForDomain() публичный Метод

Returns the names of registered templates in the given domain.
public getNamesForDomain ( string $domain ) : array
$domain string Return template names for this domain
Результат array Array of template name strings
Пример #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
  * @dataProvider provideGetNamesForDomain
  */
 public function gets_names_for_domain($templateRegistrations, $domain, $expectedNames, $exception = false)
 {
     foreach ($templateRegistrations as $templateRegistration) {
         $template = $this->prophesize('Gush\\Template\\TemplateInterface');
         $template->getName()->willReturn($templateRegistration);
         $this->helper->registerTemplate($template->reveal());
     }
     if ($exception) {
         $this->setExpectedException('InvalidArgumentException', 'Unknown template domain');
     }
     $res = $this->helper->getNamesForDomain($domain);
     $this->assertEquals($expectedNames, $res);
 }