-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPatternLibraryRESTForm.php
More file actions
62 lines (51 loc) · 1.39 KB
/
PatternLibraryRESTForm.php
File metadata and controls
62 lines (51 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Drupal\patternkit\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Settings form for configuring the REST Library Plugin.
*/
class PatternLibraryRESTForm extends ConfigFormBase {
/**
* Settings identifier.
*
* @var string
*/
public const SETTINGS = 'patternkit.settings';
/**
* Implements buildForm().
*
* {@inheritDoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) :array {
$config = $this->config(static::SETTINGS);
$form['patternkit_pl_host'] = array(
'#type' => 'textfield',
'#title' => t('PatternLab Host Web Address'),
'#description' => t('Enter the website address of the PatternLab host REST endpoint.'),
'#default_value' => $config->get('patternkit_pl_host'),
);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritDoc}
*/
protected function getEditableConfigNames() :array {
return [static::SETTINGS];
}
/**
* {@inheritDoc}
*/
public function getFormId() :string {
return 'patternkit_rest_editor_config';
}
/**
* {@inheritDoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->config(static::SETTINGS)
->set('patternkit_pl_host', $form_state->getValue('patternkit_pl_host'))
->save();
parent::submitForm($form, $form_state);
}
}