You are here

public function ContentHubEntityExportController::isRequestFromAcquiaContentHub in Acquia Content Hub 8

Resolves whether the current request comes from Acquia Content Hub or not.

Return value

bool TRUE if request comes from Content Hub, FALSE otherwise.

1 call to ContentHubEntityExportController::isRequestFromAcquiaContentHub()
ContentHubEntityExportController::getDrupalEntities in src/Controller/ContentHubEntityExportController.php
Collects all Drupal Entities that needs to be sent to Hub.

File

src/Controller/ContentHubEntityExportController.php, line 272

Class

ContentHubEntityExportController
Controller for Content Hub Export Entities using bulk upload.

Namespace

Drupal\acquia_contenthub\Controller

Code

public function isRequestFromAcquiaContentHub() {
  $request = Request::createFromGlobals();

  // This function already sits behind an access check to confirm that the
  // request for CDF came from Content Hub, but just in case that access is
  // opened to authenticated users or during development, we are using a
  // condition to prevent false tracking of entities as exported.
  $headers = array_map('current', $request->headers
    ->all());
  if (isset($headers['user-agent']) && strpos($headers['user-agent'], 'Go-http-client') !== FALSE) {
    return TRUE;
  }
  return FALSE;
}