class RequestDataCollector in Devel 8.2
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector
- 8 webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector
- 4.x webprofiler/src/DataCollector/RequestDataCollector.php \Drupal\webprofiler\DataCollector\RequestDataCollector
Integrate _content into the RequestDataCollector
Hierarchy
- class \Drupal\webprofiler\DataCollector\RequestDataCollector extends \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector implements DrupalDataCollectorInterface uses StringTranslationTrait
Expanded class hierarchy of RequestDataCollector
1 file declares its use of RequestDataCollector
- AccessManagerWrapper.php in webprofiler/
src/ Access/ AccessManagerWrapper.php
1 string reference to 'RequestDataCollector'
- webprofiler.services.yml in webprofiler/
webprofiler.services.yml - webprofiler/webprofiler.services.yml
1 service uses RequestDataCollector
File
- webprofiler/
src/ DataCollector/ RequestDataCollector.php, line 15
Namespace
Drupal\webprofiler\DataCollectorView source
class RequestDataCollector extends BaseRequestDataCollector implements DrupalDataCollectorInterface {
use StringTranslationTrait, DrupalDataCollectorTrait;
/**
* @var \Drupal\Core\Controller\ControllerResolverInterface
*/
private $controllerResolver;
/**
* @var array
*/
private $accessCheck;
/**
* @param \Drupal\Core\Controller\ControllerResolverInterface $controllerResolver
*/
public function __construct(ControllerResolverInterface $controllerResolver) {
parent::__construct();
$this->controllerResolver = $controllerResolver;
$this->accessCheck = [];
}
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = NULL) {
parent::collect($request, $response, $exception);
$controller = $this->controllerResolver
->getController($request);
$this->data['controller'] = $this
->getMethodData($controller[0], $controller[1]);
$this->data['access_check'] = $this->accessCheck;
}
/**
* @param $service_id
* @param $callable
* @param \Symfony\Component\HttpFoundation\Request $request
*
*/
public function addAccessCheck($service_id, $callable, Request $request) {
$this->accessCheck[$request
->getPathInfo()][] = [
'service_id' => $service_id,
'callable' => $this
->getMethodData($callable[0], $callable[1]),
];
}
/**
* {@inheritdoc}
*/
public function getTitle() {
return $this
->t('Request');
}
/**
* {@inheritdoc}
*/
public function getPanelSummary() {
return $this->data['status_code'] . ' ' . $this->data['status_text'];
}
/**
* {@inheritdoc}
*/
public function getIcon() {
return 'iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAQAAADYBBcfAAACvElEQVR42tVTbUhTYRTerDCnKVoUUr/KCZmypA9Koet0bXNLJ5XazDJ/WFaCUY0pExRZXxYiJgsxWWjkaL+yK+po1gjyR2QfmqWxtBmaBtqWGnabT++c11Fu4l/P4VzOPc95zoHznsNZodIbLDdRcKnc1Bu8DAK45ZsOnykQNMopsNooLxCknb0cDq5vml9FtHiIgpBR0R6iihYyFMTDt2Lg56ObPkI6TMGXSof1EV67IqCwisJSWliFAG/E0CfFIiebdNypcxi/1zgyFiIiZ3sJQr0RQx5frLa6k7SOKRo3oMFNR5t62h2rttKXEOKFqDCxtXNmmBokO2KKTlp3IdWuT2dYRNGKwEXEBCcL172G5FG0aIxC0kR9PBTVH1kkwQn+IqJnCE33EalVzT9GJQS1tAdD3CKicJYFrxqx7W2ejCEdZy1FiC5tZxHhLJKOZaRdQJAyV/YAvDliySALHxmxR4Hqe2iwvaOR/CEuZYJFSgYhVbZRkA8KGdEktrqnqra90NndCdkt77fjIHIhexOrfO6O3bbbOj/rqu5IptgyR3sU93QbOYhquZK4MCDp0Ina/PLsu5JvbCTRaapUdUmIV/RzoMdsk/0hWRNdAvKOmvqlN0drsJbJf1P4YsQ5lGrJeuosiOUgbOC8cto3LfOXTdVd7BqZsQKbse+0jUL6WPcesqs4MNSUTQAxGjwFiC8m3yzmqwHJBWYKBJ9WNqW/dHkpU/osch1Yj5RJfXPfSEe/2UPsN490NPfZG5CKyJmcV5ayHyzy7BMqsXfuHhGK/cjAIeSpR92gehR55D8TcQhDEKJwytBJ4fr4NULvrEM8NszfJPyxDoHYAQ1oPCWmIX4gifmDS/DV2DKeb25FHWr76yEG7/9L4YFPeiQQ4/8LkgJ8Et+NncTCsYqzXAEXa7CWdPZzGWdlyV+vST0JanfPvwAAAABJRU5ErkJggg==';
}
/**
* @return array|string
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDataCollectorInterface:: |
public | function | 1 | |
DrupalDataCollectorInterface:: |
public | function | Returns the libraries needed in detail panel. | 2 |
DrupalDataCollectorInterface:: |
public | function | Returns the name of the collector. | 21 |
DrupalDataCollectorInterface:: |
public | function | Returns true if this datacollector has a detail panel. | 2 |
RequestDataCollector:: |
private | property | ||
RequestDataCollector:: |
private | property | ||
RequestDataCollector:: |
public | function | ||
RequestDataCollector:: |
public | function | Collects data for the given Request and Response. | |
RequestDataCollector:: |
public | function |
Overrides DrupalDataCollectorInterface:: |
|
RequestDataCollector:: |
public | function |
Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface:: |
|
RequestDataCollector:: |
public | function |
Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface:: |
|
RequestDataCollector:: |
public | function |
Returns the datacollector title. Overrides DrupalDataCollectorInterface:: |
|
RequestDataCollector:: |
public | function | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |