CreatedWeek.php 951 Bytes
Newer Older
1
2
<?php

3
4
5
6
7
/**
 * @file
 * Definition of Views\node\Plugin\views\argument\CreatedWeek.
 */

8
namespace Views\node\Plugin\views\argument;
9
10

use Drupal\Core\Annotation\Plugin;
11
use Drupal\views\Plugin\views\argument\Date;
12
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
13
14
15

/**
 * Argument handler for a week.
16
 *
17
 * @Plugin(
18
19
 *   id = "node_created_week",
 *   module = "node"
dawehner's avatar
dawehner committed
20
 * )
21
22
 */
class CreatedWeek extends Date {
23

24
  /**
25
   * Constructs a CreatedWeek object.
26
   */
27
28
29
  public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
    parent::__construct($configuration, $plugin_id, $discovery);

30
    $this->arg_format = 'w';
31
    $this->formula = views_date_sql_extract('WEEK', "***table***.$this->realField");
32
33
34
35
36
37
38
39
40
  }

  /**
   * Provide a link to the next level of the view
   */
  function summary_name($data) {
    $created = $data->{$this->name_alias};
    return t('Week @week', array('@week' => $created));
  }
41

42
}