MonthDate.php 1015 Bytes
Newer Older
1
2
<?php

3
namespace Drupal\views\Plugin\views\argument;
4
5
6

/**
 * Argument handler for a month (MM)
7
 *
8
 * @ViewsArgument("date_month")
9
 */
10
class MonthDate extends Date {
11

12
13
14
15
16
17
18
19
20
21
  /**
   * {@inheritdoc}
   */
  protected $format = 'F';

  /**
   * {@inheritdoc}
   */
  protected $argFormat = 'm';

22
23
24
  /**
   * Provide a link to the next level of the view
   */
25
  public function summaryName($data) {
26
    $month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
27
    return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC');
28
29
30
31
32
  }

  /**
   * Provide a link to the next level of the view
   */
33
  public function title() {
34
    $month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
35
    return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
36
37
  }

38
  public function summaryArgument($data) {
39
40
41
    // Make sure the argument contains leading zeroes.
    return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
  }
42

43
}