Completed
Push — 15-request_grouping ( 76e174...2ffca1 )
by Frédéric G.
02:55
created

RequestController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Drupal\mongodb_watchdog\Controller;
4
5
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
6
use Drupal\mongodb_watchdog\Logger;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
8
9
/**
10
 * Implements the controller for the request events page.
11
 */
12
class RequestController implements ContainerInjectionInterface {
13
14
  /**
15
   * The mongodb_watchdog logger, to access events.
16
   *
17
   * @var \Drupal\mongodb_watchdog\Logger
18
   */
19
  protected $watchdog;
20
21
  public function __construct(Logger $watchdog) {
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
22
    $this->watchdog = $watchdog;
23
  }
24
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public static function create(ContainerInterface $container) {
29
    /** @var \Drupal\mongodb_watchdog\Logger $watchdog */
30
    $watchdog = $container->get('mongodb.logger');
31
    return new static($watchdog);
32
  }
33
34
  /**
35
   * Controller.
36
   *
37
   * @param string $unique_id
38
   *   The unique request id from mod_unique_id.
39
   *
40
   * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
41
   *   A render array.
42
   */
43
  public function track($unique_id) {
44
    $events = $this->watchdog->requestEvents($unique_id);
45
    ksm($events);
46
    return [
47
      '#markup' => $unique_id,
48
    ];
49
  }
50
51
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
52