CreatedFullDate.php 1.22 KB
Newer Older
1 2
<?php

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

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 full date (CCYYMMDD)
16
 *
17
 * @Plugin(
18 19
 *   id = "node_created_fulldate",
 *   module = "node"
20 21 22
 * )
 */
class CreatedFullDate extends Date {
23

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

30 31
    $this->format = 'F j, Y';
    $this->arg_format = 'Ymd';
32
    $this->formula = views_date_sql_format($this->arg_format, "***table***.$this->realField");
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  }

  /**
   * Provide a link to the next level of the view
   */
  function summary_name($data) {
    $created = $data->{$this->name_alias};
    return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
  }

  /**
   * Provide a link to the next level of the view
   */
  function title() {
    return format_date(strtotime($this->argument . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
  }
49

50
}