Coverage index

src/Plugin/views/argument/RefererKeyword.php

Lines: 0.00%

LineHitsSource
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Drupal\visitors\Plugin\views\argument;
6
7
use Drupal\views\Attribute\ViewsArgument;
8
use Drupal\views\Plugin\views\argument\StringArgument;
9
10
/**
11
 * Filters a referrer keyword, including keywords that were not stored.
12
 *
13
 * The argument "not-defined" matches an empty or NULL keyword. That is the
14
 * label Matomo uses when a search engine sends no query.
15
 */
16
#[ViewsArgument('visitors_referer_keyword')]
17
class RefererKeyword extends StringArgument {
18
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function query($group_by = FALSE) {
230
    if ($this->argument === 'not-defined') {
240
      $this->ensureMyTable();
250
      $field = "{$this->tableAlias}.{$this->realField}";
260
      $this->query->addWhereExpression(
270
        0,
280
        "($field = '' OR $field IS NULL)"
290
      );
300
      return;
31
    }
320
    parent::query($group_by);
33
  }
34
35
}