*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
- $values += array(
+ $values += [
'user_id' => \Drupal::currentUser()->id(),
- );
+ ];
}
{% if revisionable %}
}
{% endif %}
-{% if bundle_entity_type %}
- /**
- * {@inheritdoc}
- */
- public function getType() {
- return $this->bundle();
- }
-
-{% endif %}
/**
* {@inheritdoc}
*/
$this->set('status', $published ? TRUE : FALSE);
return $this;
}
-{% if revisionable %}
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionCreationTime() {
- return $this->get('revision_timestamp')->value;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionCreationTime($timestamp) {
- $this->set('revision_timestamp', $timestamp);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionUser() {
- return $this->get('revision_uid')->entity;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionUserId($uid) {
- $this->set('revision_uid', $uid);
- return $this;
- }
-{% endif %}
/**
* {@inheritdoc}
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
- ),
- ))
+ ],
+ ])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
{% if revisionable %}
->setRevisionable(TRUE)
{% endif %}
- ->setSettings(array(
+ ->setSettings([
'max_length' => 50,
'text_processing' => 0,
- ))
+ ])
->setDefaultValue('')
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
-{% if revisionable %}
-
- $fields['revision_timestamp'] = BaseFieldDefinition::create('created')
- ->setLabel(t('Revision timestamp'))
- ->setDescription(t('The time that the current revision was created.'))
- ->setQueryable(FALSE)
- ->setRevisionable(TRUE);
-
- $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')
- ->setLabel(t('Revision user ID'))
- ->setDescription(t('The user ID of the author of the current revision.'))
- ->setSetting('target_type', 'user')
- ->setQueryable(FALSE)
- ->setRevisionable(TRUE);
-{% endif %}
{% if revisionable and is_translatable %}
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')