|
|
|
@ -536,7 +536,7 @@ class TwigExtension extends AbstractExtension {
|
|
|
|
|
->addCacheTags($entity_type->getListCacheTags()) |
|
|
|
|
->addCacheContexts($entity_type->getListCacheContexts()); |
|
|
|
|
|
|
|
|
|
/* @var $blocks \Drupal\block\BlockInterface[] */ |
|
|
|
|
/** @var \Drupal\block\BlockInterface[] $blocks */ |
|
|
|
|
foreach ($blocks as $id => $block) { |
|
|
|
|
$access = $block->access('view', NULL, TRUE); |
|
|
|
|
$cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($access)); |
|
|
|
@ -1054,7 +1054,7 @@ class TwigExtension extends AbstractExtension {
|
|
|
|
|
* in an <img> tag. Requesting the URL will cause the image to be created. |
|
|
|
|
*/ |
|
|
|
|
public function imageStyle($path, $style) { |
|
|
|
|
|
|
|
|
|
// @phpcs:ignore DrupalPractice.Objects.GlobalClass.GlobalClass |
|
|
|
|
if (!$image_style = ImageStyle::load($style)) { |
|
|
|
|
trigger_error(sprintf('Could not load image style %s.', $style)); |
|
|
|
|
return; |
|
|
|
@ -1336,17 +1336,17 @@ class TwigExtension extends AbstractExtension {
|
|
|
|
|
/** |
|
|
|
|
* Returns the translation for the given entity. |
|
|
|
|
* |
|
|
|
|
* @param object $entity |
|
|
|
|
* @param \Drupal\Core\Entity\EntityInterface $entity |
|
|
|
|
* The entity to get the translation from. |
|
|
|
|
* |
|
|
|
|
* @param string $langcode |
|
|
|
|
* (optional) For which language the translation should be looked for, |
|
|
|
|
* defaults to the current language context. |
|
|
|
|
* |
|
|
|
|
* @return EntityInterface |
|
|
|
|
* @return \Drupal\Core\Entity\EntityInterface |
|
|
|
|
* The appropriate translation for the given language context. |
|
|
|
|
*/ |
|
|
|
|
public function entityTranslation(EntityInterface $entity, $langcode = NULL) { |
|
|
|
|
return \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|