You are here

private function Base::readInput in DRD Agent 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Agent/Action/Base.php \Drupal\drd_agent\Agent\Action\Base::readInput()

Read and decode the input from the POST request.

Parameters

bool $debugMode: Whether we operate in debug mode.

string $message: Optional warning to output in watchdog.

Return value

array The decoded input.

Throws

\Exception

2 calls to Base::readInput()
Base::authorizeBySecret in src/Agent/Action/Base.php
Callback to authorize a DRD instance with a given secret.
Base::run in src/Agent/Action/Base.php
Main callback to execute an action.

File

src/Agent/Action/Base.php, line 182

Class

Base
Base class for Remote DRD Action Code.

Namespace

Drupal\drd_agent\Agent\Action

Code

private function readInput($debugMode, $message = NULL) : array {
  $this
    ->setDebugMode($debugMode);
  if (isset($message)) {
    $this
      ->watchdog($message, array(), 4);
  }
  $raw_input = file_get_contents('php://input');
  if (empty($raw_input)) {
    throw new RuntimeException('Can not read input');
  }
  $input = json_decode(base64_decode($raw_input), TRUE);
  if (!is_array($input) || empty($input)) {
    throw new RuntimeException('Input is empty');
  }
  return $input;
}