Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Form / ConfigFormBase.php
1 <?php
2
3 namespace Drupal\Core\Form;
4
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Symfony\Component\DependencyInjection\ContainerInterface;
7
8 /**
9  * Base class for implementing system configuration forms.
10  */
11 abstract class ConfigFormBase extends FormBase {
12   use ConfigFormBaseTrait;
13
14   /**
15    * Constructs a \Drupal\system\ConfigFormBase object.
16    *
17    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
18    *   The factory for configuration objects.
19    */
20   public function __construct(ConfigFactoryInterface $config_factory) {
21     $this->setConfigFactory($config_factory);
22   }
23
24   /**
25    * {@inheritdoc}
26    */
27   public static function create(ContainerInterface $container) {
28     return new static(
29       $container->get('config.factory')
30     );
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function buildForm(array $form, FormStateInterface $form_state) {
37     $form['actions']['#type'] = 'actions';
38     $form['actions']['submit'] = [
39       '#type' => 'submit',
40       '#value' => $this->t('Save configuration'),
41       '#button_type' => 'primary',
42     ];
43
44     // By default, render the form using system-config-form.html.twig.
45     $form['#theme'] = 'system_config_form';
46
47     return $form;
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function submitForm(array &$form, FormStateInterface $form_state) {
54     $this->messenger()->addStatus($this->t('The configuration options have been saved.'));
55   }
56
57 }