public function PublicationDateItem::applyDefaultValue in Publication Date 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldType/PublicationDateItem.php \Drupal\publication_date\Plugin\Field\FieldType\PublicationDateItem::applyDefaultValue()
Applies the default value.
Parameters
bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.
Return value
$this Returns itself to allow for chaining.
Overrides CreatedItem::applyDefaultValue
File
- src/
Plugin/ Field/ FieldType/ PublicationDateItem.php, line 38 - Contains \Drupal\publication_date\Plugin\Field\FieldType\PublicationDateItem.
Class
- PublicationDateItem
- Defines the 'published_at' entity field type.
Namespace
Drupal\publication_date\Plugin\Field\FieldTypeCode
public function applyDefaultValue($notify = TRUE) {
$value = $this
->isPublished() ? REQUEST_TIME : NULL;
$published_at_or_now = isset($value) ? $value : REQUEST_TIME;
$this
->setValue([
'value' => $value,
'published_at_or_now' => $published_at_or_now,
], $notify);
return $this;
}