$key .= '.' .
$entity->
language()->
getId();
} return $key;
} /**
* {@inheritdoc}
*/
public function deriveContextsFromRoute($value,
$definition,
$name, array
$defaults) { $contexts =
[];
if ($entity =
$this->
extractEntityFromRoute($value,
$defaults)) { $contexts['entity'
] = EntityContext::
fromEntity($entity);
// @todo Expand to work for all view modes in
// https://www.drupal.org/node/2907413.
$view_mode = 'full';
// Retrieve the actual view mode from the returned view display as the
// requested view mode may not exist and a fallback will be used.
$view_mode = LayoutBuilderEntityViewDisplay::
collectRenderDisplay($entity,
$view_mode)->
getMode();
$contexts['view_mode'
] =
new Context(new ContextDefinition('string'
),
$view_mode);
} return $contexts;
}