You are here

public function DrupalGatherContentClient::templateGet in GatherContent 8.5

File

src/DrupalGatherContentClient.php, line 200

Class

DrupalGatherContentClient
Extends the GatherContentClient class with Drupal specific functionality.

Namespace

Drupal\gathercontent

Code

public function templateGet($templateId) {
  $template = parent::templateGet($templateId);
  if (empty($template['related'])) {
    return $template;
  }

  // Add the ID as the array key.
  $groups = $template['related']->structure->groups;
  foreach ($groups as $group) {
    $group->fields = $this
      ->reKeyArray($group->fields, 'id');
  }
  $template['related']->structure->groups = $this
    ->reKeyArray($groups, 'id');
  return $template;
}