I have an entity,
// src/Acme/StoreBundle/Entity/Product.php
namespace Acme\StoreBundle\Entity;
class Product
{
protected $name;
protected $price;
protected $description;
}
I when I get a product record I want to join the name and description. Something like,
// src/Acme/StoreBundle/Entity/Product.php
namespace Acme\StoreBundle\Entity;
class Product
{
protected $name;
protected $price;
protected $description;
protected $heading;
public function __construct()
{
parent::__construct();
$this->heading = $this->name . ' ' . $this->description;
}
}
I've tried setting heading on the preLoad event, in the constructor. After its creation and before serialising. Nothing seems to work. How can I do this?