public static function FillPdf::checkLocalServiceEndpoint in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x src/Component/Utility/FillPdf.php \Drupal\fillpdf\Component\Utility\FillPdf::checkLocalServiceEndpoint()
 
Tests the connection to a local service endpoint.
Parameters
\GuzzleHttp\Client $http_client: The Guzzle http client.
\Drupal\Core\Config\Config $fillpdf_config: FillPDF configuration object.
Return value
bool TRUE if a connection could be established, otherwise FALSE.
3 calls to FillPdf::checkLocalServiceEndpoint()
- FillPdfSettingsForm::validateForm in src/
Form/ FillPdfSettingsForm.php  - Form validation handler.
 - PdfParseTest::testParseLocalService in tests/
src/ Functional/ PdfParseTest.php  - Tests PDF population using local service.
 - PdfPopulationTest::testMergeLocalService in tests/
src/ Functional/ PdfPopulationTest.php  - Tests PDF population using local service.
 
File
- src/
Component/ Utility/ FillPdf.php, line 106  
Class
- FillPdf
 - Class FillPdf.
 
Namespace
Drupal\fillpdf\Component\UtilityCode
public static function checkLocalServiceEndpoint(Client $http_client, Config $fillpdf_config) {
  try {
    $response = $http_client
      ->get($fillpdf_config
      ->get('local_service_endpoint'));
  } catch (Exception $exception) {
    // If any thing goes wrong, just fail the check.
    return FALSE;
  }
  // Only consider the check passed if we actually get a 200 from the API.
  return $response
    ->getStatusCode() === 200;
}