Gush\Helper\TemplateHelper::getNamesForDomain PHP Method

getNamesForDomain() public method

Returns the names of registered templates in the given domain.
public getNamesForDomain ( string $domain ) : array
$domain string Return template names for this domain
return array Array of template name strings
    public function getNamesForDomain($domain)
    {
        if (!isset($this->templates[$domain])) {
            throw new \InvalidArgumentException(sprintf('Unknown template domain "%s"', $domain));
        }
        return array_keys($this->templates[$domain]);
    }

Usage Example

Example #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)));
             }
         }
     }
 }
All Usage Examples Of Gush\Helper\TemplateHelper::getNamesForDomain