@@ 109-123 (lines=15) @@ | ||
106 | $entityType = $this->entityTypeManager->getDefinition($pluginDefinition['entity_type']); |
|
107 | yield (new CacheableValue(NULL))->addCacheTags($entityType->getListCacheTags()); |
|
108 | } |
|
109 | else { |
|
110 | /** @var \Drupal\Core\Entity\EntityInterface $entity */ |
|
111 | $access = $entity->access('view', NULL, TRUE); |
|
112 | ||
113 | if ($access->isAllowed()) { |
|
114 | if (isset($args['language']) && $args['language'] != $entity->language()->getId() && $entity instanceof TranslatableInterface) { |
|
115 | $entity = $entity->getTranslation($args['language']); |
|
116 | } |
|
117 | ||
118 | yield $entity->addCacheableDependency($access); |
|
119 | } |
|
120 | else { |
|
121 | yield new CacheableValue(NULL, [$access]); |
|
122 | } |
|
123 | } |
|
124 | }; |
|
125 | } |
|
126 |
@@ 102-114 (lines=13) @@ | ||
99 | yield new CacheableValue(NULL, [$metadata]); |
|
100 | } |
|
101 | /** @var \Drupal\Core\Access\AccessResultInterface $access */ |
|
102 | else if (($access = $entity->access('view', NULL, TRUE)) && $access->isAllowed()) { |
|
103 | if ($entity instanceof TranslatableInterface && isset($args['language']) && $args['language'] != $entity->language()->getId()) { |
|
104 | $entity = $entity->getTranslation($args['language']); |
|
105 | } |
|
106 | ||
107 | yield new CacheableValue($entity, [$access]); |
|
108 | } |
|
109 | else { |
|
110 | // If the entity exists but we do not grant access to it, we still want |
|
111 | // to have it's cache metadata in the output because future changes to |
|
112 | // the entity might affect its visibility for the user. |
|
113 | yield new CacheableValue(NULL, [$access]); |
|
114 | } |
|
115 | } |
|
116 | ||
117 | } |