You are here

protected function TemplateProcessor::loadTemplate in YAML Content 8.2

Load the template designated through context values.

Return value

mixed The loaded template structure.

1 call to TemplateProcessor::loadTemplate()
TemplateProcessor::preprocess in src/Plugin/YamlContent/TemplateProcessor.php
Pre-process import data and manipulate it prior to content creation.

File

src/Plugin/YamlContent/TemplateProcessor.php, line 68

Class

TemplateProcessor
A content processor plugin supporting content templates in defined content.

Namespace

Drupal\yaml_content\Plugin\YamlContent

Code

protected function loadTemplate() {
  $context = $this
    ->getContextValues();
  $template_path = drupal_get_path('module', $context['module']) . '/content';
  $template_name = $context['template'] . '.template.yml';

  // @todo Handle failure to load file.
  $template_data = $this->decoder
    ->decode(file_get_contents($template_path . '/' . $template_name));
  return $template_data;
}