Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
RefererType | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
9 | |
100.00% |
1 / 1 |
render | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
9 |
1 | <?php |
2 | |
3 | namespace Drupal\visitors\Plugin\views\field; |
4 | |
5 | use Drupal\views\Attribute\ViewsField; |
6 | use Drupal\views\Plugin\views\field\FieldPluginBase; |
7 | |
8 | /** |
9 | * Field handler to display the hour (server) of the visit. |
10 | * |
11 | * @ingroup views_field_handlers |
12 | */ |
13 | #[ViewsField("visitors_referer_type")] |
14 | final class RefererType extends FieldPluginBase { |
15 | |
16 | /** |
17 | * {@inheritdoc} |
18 | */ |
19 | public function render($values) { |
20 | $type = $this->getValue($values); |
21 | switch ($type) { |
22 | case 'direct': |
23 | $value = $this->t('Direct Entry'); |
24 | break; |
25 | |
26 | case 'website': |
27 | $value = $this->t('Website'); |
28 | break; |
29 | |
30 | case 'internal': |
31 | $value = $this->t('Internal'); |
32 | break; |
33 | |
34 | case 'search_engine': |
35 | $value = $this->t('Search Engine'); |
36 | break; |
37 | |
38 | case 'spam': |
39 | $value = $this->t('Spam'); |
40 | break; |
41 | |
42 | case 'social_network': |
43 | $value = $this->t('Social Network'); |
44 | break; |
45 | |
46 | case 'ai_assistant': |
47 | $value = $this->t('AI Assistant'); |
48 | break; |
49 | |
50 | default: |
51 | $value = $this->t('Unknown'); |
52 | break; |
53 | } |
54 | |
55 | return $value; |
56 | } |
57 | |
58 | } |