Find template.

@param string $key

@return TemplateInterface

@throws NotFoundException
332640
public function find($key)
    {
        $template = $this->getCollection()->get($key);

        if ($template !== null) {
            return $template;
        }

        throw new NotFoundException("Media template $key not found.");
    }
1045654
public function getTemplate($key, $language_id)
    {
        if ($template = EmailTemplateTranslation::findOne([
            'template_id' => EmailTemplate::getIdByKey($key),
            'language_id' => $language_id
        ])) {
            return Template::buildTemplate($template);
        }

        return null;
    }
1088502
protected function findModelByRouteKey($key)
    {
        return $this->model->where($this->model->getRouteKeyName(), $key)->first();
    }
1207279
public function findByKey(string $key) {
        if (!$this->root) {
            return null;
        }

        return $this->root->findByKey($key);
    }
663196
private function getTemplate($templateKey)
    {
        if (!$templateKey) {
            return null;
        }

        $templateManager = $this->getContainer()->get('phlexible_media_template.template_manager');

        return $templateManager->getCollection()->get($templateKey);
    }
1251222
public function getWritable($key): WritableTranslationValueInterface
    {
        if (!$this->has($key)) {
            throw new TranslationNotFoundException($key, $this);
        }

        return $this->translationBuffer[$key];
    }
543759
private function fetchTemplate($template)
    {
        $resolver = $this->getResolver();
        $content  = $resolver->resolve($template);

        if (! $content) {
            throw new Exception\TemplateNotFoundException('Template by name "' . $template . '" not found');
        }

        return $content;
    }
977605
public function template($template = null)
    {
        if (is_null($template)) {
            return $this->template;
        } else {
            $this->template = $template;
        }
    }
570608
public function getRequired(string $key)
    {
        if (!$this->has($key)) {
            throw new \InvalidArgumentException('Element ' . $key . ' does not exist');
        }

        return $this->collection[$this->keyMap[strtolower($key)]];
    }
31812
protected function hasTemplateOption($key)
    {
        if ($this->templateOptions === null) {
            $this->templateOptions = $this->buildTemplateOptions();
        }

        return isset($this->templateOptions[$key]);
    }
261462
protected function get($key)
    {
        $this->checkForNonEmptyKey($key);
        if (!$this->settingsHaveBeenRetrieved) {
            $this->retrieveSettings();
        }
        if (!isset($this->cachedSettings[$key])) {
            return null;
        }

        return $this->cachedSettings[$key];
    }
584221
public function load(string $key): CompanyInterface
    {
        if (!$this->has($key)) {
            throw new NotFoundException('the company with key "' . $key . '" was not found');
        }

        $company = $this->companies[$key];

        return new Company(
            $key,
            $company['name'],
            $company['brandname']
        );
    }
397053
private function findTemplate($template)
    {
        $logicalName = (string) $template;

        if (isset($this->cache[$logicalName])) {
            return $this->cache[$logicalName];
        }

        $template = $this->templateNameParser->parse($template);
        $file = $this->templateLocator->locate($template);

        return $this->cache[$logicalName] = $file;
    }
850623
public function getTemplate($name)
    {
        if (!array_key_exists($name, $this->getTemplates())) {
            throw new \Exception('Template not found');
        }

        return $this->getTemplates()[$name];
    }
804930
public function find($template)
    {
        is_array($template) and $template = array_filter($template, 'is_string');
        if ((! is_string($template) && ! is_array($template)) || empty($template)) {
            throw new InvalidArgumentException(
                'Template name must be a string or an array of strings.'
            );
        }
        if (is_array($template)) {
            return $this->findMany($template);
        }
        $parse = $this->parseName($template);
        if ($parse['dir']) {
            return $this->findInDir($parse['dir'], $parse['file']);
        }

        return $parse['file'] ? $this->scanFor($parse['file']) : false;
    }
1049638
public function get($key)
    {
        if (!$this->has($key)) {
            throw new Exception(sprintf(Exception::SETTING_KEY_NOT_EXISTS, $key));
        }

        return $this->getCachedSettings()->offsetGet($key);
    }
1076987
public function findTemplate(string $index): Template
    {
        $template = $this->getByIndex($index);

        if ($template instanceof Template) {
            return $template;
        }

        // Oops, template not found
        throw TemplateNotFoundException::create($index);
    }