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

3
namespace Views\node\Plugin\views\argument;
4 5

use Drupal\Core\Annotation\Plugin;
6
use Drupal\views\Plugin\views\argument\Date;
7 8 9 10 11 12 13

/**
 * Argument handler for a year (CCYY)
 */

/**
 * @Plugin(
14 15
 *   id = "node_created_year",
 *   module = "node"
dawehner's avatar
dawehner committed
16
 * )
17 18 19 20 21 22 23 24 25 26 27
 */
class CreatedYear extends Date {
  /**
   * Constructor implementation
   */
  function construct() {
    parent::construct();
    $this->arg_format = 'Y';
    $this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field");
  }
}