public function ImportPartialForm::buildForm in Tome 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
tome_sync/ src/ Form/ ImportPartialForm.php, line 117
Class
- ImportPartialForm
- Contains a form for performing a partial import.
Namespace
Drupal\tome_sync\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
if ($error = $this
->getInitialError()) {
$form['error']['#markup'] = '<p>' . $error . '</p>';
return $form;
}
$form['description'] = [
'#markup' => '<p>' . $this
->t("Submitting this form will import all changed Tome content and files. Your local site's content and files will be deleted or updated.") . '</p>',
];
$form['content_status'] = [
'#type' => 'container',
];
$change_list = $this->contentHasher
->getChangelist();
if (empty($change_list['modified']) && empty($change_list['deleted']) && empty($change_list['added'])) {
$form['content_status']['status'] = [
'#markup' => '<p>' . $this
->t('No content has been changed or deleted. There may be file changes to import.') . '</p>',
];
}
if (!empty($change_list['modified'])) {
$form['content_status']['modified'] = [
'#title' => $this
->t('Modified'),
'#theme' => 'item_list',
'#items' => $change_list['modified'],
];
}
if (!empty($change_list['added'])) {
$form['content_status']['added'] = [
'#title' => $this
->t('Added'),
'#theme' => 'item_list',
'#items' => $change_list['added'],
];
}
if (!empty($change_list['deleted'])) {
$form['content_status']['deleted'] = [
'#title' => $this
->t('Deleted'),
'#theme' => 'item_list',
'#items' => $change_list['deleted'],
];
}
if ($this->state
->get(ImporterInterface::STATE_KEY_IMPORTING, FALSE)) {
$form['warning'] = [
'#markup' => '<p>' . $this
->t('<strong>Warning</strong>: Another user may be running an import, proceed only if the last import failed unexpectedly') . '</p>',
];
}
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}