I have two Entity class: House and Car.
in Entity House class i have method:
<?php
namespace Acme\HouseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* House
*/
class House {
//...
public function getRandomCar()
{
$em = $this->getDoctrine()->getManager();
$car = $em->getRepository('AcmeCarBundle:Car')->find(rand(0,100));
return $car->getName();
}
}
but i dont have access to Doctrine in my Entity House class. How can i make it?