You are here

public function ApiMarkup::getNextForm in FormAssembly 8

Get the HTML for a FormAssembly next path using returned tfa_next value.

Parameters

string $tfa_next: The urlencoded parameter from FormAssembly.

Return value

string HTML returned by the query

File

src/ApiMarkup.php, line 172

Class

ApiMarkup
Service class for FormAssembly API: Fetches form markup.

Namespace

Drupal\formassembly

Code

public function getNextForm($tfa_next) {
  $queryPath = urldecode($tfa_next);

  // Make FA rest call and return form markup.
  $url = $this
    ->getUrl('/rest/' . $queryPath);
  $request = $this->httpClient
    ->get($url
    ->toString(TRUE)
    ->getGeneratedUrl());

  // Guzzle throws an Exception on http 400/500 errors.
  // Ensure we have a 200.
  if ($request
    ->getStatusCode() != 200) {
    throw new \UnexpectedValueException('Http return code 200 expected.  Code ' . $request
      ->getStatusCode() . ' received.');
  }
  return $request
    ->getBody()
    ->getContents();
}