<?phpnamespace CoreBundle\Entity\Vehicles;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;/** * FAQ */class Faq{ /** * @var integer */ private $id; /** * @var integer */ private $temp_id; /** * @var Collection */ private $content; /** * @var Vehicle */ private $vehicle; /** * Constructor */ public function __construct() { $this->content = new ArrayCollection(); $this->content->add((new FaqContent())->setLanguage('ru')->setFaq($this)); $this->content->add((new FaqContent())->setLanguage('ua')->setFaq($this)); } public function __toString() { if(!$this->content->count()) { return ''; } return (string) $this->content->first()->getTitle(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set tempId * * @param integer $tempId * * @return Faq */ public function setTempId($tempId) { $this->temp_id = $tempId; return $this; } /** * Get tempId * * @return integer */ public function getTempId() { return $this->temp_id; } /** * Add content * * @param FAQContent $content * * @return Faq */ public function addContent(FAQContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param FAQContent $content */ public function removeContent(FAQContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } /** * Set vehicle * * @param Vehicle $vehicle * * @return Faq */ public function setVehicle(Vehicle $vehicle = null) { $this->vehicle = $vehicle; return $this; } /** * Get vehicle * * @return Vehicle */ public function getVehicle() { return $this->vehicle; } public function getContentByLocale($locale) { /** @var FaqContent $item */ foreach ($this->getContent() as $item) { if($item->getLanguage() == $locale) { return $item; } } return $this->getContent()->first(); }}