I created a custom entity (Representative) using the Drupal Console generate:entity:content
command.
The entity works correctly. I added fields, added some content, and I can query this entity.
My problem is that I can't render this entity in a template file, using the following code.
$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).
Can anyone help?