CreatedYear.php 758 Bytes
Newer Older
1 2
<?php

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

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 year (CCYY)
16
 *
17
 * @Plugin(
18 19
 *   id = "node_created_year",
 *   module = "node"
dawehner's avatar
dawehner committed
20
 * )
21 22
 */
class CreatedYear extends Date {
23

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

30
    $this->arg_format = 'Y';
31
    $this->formula = views_date_sql_extract('YEAR', "***table***.$this->realField");
32
  }
33

34
}