1 | <?php |
||
15 | class EventController { |
||
16 | |||
17 | /** |
||
18 | * The length of the absolute home URL. |
||
19 | * |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $baseLength; |
||
23 | |||
24 | /** |
||
25 | * The date.formatter service. |
||
26 | * |
||
27 | * @var \Drupal\Core\Datetime\DateFormatterInterface |
||
28 | */ |
||
29 | protected $dateFormatter; |
||
30 | |||
31 | /** |
||
32 | * The absolute path to the site home. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $front; |
||
37 | |||
38 | /** |
||
39 | * An instance cache for user accounts, which are used in a loop. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $userCache = []; |
||
44 | |||
45 | /** |
||
46 | * The MongoDB logger service, to load events. |
||
47 | * |
||
48 | * @var \Drupal\mongodb_watchdog\Logger |
||
49 | */ |
||
50 | protected $watchdog; |
||
51 | |||
52 | /** |
||
53 | * EventController constructor. |
||
54 | * |
||
55 | * @param \Drupal\Core\Config\ConfigFactoryInterface $config |
||
56 | * The config.factory service. |
||
57 | * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter |
||
58 | * The core data.formatter service. |
||
59 | * @param \Drupal\mongodb_watchdog\Logger $watchdog |
||
60 | * The MongoDB logger service, to load events. |
||
61 | */ |
||
62 | public function __construct(ConfigFactoryInterface $config, |
||
71 | |||
72 | /** |
||
73 | * Provide a table rows representation of an event occurrence. |
||
74 | * |
||
75 | * @param \Drupal\mongodb_watchdog\EventTemplate $template |
||
76 | * The template for which the occurrence exists. |
||
77 | * @param \Drupal\mongodb_watchdog\Event $event |
||
78 | * The event occurrence to represent. |
||
79 | * |
||
80 | * @return array |
||
81 | * A render array. |
||
82 | */ |
||
83 | public function asTableRow(EventTemplate $template, Event $event) { |
||
105 | |||
106 | /** |
||
107 | * Load MongoDB watchdog events for a given event template. |
||
108 | * |
||
109 | * @param \Drupal\mongodb_watchdog\EventTemplate $template |
||
110 | * The template for which to find events. |
||
111 | * @param string $first_id |
||
112 | * The string representation of the first event to match. |
||
113 | * @param int $limit |
||
114 | * The limit on the number of objects to return. |
||
115 | * |
||
116 | * @return \MongoDB\Driver\Cursor |
||
117 | * A cursor to the event occurrences. |
||
118 | */ |
||
119 | public function find(EventTemplate $template, $first_id, $limit) { |
||
135 | |||
136 | /** |
||
137 | * Return the number of event occurrences for a given template. |
||
138 | * |
||
139 | * @param \Drupal\mongodb_watchdog\EventTemplate $template |
||
140 | * The template for which to count events. |
||
141 | * |
||
142 | * @return int |
||
143 | * The number of occurrences. |
||
144 | */ |
||
145 | public function count(EventTemplate $template) { |
||
150 | |||
151 | } |
||
152 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: