function DateTimeComputed::__construct

Same name in other branches
  1. 9 core/modules/datetime/src/DateTimeComputed.php \Drupal\datetime\DateTimeComputed::__construct()
  2. 8.9.x core/modules/datetime/src/DateTimeComputed.php \Drupal\datetime\DateTimeComputed::__construct()
  3. 11.x core/modules/datetime/src/DateTimeComputed.php \Drupal\datetime\DateTimeComputed::__construct()

Overrides TypedData::__construct

File

core/modules/datetime/src/DateTimeComputed.php, line 30

Class

DateTimeComputed
A computed property for dates of date time field items.

Namespace

Drupal\datetime

Code

public function __construct(DataDefinitionInterface $definition, $name = NULL, ?TypedDataInterface $parent = NULL) {
    parent::__construct($definition, $name, $parent);
    if (!$definition->getSetting('date source')) {
        throw new \InvalidArgumentException("The definition's 'date source' key has to specify the name of the date property to be computed.");
    }
}

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