diff --git a/psulib_base_helper.info.yml b/psulib_base_helper.info.yml index 7b07967..9031e0c 100644 --- a/psulib_base_helper.info.yml +++ b/psulib_base_helper.info.yml @@ -2,4 +2,6 @@ name: 'PSULIB Base Theme Helper' type: module description: 'Helper module that works with the psulib_base base theme.' package: PSU Libraries -core_version_requirement: ^10 || ^11 \ No newline at end of file +core_version_requirement: ^10 || ^11 +dependencies: + - drupal:system diff --git a/src/Plugin/Block/PsulBrandingBlock.php b/src/Plugin/Block/PsulBrandingBlock.php new file mode 100644 index 0000000..555cb32 --- /dev/null +++ b/src/Plugin/Block/PsulBrandingBlock.php @@ -0,0 +1,101 @@ + 'checkbox', + '#title' => $this->t('Hide Site name and slogan'), + '#description' => $this->t('Hide the site name and slogan with css.'), + '#default_value' => $this->configuration['hide_site_name'], + ]; + + $form['block_branding']['logo_title'] = [ + '#type' => 'textfield', + '#title' => $this->t('Logo title'), + '#description' => $this->t('Set the logo title and alt.'), + '#default_value' => $this->configuration['logo_title'], + ]; + + $form['block_branding']['logo_path'] = [ + '#type' => 'url', + '#title' => $this->t('Logo link URL'), + '#description' => $this->t('Update the logo so it links to another site.'), + '#default_value' => $this->configuration['logo_path'], + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + $block_branding = $form_state->getValue('block_branding'); + $this->configuration['use_site_logo'] = $block_branding['use_site_logo']; + $this->configuration['use_site_name'] = $block_branding['use_site_name']; + $this->configuration['use_site_slogan'] = $block_branding['use_site_slogan']; + $this->configuration['hide_site_name'] = $block_branding['hide_site_name']; + $this->configuration['logo_title'] = $block_branding['logo_title']; + $this->configuration['logo_path'] = $block_branding['logo_path']; + + } + + /** + * {@inheritdoc} + */ + public function build(): array { + $site_config = $this->configFactory->get('system.site'); + + // Create the header_mark response. + return [ + '#type' => 'component', + '#component' => 'psulib_base:header_mark', + '#props' => [ + 'site_name' => $this->configuration['use_site_name'] ? $site_config->get('name') : '', + 'site_logo' => $this->configuration['use_site_logo'] ? theme_get_setting('logo.url') : '', + 'site_slogan' => $this->configuration['use_site_slogan'] ? $site_config->get('slogan') : '', + 'hide_site_name' => $this->configuration['hide_site_name'], + 'logo_title' => $this->configuration['logo_title'], + 'logo_path' => $this->configuration['logo_path'], + ], + ]; + + } + +}