You are here

public function LogController::log in TacJS 8.5

Store proof of consent.

Parameters

int $service_key: Unique ID of the service.

Return value

array Empty Array.

Throws

\Exception

1 string reference to 'LogController::log'
tacjs.routing.yml in ./tacjs.routing.yml
tacjs.routing.yml

File

src/Controller/LogController.php, line 39

Class

LogController

Namespace

Drupal\tacjs\Controller

Code

public function log($service_key) {
  try {
    $this->connection
      ->insert('tacjslog')
      ->fields([
      'timestamp' => \Drupal::time()
        ->getCurrentTime(),
      'ip_address' => \Drupal::request()
        ->getClientIp(),
      'services_allowed' => $service_key,
    ])
      ->execute();
  } catch (\Exception $e) {
    throw $e;
  }
  return new JsonResponse([
    'timestamp' => \Drupal::time()
      ->getCurrentTime(),
    'ip_address' => \Drupal::request()
      ->getClientIp(),
    'services_allowed' => $service_key,
  ]);
}