You are here

public function DateTimeComputed::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/datetime/src/DateTimeComputed.php \Drupal\datetime\DateTimeComputed::__construct()
  2. 10 core/modules/datetime/src/DateTimeComputed.php \Drupal\datetime\DateTimeComputed::__construct()

Constructs a TypedData object given its definition and context.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface $definition: The data definition.

string $name: (optional) The name of the created property, or NULL if it is the root of a typed data tree. Defaults to NULL.

\Drupal\Core\TypedData\TypedDataInterface $parent: (optional) The parent object of the data property, or NULL if it is the root of a typed data tree. Defaults to NULL.

Overrides TypedData::__construct

See also

\Drupal\Core\TypedData\TypedDataManager::create()

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.");
  }
}