ConfigFormBase.php in Drupal 10
File
core/lib/Drupal/Core/Form/ConfigFormBase.php
View source
<?php
namespace Drupal\Core\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ConfigFormBase extends FormBase {
use ConfigFormBaseTrait;
public function __construct(ConfigFactoryInterface $config_factory) {
$this
->setConfigFactory($config_factory);
}
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'));
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Save configuration'),
'#button_type' => 'primary',
];
$form['#theme'] = 'system_config_form';
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->messenger()
->addStatus($this
->t('The configuration options have been saved.'));
}
}