You are here

public function RequestDataCollector::getData in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector::getData()
  2. 8 webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector::getData()
  3. 8.2 webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector::getData()

Return value

array|string

Overrides DrupalDataCollectorInterface::getData

File

webprofiler/src/DataCollector/RequestDataCollector.php, line 87

Class

RequestDataCollector
Integrate _content into the RequestDataCollector.

Namespace

Drupal\webprofiler\DataCollector

Code

public function getData() {

  // Drupal 8.5+ uses Symfony 3.4.x that changes the way the Request data are
  // collected. Data is altered with \Symfony\Component\HttpKernel\DataCollector\DataCollector::cloneVar.
  // The stored data (of type \Symfony\Component\VarDumper\Cloner\Data) is
  // suitable to be converted to a string by a Dumper (\Symfony\Component\VarDumper\Dumper\DataDumperInterface).
  // In our implementation however we need that data as an array, to be later
  // converted in a json response by a REST endpoint. We need to refactor the
  // whole way Web Profiler works to allow that. At the moment we just
  // retrieve the raw Data value and do some string manipulation to clean the
  // output a bit.
  $data = $this->data
    ->getValue(TRUE);
  unset($data['request_attributes']['_route_params']);
  unset($data['request_attributes']['_access_result']);
  $route_object = [];
  foreach ($data['request_attributes']['_route_object'] as $key => $result) {
    $key = str_replace("\0", '', $key);
    $key = str_replace('Symfony\\Component\\Routing\\Route', 'Symfony\\Component\\Routing\\Route::', $key);
    $route_object[$key] = $result;
  }
  $data['request_attributes']['_route_object'] = $route_object;
  return $data;
}