3 namespace Drupal\hacked\Form;
5 use Drupal\Component\Utility\Html;
6 use Drupal\Core\Form\ConfigFormBase;
7 use Drupal\Core\Form\FormStateInterface;
10 * Configure locale settings for this site.
12 class HackedSettingsForm extends ConfigFormBase {
16 protected function getEditableConfigNames() {
17 return ['hacked.settings'];
23 public function getFormID() {
24 return 'hacked_settings';
30 public function buildForm(array $form, FormStateInterface $form_state) {
31 $config = $this->config('hacked.settings');
33 $hashers = hacked_get_file_hashers();
35 $form['selected_file_hasher'] = array(
37 '#title' => t('File hasher'),
41 $parents = array('selected_file_hasher');
43 foreach ($hashers as $name => $hasher_info) {
44 // Generate the parents as the autogenerator does, so we will have a
45 // unique id for each radio button.
46 $parents_for_id = array_merge($parents, array($name));
47 $form['selected_file_hasher'][$name] = array(
49 '#title' => $hasher_info['name'],
50 '#default_value' => $config->get('selected_file_hasher'),
51 '#return_value' => $name,
52 '#parents' => $parents,
53 '#description' => !empty($hasher_info['description']) ? $hasher_info['description'] : '',
54 '#id' => Html::getId('edit-' . implode('-', $parents_for_id)),
58 return parent::buildForm($form, $form_state);
64 public function submitForm(array &$form, FormStateInterface $form_state) {
65 // Clear the Hacked! report cache.
66 // cache_clear_all('hacked:full-report', HACKED_CACHE_TABLE);
68 $values = $form_state->getValues();
70 $config = $this->config('hacked.settings');
71 $config->set('selected_file_hasher', $values['selected_file_hasher'])
74 parent::submitForm($form, $form_state);