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

RequestController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 40
rs 10
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 5 1
A track() 0 7 1
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