CreatedYear.php 485 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 14 15 16 17 18 19 20 21 22 23 24 25

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

/**
 * @Plugin(
 *   plugin_id = "node_created_year"
 */
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");
  }
}