You are here

public function Template::getTemplatesObject in GatherContent 7.3

Fetch projects from GatherContent.

Return value

array Associative array of projects.

File

includes/Template.inc, line 84

Class

Template
Class Template.

Namespace

GatherContent

Code

public function getTemplatesObject($project_id) {
  $templates = array();
  try {
    $response = $this->client
      ->get('/templates?project_id=' . $project_id);
    if ($response
      ->getStatusCode() === 200) {
      $data = json_decode($response
        ->getBody());
      foreach ($data->data as $template) {
        $templates[$template->id] = $template;
      }
    }
  } catch (\Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    watchdog('gathercontent', $e
      ->getMessage(), array(), WATCHDOG_ERROR);
  }
  return $templates;
}