/**
  * Extract the token from the request.
  *
  * @param RequestInterface $request
  *   The request.
  *
  * @return string
  *   The extracted token.
  */
 protected function extractToken(RequestInterface $request)
 {
     $plugin_definition = $this->getPluginDefinition();
     $options = $plugin_definition['options'];
     $key_name = !empty($options['paramName']) ? $options['paramName'] : 'access_token';
     // Access token may be on the request, or in the headers.
     $input = $request->getParsedInput();
     return empty($input[$key_name]) ? $request->getHeaders()->get($key_name)->getValueString() : $input[$key_name];
 }
 /**
  * {@inheritdoc}
  */
 public function getVersionFromRequest()
 {
     $version =& drupal_static(__METHOD__);
     if (isset($version)) {
         return $version;
     }
     $path = $this->request->getPath(FALSE);
     list($resource_name, $version) = static::getPageArguments($path);
     if (preg_match('/^v\\d+(\\.\\d+)?$/', $version)) {
         $version = $this->parseVersionString($version, $resource_name);
         return $version;
     }
     // If there is no version in the URL check the header.
     if ($version_string = $this->request->getHeaders()->get('x-api-version')->getValueString()) {
         $version = $this->parseVersionString($version_string, $resource_name);
         return $version;
     }
     // If there is no version negotiation information return the latest version.
     $version = $this->getResourceLastVersion($resource_name);
     return $version;
 }
 /**
  * Detects whether the script is running from a command line environment.
  *
  * @param RequestInterface $request.
  *   The request.
  *
  * @return bool
  *   TRUE if a command line environment is detected. FALSE otherwise.
  */
 protected function isCli(RequestInterface $request)
 {
     // Needed to detect if run-tests.sh is running the tests.
     $cli = $request->getHeaders()->get('User-Agent')->getValueString() == 'Drupal command line';
     return $cli || drupal_is_cli();
 }