You are here

public function Template::getTemplate in GatherContent 8

Same name and namespace in other branches
  1. 8.3 src/DAO/Template.php \Drupal\gathercontent\DAO\Template::getTemplate()

TBD.

Parameters

int $template_id: ID of template.

Return value

object Object of template

File

src/DAO/Template.php, line 114

Class

Template
Class Template.

Namespace

Drupal\gathercontent\DAO

Code

public function getTemplate($template_id) {
  $template = NULL;
  try {
    $response = $this->client
      ->get('/templates/' . $template_id);
    if ($response
      ->getStatusCode() === 200) {
      $data = json_decode($response
        ->getBody());
      $template = $data->data;
    }
  } catch (\Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    \Drupal::logger('gathercontent')
      ->error($e
      ->getMessage(), array());
  }
  return $template;
}