-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UCPKN-3176: Accessibility statement link in the footer. #1488
Conversation
b572a9a
to
adb2912
Compare
adb2912
to
fa7d00d
Compare
c5bc68a
to
9ec93bb
Compare
oe_theme.theme
Outdated
if (!function_exists('oe_corporate_blocks_preprocess_set_accessibility_link')) { | ||
return; | ||
} | ||
$cacheability = CacheableMetadata::createFromRenderArray($variables); | ||
$configuration = \Drupal::configFactory()->get(SiteInformation::CONFIG_NAME); | ||
$cacheability->addCacheableDependency($configuration); | ||
/** @var \Drupal\oe_corporate_site_info\SiteInformationInterface $site_information */ | ||
$site_information = \Drupal::service('oe_corporate_site_info.site_information'); | ||
if (!$site_information->hasAccessibilityLink()) { | ||
$cacheability->applyTo($variables); | ||
|
||
oe_corporate_blocks_preprocess_set_accessibility_link($variables); | ||
|
||
if (!isset($variables['accessibility_link']) || !$variables['accessibility_link'] instanceof Url) { | ||
return; | ||
} | ||
$uri = $site_information->getAccessibilityLink(); | ||
$uri_parts = parse_url($uri); | ||
if ($uri_parts['scheme'] === 'entity') { | ||
[$entity_type_id, $entity_id] = explode('/', $uri_parts['path'], 2); | ||
$entity = \Drupal::entityTypeManager()->getStorage($entity_type_id)->load($entity_id); | ||
if ($entity instanceof NodeInterface) { | ||
$cacheability->addCacheableDependency($entity); | ||
$access = $entity->access('view', \Drupal::currentUser(), TRUE); | ||
$cacheability->addCacheableDependency($access); | ||
if (!$access->isAllowed()) { | ||
$cacheability->applyTo($variables); | ||
// Do not show the button if access to the node is forbidden. | ||
return; | ||
} | ||
} | ||
} | ||
$url = Url::fromUri($uri)->toString(); | ||
|
||
$variables['accessibility_link'] = $url; | ||
$cacheability->applyTo($variables); | ||
$variables['accessibility_link'] = $variables['accessibility_link']->toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the need of manually calling the preprocess function as it's already set in the two theme implementations.
The accessibility_link variable is already there when I debugged the method, and the toString() method is not needed as far as I can see, because it's called by twig when rendering. I have commented out this method and the links were showing ok for me. The only limitation that we need to be sure to put is a constraint in both oe_theme and oe_corporate_blocks to make sure that previous versions of either components are not used with an older version of the other.
Or, alternatively, we keep the code in this method, leave a todo for the next major, and bail out if the accessibility_link is already there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the function entirely and marked the conflict.
aa0973d
to
67c41ac
Compare
67c41ac
to
cee5e2f
Compare
…oe_corporate_blocks module.
7b7fb7a
to
6981fe6
Compare
OPENEUROPA-[Insert ticket number here]
Description
The accessibility statement link logic is in the oe_coporate_blocks module from now. See openeuropa/oe_corporate_blocks#155
Change log
Commands