public function SettingsForm::buildForm in Replication 8
Same name and namespace in other branches
- 8.2 src/Form/SettingsForm.php \Drupal\replication\Form\SettingsForm::buildForm()
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 ConfigFormBase::buildForm
File
- src/
Form/ SettingsForm.php, line 34
Class
- SettingsForm
- Class SettingsForm.
Namespace
Drupal\replication\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('replication.settings');
$options = [
'uid' => $this
->t('Map by UID'),
'anonymous' => $this
->t('Map to Anonymous'),
'uid_1' => $this
->t('Map to UID 1'),
];
$form['config'] = array(
'#type' => 'fieldset',
'#title' => $this
->t('Replication configuration'),
);
$form['config']['mapping_type'] = [
'#type' => 'select',
'#title' => $this
->t('Users mapping type'),
'#default_value' => $config
->get('mapping_type'),
'#options' => $options,
'#description' => $this
->t("Select how users will be mapped when they can't be mapped by username or email."),
];
$form['config']['uid'] = [
'#type' => 'textfield',
'#title' => $this
->t('UID'),
'#default_value' => $config
->get('mapping_type') === 'uid' ? $config
->get('uid') : '',
'#maxlength' => 60,
'#size' => 30,
'#states' => [
'visible' => [
'select[name="mapping_type"]' => [
'value' => 'uid',
],
],
],
];
$form['config']['changes_limit'] = [
'#type' => 'number',
'#title' => t('Changes limit'),
'#default_value' => $config
->get('changes_limit'),
'#description' => $this
->t("This is the limit of changes the \n replicator will GET per request, if the limit is a smaller number than \n the total changes, then it will do multiple requests to get all the \n changes. The bigger this number is, the slower will be the request, but at \n the same time - the smaller is the limit, the higher is the number of \n requests, so, there should be set an optimal limit, to not impact the \n performance. Values range 10 - 1000."),
'#required' => TRUE,
'#min' => 10,
'#max' => 1000,
'#step' => 10,
];
$form['config']['bulk_docs_limit'] = [
'#type' => 'number',
'#title' => t('Bulk docs limit'),
'#default_value' => $config
->get('bulk_docs_limit'),
'#description' => $this
->t("This is the limit of entities the \n replicator will POST per request, if the limit is a smaller number than \n the total number of entities that have to be transferred to the destination, \n then it will do multiple requests to transfer all the entities. The bigger \n this number is, the slower will be the request and the destination site will \n need more resources to process all the data, so, there should be set an \n optimal limit, to not impact the performance. Values range 10 - 1000."),
'#required' => TRUE,
'#min' => 10,
'#max' => 1000,
'#step' => 10,
];
$form['config']['replication_execution_limit'] = [
'#type' => 'select',
'#title' => $this
->t('Replication execution limit'),
'#default_value' => $config
->get('replication_execution_limit'),
'#options' => [
1 => $this
->t('1 hour'),
2 => $this
->t('2 hours'),
4 => $this
->t('4 hours'),
8 => $this
->t('8 hours'),
],
'#description' => $this
->t("The maximum time a replication can run, if it exceeds this time then the replication is marked as failed."),
'#required' => TRUE,
];
$form['config']['verbose_logging'] = [
'#type' => 'checkbox',
'#title' => t('Verbose logging'),
'#default_value' => (int) $config
->get('verbose_logging'),
'#description' => $this
->t('This will enable verbose replication logging.'),
];
$form['config']['actions']['#type'] = 'actions';
$form['config']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Save configuration'),
'#button_type' => 'primary',
];
// By default, render the form using system-config-form.html.twig.
$form['#theme'] = 'system_config_form';
return $form;
}