You are here

class DayDate in Drupal 10

Same name in this branch
  1. 10 core/modules/views/src/Plugin/views/argument/DayDate.php \Drupal\views\Plugin\views\argument\DayDate
  2. 10 core/modules/datetime/src/Plugin/views/argument/DayDate.php \Drupal\datetime\Plugin\views\argument\DayDate
Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/argument/DayDate.php \Drupal\views\Plugin\views\argument\DayDate
  2. 9 core/modules/views/src/Plugin/views/argument/DayDate.php \Drupal\views\Plugin\views\argument\DayDate

Argument handler for a day (DD)

Plugin annotation

@ViewsArgument("date_day");

Hierarchy

  • class \Drupal\views\Plugin\views\argument\Formula extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase

Expanded class hierarchy of DayDate

File

core/modules/views/src/Plugin/views/argument/DayDate.php, line 10

Namespace

Drupal\views\Plugin\views\argument
View source
class DayDate extends Date {

  /**
   * {@inheritdoc}
   */
  protected $format = 'j';

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

  /**
   * {@inheritdoc}
   */
  public function summaryName($data) {
    $day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);

    // strtotime respects server timezone, so we need to set the time fixed as utc time
    return $this->dateFormatter
      ->format(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
  }

  /**
   * {@inheritdoc}
   */
  public function title() {
    $day = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
    return $this->dateFormatter
      ->format(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
  }
  public function summaryArgument($data) {

    // Make sure the argument contains leading zeroes.
    return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Date::$dateFormatter protected property The date formatter service.
Date::$option_name public property
Date::$routeMatch protected property The route match.
Date::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
Date::defaultArgumentForm public function Add an option to set the default value to the current date.
Date::getDefaultArgument public function Set the empty argument value to the current date, formatted appropriately for this argument.
Date::getFormula public function Overrides Formula::getFormula
Date::getSortName public function
Date::__construct public function Constructs a new Date instance. 1
DayDate::$argFormat protected property The date format used in the query. Overrides Date::$argFormat
DayDate::$format protected property The date format used in the title. Overrides Date::$format
DayDate::summaryArgument public function
DayDate::summaryName public function
DayDate::title public function
Formula::$formula public property
Formula::init public function
Formula::query public function Build the query based upon the formula.
Formula::summaryQuery protected function Build the summary query based on a formula.