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

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

OEL-547: Add links to corporate logos.

parent 74a38fda
No related branches found
No related tags found
1 merge request!36OEL-579 - Whitelabel - Medley branch with BCL 0.9.0 upgradel
......@@ -8,6 +8,7 @@ use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
......@@ -80,15 +81,26 @@ class CorporateEcLogoBlock extends BlockBase implements ContainerFactoryPluginIn
$logo_path = drupal_get_path('module', 'oe_whitelabel_helper') . '/images/logos/ec';
$title = $this->configFactory->get('system.site')->get('name');
$build = [
$image = [
'#theme' => 'image',
'#uri' => $logo_path . '/logo-ec--' . $language . '.svg',
'#width' => '240px',
'#height' => '60px',
'#alt' => $title,
'#title' => $title,
];
$build = [
'#type' => 'link',
'#url' => Url::fromUri('https://ec.europa.eu/info/index_' . $language, [
'attributes' => [
'class' => [
'navbar-brand',
],
'target' => '_blank',
],
]),
'#title' => $image,
];
$cache->applyTo($build);
return $build;
......
......@@ -8,6 +8,7 @@ use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
......@@ -83,19 +84,21 @@ class CorporateEuLogoBlock extends BlockBase implements ContainerFactoryPluginIn
$image = [
'#theme' => 'image',
'#uri' => $logo_path . '/logo-eu--' . $language . '.svg',
'#width' => '240px',
'#height' => '60px',
'#alt' => $title,
'#title' => $title,
];
$mobile_url = file_create_url($logo_path . '/mobile/logo-eu--' . $language . '.svg');
$build = [
'#type' => 'inline_template',
'#template' => '<picture><source media="(max-width: 25em)" srcset="{{ mobile }}">{{ image }}</picture>',
'#context' => [
'image' => $image,
'mobile' => file_url_transform_relative($mobile_url),
],
'#type' => 'link',
'#url' => Url::fromUri('https://europa.eu/european-union/index_' . $language, [
'attributes' => [
'class' => [
'navbar-brand',
],
'target' => '_blank',
],
]),
'#title' => $image,
];
$cache->applyTo($build);
......
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