public static function ContentEntityTypeResolver::getRenderedOutput in GraphQL 8.2
Same name and namespace in other branches
- 8 src/TypeResolver/ContentEntityTypeResolver.php \Drupal\graphql\TypeResolver\ContentEntityTypeResolver::getRenderedOutput()
Property value resolver callback for getting the rendered entity output.
Parameters
\Drupal\Core\Entity\Plugin\DataType\EntityAdapter $data: The parent complex data structure to extract the entity from.
Return value
mixed The rendered entity using the given view mode.
File
- src/
TypeResolver/ ContentEntityTypeResolver.php, line 350
Class
- ContentEntityTypeResolver
- Resolves the schema for content entities.
Namespace
Drupal\graphql\TypeResolverCode
public static function getRenderedOutput(EntityAdapter $data, $args, $b, $c, $d, $e, $f, $config) {
if ($data instanceof AccessibleInterface && !$data
->access('view')) {
return NULL;
}
// @todo Fix injection of container dependencies in resolver functions.
$viewBuilder = \Drupal::entityManager()
->getViewBuilder($config['type']);
$renderer = \Drupal::service('renderer');
$output = $viewBuilder
->view($data
->getValue(), $args['viewMode'] ?: NULL);
return $renderer
->render($output);
}