Base class for implementing system configuration forms.
Expanded class hierarchy of SystemConfigFormBase
abstract class SystemConfigFormBase implements FormInterface, ControllerInterface {
/**
* Stores the configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $configFactory;
/**
* Constructs a \Drupal\system\SystemConfigFormBase object.
*
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Config\Context\ContextInterface $context
* The configuration context to use.
*/
public function __construct(ConfigFactory $config_factory, ContextInterface $context) {
$this->configFactory = $config_factory;
$this->configFactory
->enterContext($context);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('config.context.free'));
}
/**
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*/
public function buildForm(array $form, array &$form_state) {
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
'#button_type' => 'primary',
);
// By default, render the form using theme_system_config_form().
$form['#theme'] = 'system_config_form';
return $form;
}
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, array &$form_state) {
}
/**
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*/
public function submitForm(array &$form, array &$form_state) {
drupal_set_message(t('The configuration options have been saved.'));
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormInterface:: |
public | function | Returns a unique string identifying the form. | 90 |
SystemConfigFormBase:: |
protected | property | Stores the configuration factory. | |
SystemConfigFormBase:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides FormInterface:: |
24 |
SystemConfigFormBase:: |
public static | function |
Instantiates a new instance of this controller. Overrides ControllerInterface:: |
9 |
SystemConfigFormBase:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides FormInterface:: |
24 |
SystemConfigFormBase:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface:: |
7 |
SystemConfigFormBase:: |
public | function | Constructs a \Drupal\system\SystemConfigFormBase object. | 9 |