class Date

Same name in this branch
  1. main core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date
  2. main core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date
  3. main core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date
  4. main core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date
  5. main core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date
  6. main core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date
  7. main core/modules/datetime/src/Plugin/views/argument/Date.php \Drupal\datetime\Plugin\views\argument\Date
  8. main core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date
Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date
  2. 11.x core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date
  3. 11.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date
  4. 11.x core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date
  5. 11.x core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date
  6. 11.x core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date
  7. 11.x core/modules/datetime/src/Plugin/views/argument/Date.php \Drupal\datetime\Plugin\views\argument\Date
  8. 11.x core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date
  9. 10 core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date
  10. 10 core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date
  11. 10 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date
  12. 10 core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date
  13. 10 core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date
  14. 10 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date
  15. 10 core/modules/datetime/src/Plugin/views/argument/Date.php \Drupal\datetime\Plugin\views\argument\Date
  16. 10 core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date
  17. 9 core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date
  18. 9 core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date
  19. 9 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date
  20. 9 core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date
  21. 9 core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date
  22. 9 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date
  23. 9 core/modules/datetime/src/Plugin/views/argument/Date.php \Drupal\datetime\Plugin\views\argument\Date
  24. 9 core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date
  25. 8.9.x core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date
  26. 8.9.x core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date
  27. 8.9.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date
  28. 8.9.x core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date
  29. 8.9.x core/modules/datetime/src/Plugin/views/sort/Date.php \Drupal\datetime\Plugin\views\sort\Date
  30. 8.9.x core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date
  31. 8.9.x core/modules/datetime/src/Plugin/views/argument/Date.php \Drupal\datetime\Plugin\views\argument\Date
  32. 8.9.x core/lib/Drupal/Core/Render/Element/Date.php \Drupal\Core\Render\Element\Date
  33. 11.x core/modules/views/src/Plugin/views/argument_default/Date.php \Drupal\views\Plugin\views\argument_default\Date

The current date argument default handler.

Attributes

#[ViewsArgumentDefault(id: 'date', title: new TranslatableMarkup('Current date'))]

Hierarchy

Expanded class hierarchy of Date

182 string references to 'Date'
ArgumentDefaultTest::testArgumentDefaultDate in core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
Tests current date default argument.
Callbacks::dateCallback in core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php
Ajax callback triggered by date.
CallbackTest::providerCallbackArray in core/modules/migrate/tests/src/Unit/process/CallbackTest.php
Data provider for ::testCallbackArray().
claro_preprocess_input in core/themes/claro/claro.theme
Implements hook_preprocess_HOOK() for input.
CommentAccessControlHandler::checkFieldAccess in core/modules/comment/src/CommentAccessControlHandler.php
Default field access as determined by this access control handler.

... See full list

File

core/modules/views/src/Plugin/views/argument_default/Date.php, line 16

Namespace

Drupal\views\Plugin\views\argument_default
View source
class Date extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
  
  /**
   * Constructs a new Date instance.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Datetime\DateFormatterInterface $dateFormatter
   *   The date formatter service.
   * @param \Drupal\Component\Datetime\TimeInterface $time
   *   The time service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, protected DateFormatterInterface $dateFormatter, protected TimeInterface $time) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }
  
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container->get('date.formatter'), $container->get('datetime.time'));
  }
  
  /**
   * {@inheritdoc}
   */
  public function getArgument() : string {
    // The Date argument handlers provide their own format strings, otherwise
    // use a default.
    $format = $this->argument instanceof DateArgument ? $this->argument
      ->getArgFormat() : 'Y-m-d';
    $request_time = $this->time
      ->getRequestTime();
    return $this->dateFormatter
      ->format($request_time, 'custom', $format);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return [];
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return 0;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ArgumentDefaultPluginBase::$argument protected property The argument handler instance associated with this plugin.
ArgumentDefaultPluginBase::$option_name public property The option name.
ArgumentDefaultPluginBase::access public function Determine if the administrator has the privileges to use this plugin.
ArgumentDefaultPluginBase::buildOptionsForm public function Provide the default form for setting options. Overrides PluginBase::buildOptionsForm
ArgumentDefaultPluginBase::checkAccess protected function Disables the given option if the user does not have access.
ArgumentDefaultPluginBase::defineOptions protected function Retrieve the options when this is a new access control plugin. Overrides PluginBase::defineOptions
ArgumentDefaultPluginBase::getCacheTags public function
ArgumentDefaultPluginBase::setArgument public function Sets the parent argument this plugin is associated with.
ArgumentDefaultPluginBase::submitOptionsForm public function Provide the default form for submitting options. Overrides PluginBase::submitOptionsForm
ArgumentDefaultPluginBase::validateOptionsForm public function Provide the default form for validating options. Overrides PluginBase::validateOptionsForm
AutowiredInstanceTrait::createInstanceAutowired public static function Instantiates a new instance of the implementing class using autowiring.
Date::create public static function Instantiates a new instance of the implementing class using autowiring. Overrides PluginBase::create
Date::getArgument public function Return the default argument. Overrides ArgumentDefaultPluginBase::getArgument
Date::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
Date::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
Date::__construct public function Constructs a new Date instance. Overrides PluginBase::__construct
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function
DependencySerializationTrait::__wakeup public function
MessengerTrait::$messenger protected property The messenger.
MessengerTrait::messenger public function Gets the messenger.
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin.
PluginBase::$definition public property Plugins' definition.
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin ID.
PluginBase::$position public property The handler position.
PluginBase::$renderer protected property Stores the render API renderer.
PluginBase::$usesOptions protected property Denotes whether the plugin has an additional options form.
PluginBase::$view public property The top object of a view.
PluginBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::destroy public function Clears a plugin. Overrides ViewsPluginInterface::destroy
PluginBase::doFilterByDefinedOptions protected function Do the work to filter out stored options depending on the defined options.
PluginBase::filterByDefinedOptions public function Filter out stored options depending on the defined options. Overrides ViewsPluginInterface::filterByDefinedOptions
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements. Overrides ViewsPluginInterface::getAvailableGlobalTokens
PluginBase::getBaseId public function
PluginBase::getDerivativeId public function
PluginBase::getPluginDefinition public function
PluginBase::getPluginId public function
PluginBase::getProvider public function Returns the plugin provider. Overrides ViewsPluginInterface::getProvider
PluginBase::getRenderer protected function Returns the render API renderer.
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form. Overrides ViewsPluginInterface::globalTokenForm
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced. Overrides ViewsPluginInterface::globalTokenReplace
PluginBase::INCLUDE_ENTITY constant Include entity row languages when listing languages.
PluginBase::INCLUDE_NEGOTIATED constant Include negotiated languages when listing languages.
PluginBase::init public function Initialize the plugin. Overrides ViewsPluginInterface::init
PluginBase::listLanguages protected function Makes an array of languages, optionally including special languages.
PluginBase::pluginTitle public function Return the human readable name of the display. Overrides ViewsPluginInterface::pluginTitle
PluginBase::preRenderAddFieldsetMarkup public static function Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface::preRenderAddFieldsetMarkup
PluginBase::preRenderFlattenData public static function Flattens the structure of form elements. Overrides ViewsPluginInterface::preRenderFlattenData
PluginBase::query public function Add anything to the query that we might need to. Overrides ViewsPluginInterface::query
PluginBase::queryLanguageSubstitutions public static function Returns substitutions for Views queries for languages.
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::summaryTitle public function Returns the summary of the settings in the display. Overrides ViewsPluginInterface::summaryTitle
PluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. Overrides ViewsPluginInterface::themeFunctions
PluginBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
PluginBase::unpackOptions public function Unpacks options over our existing defaults. Overrides ViewsPluginInterface::unpackOptions
PluginBase::usesOptions public function Returns the usesOptions property. Overrides ViewsPluginInterface::usesOptions
PluginBase::validate public function Validate that the plugin is correct and can be saved. Overrides ViewsPluginInterface::validate
PluginBase::viewsTokenReplace protected function Replaces Views' tokens in a given string.
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT constant Query string to indicate the site default language.
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use.
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.