function DatabaseDataCollector::getData

Overrides DrupalDataCollectorInterface::getData

File

webprofiler/src/DataCollector/DatabaseDataCollector.php, line 202

Class

DatabaseDataCollector
Class DatabaseDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

public function getData() {
    $data = $this->data;
    $conn = Database::getConnection();
    foreach ($data['queries'] as &$query) {
        $explain = TRUE;
        $type = 'select';
        if (strpos($query['query'], 'INSERT') !== FALSE) {
            $explain = FALSE;
            $type = 'insert';
        }
        if (strpos($query['query'], 'UPDATE') !== FALSE) {
            $explain = FALSE;
            $type = 'update';
        }
        if (strpos($query['query'], 'CREATE') !== FALSE) {
            $explain = FALSE;
            $type = 'create';
        }
        if (strpos($query['query'], 'DELETE') !== FALSE) {
            $explain = FALSE;
            $type = 'delete';
        }
        $query['explain'] = $explain;
        $query['type'] = $type;
        $quoted = [];
        if (isset($query['args'])) {
            foreach ((array) $query['args'] as $key => $val) {
                $quoted[$key] = is_null($val) ? 'NULL' : $conn->quote($val);
            }
        }
        $query['query_args'] = strtr($query['query'], $quoted);
    }
    $data['query_highlight_threshold'] = $this->getQueryHighlightThreshold();
    return $data;
}