-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DKAN-4291 Add MySQL Import settings page.
- Loading branch information
Steve Wirt
authored and
Steve Wirt
committed
Sep 17, 2024
1 parent
c104b61
commit 01f1300
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.links.menu.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
datastore_mysql_import.settings_form: | ||
title: MySQl Import settings | ||
description: Setting for the MySQL Importer. | ||
parent: system.admin_dkan | ||
route_name: datastore.mysql_import.settings | ||
weight: 15 |
7 changes: 7 additions & 0 deletions
7
modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
datastore.mysql_import.settings: | ||
path: '/admin/dkan/datastore/mysql_import' | ||
defaults: | ||
_title: 'MySQL Import Settings' | ||
_form: 'Drupal\datastore_mysql_import\Form\DatastoreMysqlImportSettingsForm' | ||
requirements: | ||
_permission: 'administer site configuration' |
76 changes: 76 additions & 0 deletions
76
...es/datastore/modules/datastore_mysql_import/src/Form/DatastoreMysqlImportSettingsForm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Drupal\datastore_mysql_import\Form; | ||
|
||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Form\ConfigFormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Datastore MySQL Import settings form. | ||
* | ||
* @package Drupal\datastore\Form | ||
* @codeCoverageIgnore | ||
*/ | ||
class DatastoreMysqlImportSettingsForm extends ConfigFormBase { | ||
|
||
|
||
/** | ||
* Constructs form. | ||
* | ||
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory | ||
* The factory for configuration objects. | ||
*/ | ||
public function __construct(ConfigFactoryInterface $config_factory) { | ||
parent::__construct($config_factory); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container) { | ||
return new static( | ||
$container->get('config.factory'), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId() { | ||
return 'datastore_mysql_import_settings_form'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getEditableConfigNames() { | ||
return ['datastore.mysql_import.settings']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state) { | ||
$config = $this->config('datastore.mysql_import.settings'); | ||
$form['remove_empty_rows'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Enable removal of empty rows in dataset.'), | ||
'#description' => $this->t('Unlike the chunk harvester, which ignores empty rows in a CSV, the MySQL importer will import empty rows.'), | ||
'#default_value' => $config->get('remove_empty_rows'), | ||
]; | ||
return parent::buildForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$this->config('datastore.mysql_import.settings') | ||
->set('remove_empty_rows', $form_state->getValue('remove_empty_rows')) | ||
->save(); | ||
parent::submitForm($form, $form_state); | ||
} | ||
|
||
} |