I created a custom entity called 'Representative' using the drupal console 'generate:entity:content' command.
The entity works correctly I added a bundle of fields to it, added some content, and can query this entity using the EntityTypeManager query.
My problem is - I can't render this entity in twig. When I pass this entity to the render array:
$build = [ '#theme' => 'representatives', '#representative_entity' => $representative ];
I get the following error:
Exception: Object of type
Drupal\kelk_representatives\Entity\RepresentativeEntity cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 476 of core/lib/Drupal/Core/Template/TwigExtension.php).
(I was using drupal console to automatically generate the twig files and preprocess functions)..
Can anyone help?