/**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $entity_type = $this->entity->getEntityType();
     $bundle_entity = $this->getBundleEntity();
     $account = $this->currentUser();
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('Edit %bundle_label @label', ['%bundle_label' => $bundle_entity ? $bundle_entity->label() : '', '@label' => $this->entity->label()]);
     }
     $form['advanced'] = ['#type' => 'vertical_tabs', '#weight' => 99];
     // Add a log field if the "Create new revision" option is checked, or if the
     // current user has the ability to check that option.
     // @todo Could we autogenerate this form by using some widget on the
     //   revision info field.
     $form['revision_information'] = ['#type' => 'details', '#title' => $this->t('Revision information'), '#open' => $this->entity->isNewRevision(), '#group' => 'advanced', '#weight' => 20, '#access' => $this->entity->isNewRevision() || $account->hasPermission($entity_type->get('admin_permission'))];
     $form['revision_information']['revision'] = ['#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => $this->entity->isNewRevision(), '#access' => $account->hasPermission($entity_type->get('admin_permission'))];
     // Check the revision log checkbox when the log textarea is filled in.
     // This must not happen if "Create new revision" is enabled by default,
     // since the state would auto-disable the checkbox otherwise.
     if (!$this->entity->isNewRevision()) {
         $form['revision_information']['revision']['#states'] = ['checked' => ['textarea[name="revision_log"]' => ['empty' => FALSE]]];
     }
     $form['revision_information']['revision_log'] = ['#type' => 'textarea', '#title' => $this->t('Revision log message'), '#rows' => 4, '#default_value' => $this->entity->getRevisionLogMessage(), '#description' => $this->t('Briefly describe the changes you have made.')];
     return parent::form($form, $form_state);
 }
 /**
  * Stores the entity property language-aware data.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity object.
  * @param string $table_name
  *   (optional) The table name to save to. Defaults to the data table.
  */
 protected function savePropertyData(EntityInterface $entity, $table_name = NULL)
 {
     if (!isset($table_name)) {
         $table_name = $this->dataTable;
     }
     $revision = $table_name != $this->dataTable;
     if (!$revision || !$entity->isNewRevision()) {
         $key = $revision ? $this->revisionKey : $this->idKey;
         $value = $revision ? $entity->getRevisionId() : $entity->id();
         // Delete and insert to handle removed values.
         $this->database->delete($table_name)->condition($key, $value)->execute();
     }
     $query = $this->database->insert($table_name);
     foreach ($entity->getTranslationLanguages() as $langcode => $language) {
         $translation = $entity->getTranslation($langcode);
         $record = $this->mapToDataStorageRecord($translation, $table_name);
         $values = (array) $record;
         $query->fields(array_keys($values))->values($values);
     }
     $query->execute();
 }