public function JobForm::buildEntity in Translation Management Tool 8
Builds an updated entity object based upon the submitted form values.
For building the updated entity object the form's entity is cloned and the submitted form values are copied to entity properties. The form's entity remains unchanged.
Parameters
array $form: A nested array form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Entity\EntityInterface An updated copy of the form's entity object.
Overrides ContentEntityForm::buildEntity
See also
\Drupal\Core\Entity\EntityFormInterface::getEntity()
1 call to JobForm::buildEntity()
- JobForm::submitBuildJob in src/
Form/ JobForm.php - Handles submit call to rebuild a job.
File
- src/
Form/ JobForm.php, line 602
Class
- JobForm
- Form controller for the job edit forms.
Namespace
Drupal\tmgmt\FormCode
public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\tmgmt\JobInterface $job */
$job = parent::buildEntity($form, $form_state);
if ($job
->hasTranslator()) {
$translator = $job
->getTranslator();
// If requested custom job settings handling, copy values from original job.
if ($translator
->hasCustomSettingsHandling()) {
$original_job = \Drupal::entityTypeManager()
->getStorage('tmgmt_job')
->loadUnchanged($job
->id());
$job->settings = $original_job->settings;
}
}
// Make sure that we always store a label as it can be a slow operation to
// generate the default label.
if (empty($job->label)) {
$job->label = $job
->label();
}
return $job;
}