public function SolrUploadConfigsetForm::buildForm in Search API Solr 4.x
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/
search_api_solr_admin/ src/ Form/ SolrUploadConfigsetForm.php, line 31
Class
- SolrUploadConfigsetForm
- The upload configset form.
Namespace
Drupal\search_api_solr_admin\FormCode
public function buildForm(array $form, FormStateInterface $form_state, ServerInterface $search_api_server = NULL) {
$this->search_api_server = $search_api_server;
$connector = Utility::getSolrCloudConnector($this->search_api_server);
$configset = $connector
->getConfigSetName();
if (!$configset) {
$this->messenger
->addWarning($this
->t('No existing configset name could be detected on the Solr server for this collection. That\'s fine if you just create a new collection. Otherwise you should check the logs.'));
}
$form['#title'] = $this
->t('Upload Configset for %collection?', [
'%collection' => $connector
->getCollectionName(),
]);
$form['accept'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Upload (and overwrite) configset %configset to Solr Server.', [
'%configset' => $configset,
]),
'#decrtiption' => $configset ? $this
->t("The collection will be reloaded using the new configset") : $this
->t('A new collection will be created from the configset.'),
'#default_value' => FALSE,
];
if (!$configset) {
$form['num_shards'] = [
'#type' => 'number',
'#title' => $this
->t('Number of shards'),
'#description' => $this
->t('The number of shards to be created for the collection.'),
'#default_value' => 3,
];
}
else {
$form['num_shards'] = [
'#type' => 'value',
'#default_value' => 3,
];
}
$form['actions'] = [
'submit' => [
'#type' => 'submit',
'#value' => $this
->t('Upload'),
],
];
return $form;
}