Skip to content

Commit

Permalink
EWPP-5177: Add new sections for specific site footer.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed Feb 3, 2025
1 parent 6c15053 commit 4c3bb90
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 84 deletions.
63 changes: 5 additions & 58 deletions config/install/oe_corporate_blocks.ec_data.footer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,10 @@ langcode: en
corporate_site_link:
href: 'https://commission.europa.eu/index_en'
label: 'European Commission website'
class_navigation:
-
href: 'https://commission.europa.eu/strategy_en'
label: Strategy
-
href: 'https://commission.europa.eu/about-european-commission_en'
label: 'About the European Commission'
-
href: 'https://commission.europa.eu/business-economy-euro_en'
label: 'Business, Economy, Euro'
-
href: 'https://commission.europa.eu/live-work-travel-eu_en'
label: 'Live, work, travel in the EU'
-
href: 'https://commission.europa.eu/law_en'
label: Law
-
href: 'https://commission.europa.eu/funding-tenders_en'
label: 'Funding, Tenders'
-
href: 'https://commission.europa.eu/research-and-innovation_en'
label: 'Research and innovation'
-
href: 'https://commission.europa.eu/energy-climate-change-environment_en'
label: 'Energy, Climate change, Environment'
-
href: 'https://commission.europa.eu/education_en'
label: Education
-
href: 'https://commission.europa.eu/aid-development-cooperation-fundamental-rights_en'
label: 'Aid, Development cooperation, Fundamental rights'
-
href: 'https://commission.europa.eu/food-farming-fisheries_en'
label: 'Food, Farming, Fisheries'
-
href: 'https://commission.europa.eu/eu-regional-and-urban-development_en'
label: 'EU regional and urban development'
-
href: 'https://commission.europa.eu/jobs-european-commission_en'
label: 'Jobs at the European Commission'
-
href: 'https://commission.europa.eu/statistics_en'
label: Statistics
-
href: 'https://ec.europa.eu/commission/presscorner/home/en'
label: 'Press Corner'
-
href: 'https://commission.europa.eu/events_en'
label: Events
-
href: 'https://commission.europa.eu/publications_en'
label: Publications
service_navigation:
-
href: 'https://commission.europa.eu/about-european-commission/contact_en'
label: 'Contact the European Commission'
-
branding: core
href: 'https://commission.europa.eu/accessibility-statement_en'
label: 'Accessibility'
-
external: false
href: 'https://european-union.europa.eu/contact-eu/social-media-channels_en#/search?page=0&institutions=european_commission'
Expand All @@ -73,14 +17,17 @@ service_navigation:
href: 'https://commission.europa.eu/legal-notice/vulnerability-disclosure-policy_en'
label: 'Report an IT vulnerability'
legal_navigation:
-
href: 'https://commission.europa.eu/legal-notice/vulnerability-disclosure-policy_en'
label: 'Report an IT vulnerability'
-
href: 'https://commission.europa.eu/languages-our-websites_en'
label: 'Languages on our websites'
-
href: 'https://commission.europa.eu/cookies_en'
href: 'https://commission.europa.eu/cookies-policy_en'
label: Cookies
-
href: 'https://commission.europa.eu/privacy-policy_en'
href: 'https://commission.europa.eu/privacy-policy-websites-managed-european-commission_en'
label: 'Privacy policy'
-
href: 'https://commission.europa.eu/legal-notice_en'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: about_us
label: 'About us'
url: 'https://commission.europa.eu/about_en'
section: ec_core_column
weight: -4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: contact_us
label: 'Contact us'
url: 'https://commission.europa.eu/about/contact_en'
section: ec_core_column
weight: -3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: events
label: Events
url: 'https://commission.europa.eu/get-involved/events_en'
section: ec_core_column
weight: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: funding_and_tenders
label: 'Funding and tenders'
url: 'https://commission.europa.eu/funding-tenders_en'
section: ec_core_column
weight: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: jobs
label: Jobs
url: 'https://commission.europa.eu/get-involved/jobs-european-commission_en'
section: ec_core_column
weight: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: press_corner
label: 'Press corner'
url: 'https://ec.europa.eu/commission/presscorner/home/en'
section: ec_core_column
weight: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: priorities
label: Priorities
url: 'https://commission.europa.eu/priorities-2024-2029_en'
section: ec_core_column
weight: -2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: topics
label: Topics
url: 'https://commission.europa.eu/topics_en'
section: ec_core_column
weight: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
langcode: en
status: true
dependencies: { }
id: ec_core_column
label: 'EC Core column'
weight: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
langcode: en
corporate_site_link:
href: 'https://commission.europa.eu/index_en'
label: 'European Commission website'
service_navigation:
-
href: 'https://commission.europa.eu/about-european-commission/contact_en'
label: 'Contact the European Commission'
-
external: false
href: 'https://european-union.europa.eu/contact-eu/social-media-channels_en#/search?page=0&institutions=european_commission'
label: 'Follow the European Commission on social media'
-
href: 'https://commission.europa.eu/resources-partners_en'
label: 'Resources for partners'
-
href: 'https://commission.europa.eu/legal-notice/vulnerability-disclosure-policy_en'
label: 'Report an IT vulnerability'
legal_navigation:
-
href: 'https://commission.europa.eu/legal-notice/vulnerability-disclosure-policy_en'
label: 'Report an IT vulnerability'
-
href: 'https://commission.europa.eu/languages-our-websites_en'
label: 'Languages on our websites'
-
href: 'https://commission.europa.eu/cookies-policy_en'
label: Cookies
-
href: 'https://commission.europa.eu/privacy-policy-websites-managed-european-commission_en'
label: 'Privacy policy'
-
href: 'https://commission.europa.eu/legal-notice_en'
label: 'Legal notice'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: about_us
label: 'About us'
url: 'https://commission.europa.eu/about_en'
section: ec_core_column
weight: -4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: contact_us
label: 'Contact us'
url: 'https://commission.europa.eu/about/contact_en'
section: ec_core_column
weight: -3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: events
label: Events
url: 'https://commission.europa.eu/get-involved/events_en'
section: ec_core_column
weight: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: funding_and_tenders
label: 'Funding and tenders'
url: 'https://commission.europa.eu/funding-tenders_en'
section: ec_core_column
weight: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: jobs
label: Jobs
url: 'https://commission.europa.eu/get-involved/jobs-european-commission_en'
section: ec_core_column
weight: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: press_corner
label: 'Press corner'
url: 'https://ec.europa.eu/commission/presscorner/home/en'
section: ec_core_column
weight: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: priorities
label: Priorities
url: 'https://commission.europa.eu/priorities-2024-2029_en'
section: ec_core_column
weight: -2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: topics
label: Topics
url: 'https://commission.europa.eu/topics_en'
section: ec_core_column
weight: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
langcode: en
status: true
dependencies: { }
id: ec_core_column
label: 'EC Core column'
weight: 0
2 changes: 0 additions & 2 deletions config/schema/oe_corporate_blocks.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ oe_corporate_blocks.ec_data.footer:
mapping:
corporate_site_link:
type: oe_corporate_blocks.footer.link
class_navigation:
type: oe_corporate_blocks.footer.links
service_navigation:
type: oe_corporate_blocks.footer.links
legal_navigation:
Expand Down
52 changes: 52 additions & 0 deletions oe_corporate_blocks.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

declare(strict_types=1);

use Drupal\Component\Utility\Crypt;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\oe_corporate_site_info\SiteInformation;
Expand Down Expand Up @@ -112,3 +115,52 @@ function oe_corporate_blocks_preprocess_set_accessibility_link(array &$variables
$variables['accessibility_link'] = Url::fromUri($uri);
$cacheability->applyTo($variables);
}

/**
* Loads a config array from storage, determines the entity type and imports it.
*
* @param string $name
* The config name.
* @param \Drupal\Core\Config\StorageInterface $storage
* The configuration storage where the file is located.
* @param bool $create_if_missing
* If the configuration entity should be created if not found. Defaults to
* TRUE.
* @param bool $update_if_exists
* If the configuration entity should be updated if found. Defaults to TRUE.
*/
function _oe_corporate_blocks_import_config_from_file(string $name, StorageInterface $storage, bool $create_if_missing = TRUE, bool $update_if_exists = TRUE): void {
$config_manager = \Drupal::service('config.manager');
$entity_type_manager = \Drupal::entityTypeManager();

$config = $storage->read($name);
if (!$config) {
throw new \LogicException(sprintf('The configuration value named %s was not found in the storage.', $name));
}

$entity_type = $config_manager->getEntityTypeIdByName($name);
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_storage */
$entity_storage = $entity_type_manager->getStorage($entity_type);
$id_key = $entity_storage->getEntityType()->getKey('id');
$entity = $entity_storage->load($config[$id_key]);
if (!$entity instanceof ConfigEntityInterface) {
if (!$create_if_missing) {
throw new \LogicException(sprintf('The configuration entity "%s" was not found.', $config[$id_key]));
}

// When we create a new config, it usually means that we are also shipping
// it in the config/install folder so we want to make sure it gets the hash
// so Drupal treats it as a shipped config. This means that it gets exposed
// to be translated via the locale system as well.
$config['_core']['default_config_hash'] = Crypt::hashBase64(serialize($config));
$entity = $entity_storage->createFromStorageRecord($config);
$entity->save();

return;
}
if (!$update_if_exists) {
return;
}
$entity = $entity_storage->updateFromStorageRecord($entity, $config);
$entity->save();
}
18 changes: 18 additions & 0 deletions oe_corporate_blocks.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,21 @@ function oe_corporate_blocks_post_update_40010(&$sandbox): void {
}
}
}

/**
* Update EC footer data.
*/
function oe_corporate_blocks_post_update_50000(): void {
$config_path = \Drupal::service('extension.list.module')->getPath('oe_corporate_blocks') . '/config/post_update/50000_update_footer_data';
_oe_corporate_blocks_import_corporate_links($config_path);

$storage = new FileStorage($config_path);

foreach ($storage->listAll('oe_corporate_blocks.footer_link.section') as $name) {
_oe_corporate_blocks_import_config_from_file($name, $storage);
}

foreach ($storage->listAll('oe_corporate_blocks.footer_link.general') as $name) {
_oe_corporate_blocks_import_config_from_file($name, $storage);
}
}
Loading

0 comments on commit 4c3bb90

Please sign in to comment.