3 namespace Drupal\outside_in\Form;
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Plugin\PluginFormBase;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * The off-canvas form handler for the SystemBrandingBlock.
14 * @see outside_in_block_alter()
16 class SystemBrandingOffCanvasForm extends PluginFormBase implements ContainerInjectionInterface {
21 * @var \Drupal\Core\Block\BlockPluginInterface
28 * @var \Drupal\Core\Config\ConfigFactoryInterface
30 protected $configFactory;
33 * SystemBrandingOffCanvasForm constructor.
35 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
38 public function __construct(ConfigFactoryInterface $config_factory) {
39 $this->configFactory = $config_factory;
45 public static function create(ContainerInterface $container) {
47 $container->get('config.factory')
54 public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
55 $form = $this->plugin->buildConfigurationForm($form, $form_state);
57 $form['block_branding']['#type'] = 'details';
58 $form['block_branding']['#weight'] = 10;
60 // Unset links to Site Information form, we can make these changes here.
61 unset($form['block_branding']['use_site_name']['#description'], $form['block_branding']['use_site_slogan']['#description']);
63 $site_config = $this->configFactory->getEditable('system.site');
64 $form['site_information'] = [
66 '#title' => t('Site details'),
69 $form['site_information']['site_name'] = [
70 '#type' => 'textfield',
71 '#title' => t('Site name'),
72 '#default_value' => $site_config->get('name'),
75 $form['site_information']['site_slogan'] = [
76 '#type' => 'textfield',
77 '#title' => t('Slogan'),
78 '#default_value' => $site_config->get('slogan'),
79 '#description' => t("How this is used depends on your site's theme."),
88 public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
89 $this->plugin->validateConfigurationForm($form, $form_state);
95 public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
96 $site_info = $form_state->getValue('site_information');
97 $this->configFactory->getEditable('system.site')
98 ->set('name', $site_info['site_name'])
99 ->set('slogan', $site_info['site_slogan'])
101 $this->plugin->submitConfigurationForm($form, $form_state);