-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from openeuropa/OEL-1147
OEL-1147 - Footer.
- Loading branch information
Showing
30 changed files
with
572 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
config/optional/block.block.oe_whitelabel_eu_corporate_footer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- oe_corporate_blocks | ||
theme: | ||
- oe_whitelabel | ||
id: oe_whitelabel_eu_corporate_footer | ||
theme: oe_whitelabel | ||
region: footer | ||
weight: 0 | ||
provider: null | ||
plugin: oe_corporate_blocks_eu_footer | ||
settings: | ||
id: oe_corporate_blocks_eu_footer | ||
label: 'EU Footer block' | ||
provider: oe_corporate_blocks | ||
label_display: '0' | ||
visibility: | ||
oe_whitelabel_helper_current_component_library: | ||
id: oe_whitelabel_helper_current_component_library | ||
component_library: eu | ||
negate: false | ||
context_mapping: { } |
24 changes: 24 additions & 0 deletions
24
config/optional/block.block.oe_whitelabel_neutral_footer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- oe_whitelabel_helper | ||
theme: | ||
- oe_whitelabel | ||
id: oe_whitelabel_neutral_footer | ||
theme: oe_whitelabel | ||
region: footer | ||
weight: 0 | ||
provider: null | ||
plugin: oe_corporate_blocks_neutral_footer | ||
settings: | ||
id: oe_corporate_blocks_neutral_footer | ||
label: 'Neutral Footer block' | ||
provider: oe_whitelabel_helper | ||
label_display: '0' | ||
visibility: | ||
oe_whitelabel_helper_current_component_library: | ||
id: oe_whitelabel_helper_current_component_library | ||
component_library: neutral | ||
negate: false | ||
context_mapping: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/oe_whitelabel_helper/src/Plugin/Block/NeutralFooterBlock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_whitelabel_helper\Plugin\Block; | ||
|
||
use Drupal\Component\Utility\NestedArray; | ||
use Drupal\Core\Cache\CacheableMetadata; | ||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
use Drupal\oe_corporate_blocks\Plugin\Block\FooterBlockBase; | ||
|
||
/** | ||
* Provides the Neutral footer block. | ||
* | ||
* @Block( | ||
* id = "oe_corporate_blocks_neutral_footer", | ||
* admin_label = @Translation("Neutral Footer block"), | ||
* category = @Translation("Corporate blocks"), | ||
* ) | ||
*/ | ||
class NeutralFooterBlock extends FooterBlockBase implements ContainerFactoryPluginInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build() { | ||
$cache = new CacheableMetadata(); | ||
$cache->addCacheContexts(['languages:language_interface']); | ||
|
||
$config = $this->configFactory->get('oe_corporate_blocks.ec_data.footer'); | ||
$cache->addCacheableDependency($config); | ||
|
||
$build['#theme'] = 'oe_corporate_blocks_neutral_footer'; | ||
|
||
NestedArray::setValue($build, ['#corporate_footer', 'content_owner_details'], $config->get('content_owner_details')); | ||
|
||
$this->setSiteSpecificFooter($build, $cache); | ||
|
||
$cache->applyTo($build); | ||
|
||
return $build; | ||
} | ||
|
||
} |
151 changes: 151 additions & 0 deletions
151
modules/oe_whitelabel_helper/src/Plugin/Condition/CurrentComponentLibraryCondition.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_whitelabel_helper\Plugin\Condition; | ||
|
||
use Drupal\Core\Cache\Cache; | ||
use Drupal\Core\Condition\ConditionPluginBase; | ||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
use Drupal\Core\Theme\ThemeManagerInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Provides a configurable 'Current component library' condition. | ||
* | ||
* This condition checks if the current component library is equal to a given | ||
* value. | ||
* | ||
* @Condition( | ||
* id = "oe_whitelabel_helper_current_component_library", | ||
* label = @Translation("Current component library") | ||
* ) | ||
*/ | ||
class CurrentComponentLibraryCondition extends ConditionPluginBase implements ContainerFactoryPluginInterface { | ||
|
||
/** | ||
* The configuration factory service. | ||
* | ||
* @var \Drupal\Core\Config\ConfigFactoryInterface | ||
*/ | ||
protected $configFactory; | ||
|
||
/** | ||
* The theme manager. | ||
* | ||
* @var \Drupal\Core\Theme\ThemeManagerInterface | ||
*/ | ||
protected $themeManager; | ||
|
||
/** | ||
* Constructs a CurrentComponentLibraryCondition condition plugin. | ||
* | ||
* @param array $configuration | ||
* A configuration array containing information about the plugin instance. | ||
* @param string $plugin_id | ||
* The plugin_id for the plugin instance. | ||
* @param mixed $plugin_definition | ||
* The plugin implementation definition. | ||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory | ||
* The configuration factory service. | ||
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager | ||
* The theme manager. | ||
*/ | ||
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, ThemeManagerInterface $theme_manager) { | ||
parent::__construct($configuration, $plugin_id, $plugin_definition); | ||
$this->configFactory = $config_factory; | ||
$this->themeManager = $theme_manager; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | ||
return new static( | ||
$configuration, | ||
$plugin_id, | ||
$plugin_definition, | ||
$container->get('config.factory'), | ||
$container->get('theme.manager') | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function defaultConfiguration() { | ||
return [ | ||
'component_library' => '', | ||
] + parent::defaultConfiguration(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { | ||
// We allow for an empty value to be set. By doing that we make sure that | ||
// no settings about this condition is actually saved in block visibility | ||
// settings, unless the user explicitly sets one. | ||
$form['component_library'] = [ | ||
'#type' => 'select', | ||
'#title' => $this->t('Component library'), | ||
'#options' => [ | ||
'' => $this->t('- Any -'), | ||
'neutral' => $this->t('Neutral'), | ||
'ec' => $this->t('European Commission'), | ||
'eu' => $this->t('European Union'), | ||
], | ||
'#default_value' => $this->configuration['component_library'], | ||
'#description' => t('Choose with which component library this condition should be met.'), | ||
]; | ||
return parent::buildConfigurationForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { | ||
$this->configuration['component_library'] = $form_state->getValue('component_library'); | ||
parent::submitConfigurationForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function evaluate() { | ||
if (empty($this->configuration['component_library'])) { | ||
return TRUE; | ||
} | ||
$theme_name = $this->themeManager->getActiveTheme()->getName(); | ||
|
||
$component_library = $this->configFactory->get($theme_name . '.settings')->get('component_library'); | ||
return $component_library === $this->configuration['component_library']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function summary() { | ||
if (empty($this->configuration['component_library'])) { | ||
return $this->t('The current component library can be set to anything'); | ||
} | ||
|
||
if ($this->isNegated()) { | ||
return $this->t('The current component library is not @component_library', ['@component_library' => $this->configuration['component_library']]); | ||
} | ||
|
||
return $this->t('The current component library is @component_library', ['@component_library' => $this->configuration['component_library']]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCacheTags() { | ||
$theme_name = $this->themeManager->getActiveTheme()->getName(); | ||
|
||
return Cache::mergeTags(['config:' . $theme_name . '.settings'], parent::getCacheTags()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.