Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 8a27c70f authored by escuriola's avatar escuriola
Browse files

OEL-1160: Remove branding block preprocess. Add variables to neutral logo.

parent 54aaa42a
No related branches found
No related tags found
1 merge request!71OEL-1160: Header refactor.
......@@ -8,6 +8,7 @@
declare(strict_types = 1);
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\oe_whitelabel_helper\EuropeanUnionLanguages;
/**
......@@ -152,58 +153,18 @@ function oe_whitelabel_preprocess_page(&$variables) {
$site_logo_href = 'https://european-union.europa.eu';
}
else {
$site_config = \Drupal::config('system.site');
$variables['site_name'] = $site_config->get('name');
$variables['site_logo_url'] = file_url_transform_relative(file_create_url(theme_get_setting('logo.url')));
$variables['logo_aria_label'] = t('Home');
$variables['site_logo_alt'] = t('Home logo');
$variables['site_logo_title'] = t('Home');
$site_logo_href = '<front>';
$site_logo_href = Url::fromRoute('<front>')->toString();
}
// Provide correct icon for non-eu languages.
$language_code = \Drupal::languageManager()->getCurrentLanguage()->getId();
if (!EuropeanUnionLanguages::hasLanguage($language_code)) {
if ($language_code === 'nb') {
// Set correct icon for Norwegian language.
$variables['current_language_id'] = 'no';
}
else {
// Check whether ECL provides a logo for the language.
$bcl_logo = $variables['bcl_logo_path'] . '/' . $variables['bcl_component_library'] . '/';
$bcl_logo .= 'logo-' . $variables['bcl_component_library'] . '--' . $language_code . '.svg';
if (!file_exists($bcl_logo)) {
// Provide fallback "en" icon if language logo doesn't exist.
$variables['current_language_id'] = 'en';
}
}
}
else {
$site_logo_href .= '/index_' . EuropeanUnionLanguages::getInternalLanguageCode($variables['current_language_id']);
}
$variables['site_logo_href'] = $site_logo_href;
}
/**
* Implements template_preprocess_block__system_branding_block().
*/
function oe_whitelabel_preprocess_block__system_branding_block(&$variables) {
if ($variables['bcl_component_library'] === 'ec') {
$variables['logo_aria_label'] = t('Home') . ' - ' . t('European Commission');
$variables['site_logo_alt'] = t('European Commission logo');
$variables['site_logo_title'] = t('European Commission');
$site_logo_href = 'https://ec.europa.eu/info';
if ($variables['bcl_component_library'] === 'neutral') {
return;
}
elseif ($variables['bcl_component_library'] === 'eu') {
$variables['logo_aria_label'] = t('Home') . ' - ' . t('European Union');
$variables['site_logo_alt'] = t('European Union flag');
$variables['site_logo_title'] = t('European Union');
$site_logo_href = 'https://european-union.europa.eu';
}
else {
$variables['logo_aria_label'] = t('Home');
$variables['site_logo_alt'] = t('Home logo');
$variables['site_logo_title'] = t('Home');
$site_logo_href = '<front>';
}
// Provide correct icon for non-eu languages.
$language_code = \Drupal::languageManager()->getCurrentLanguage()->getId();
if (!EuropeanUnionLanguages::hasLanguage($language_code)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment