class MonthDate in Drupal 10
Same name in this branch
- 10 core/modules/views/src/Plugin/views/argument/MonthDate.php \Drupal\views\Plugin\views\argument\MonthDate
- 10 core/modules/datetime/src/Plugin/views/argument/MonthDate.php \Drupal\datetime\Plugin\views\argument\MonthDate
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/argument/MonthDate.php \Drupal\views\Plugin\views\argument\MonthDate
- 9 core/modules/views/src/Plugin/views/argument/MonthDate.php \Drupal\views\Plugin\views\argument\MonthDate
Argument handler for a month (MM)
Plugin annotation
@ViewsArgument("date_month");
Hierarchy
- class \Drupal\views\Plugin\views\argument\Formula extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase
- class \Drupal\views\Plugin\views\argument\Date implements ContainerFactoryPluginInterface
- class \Drupal\views\Plugin\views\argument\MonthDate
- class \Drupal\views\Plugin\views\argument\Date implements ContainerFactoryPluginInterface
Expanded class hierarchy of MonthDate
File
- core/
modules/ views/ src/ Plugin/ views/ argument/ MonthDate.php, line 10
Namespace
Drupal\views\Plugin\views\argumentView source
class MonthDate extends Date {
/**
* {@inheritdoc}
*/
protected $format = 'F';
/**
* {@inheritdoc}
*/
protected $argFormat = 'm';
/**
* {@inheritdoc}
*/
public function summaryName($data) {
$month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
try {
return $this->dateFormatter
->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
} catch (\InvalidArgumentException $e) {
return parent::summaryName($data);
}
}
/**
* {@inheritdoc}
*/
public function title() {
$month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
try {
return $this->dateFormatter
->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
} catch (\InvalidArgumentException $e) {
return parent::title();
}
}
public function summaryArgument($data) {
// Make sure the argument contains leading zeroes.
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Date:: |
protected | property | The date formatter service. | |
Date:: |
public | property | ||
Date:: |
protected | property | The route match. | |
Date:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
Date:: |
public | function | Add an option to set the default value to the current date. | |
Date:: |
public | function | Set the empty argument value to the current date, formatted appropriately for this argument. | |
Date:: |
public | function |
Overrides Formula:: |
|
Date:: |
public | function | ||
Date:: |
public | function | Constructs a new Date instance. | 1 |
Formula:: |
public | property | ||
Formula:: |
public | function | ||
Formula:: |
public | function | Build the query based upon the formula. | |
Formula:: |
protected | function | Build the summary query based on a formula. | |
MonthDate:: |
protected | property |
The date format used in the query. Overrides Date:: |
|
MonthDate:: |
protected | property |
The date format used in the title. Overrides Date:: |
|
MonthDate:: |
public | function | ||
MonthDate:: |
public | function | ||
MonthDate:: |
public | function |