<?phpnamespace CoreBundle\Entity\Vehicles;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use Application\Sonata\MediaBundle\Entity\Gallery;use Doctrine\Common\Collections\Collection;/** * Feature */class Feature{    /**     * @var integer     */    private $id;    /**     * @var integer     */    private $temp_id;    /**     * @var Media     */    private $image;    /**     * @var Collection     */    private $content;    /**     * @var Vehicle     */    private $vehicle;    /**     * @var FeatureGroup     */    private $group;    /**     * Constructor     */    public function __construct()    {        $this->content = new ArrayCollection();        $this->content->add((new FeatureContent())->setLanguage('ru')->setFeature($this));        $this->content->add((new FeatureContent())->setLanguage('ua')->setFeature($this));    }    /**     * Set id     *     * @param integer $id     *     * @return Feature     */    public function setId($id)    {        $this->id = $id;        return $this;    }    /**     * Get id     *     * @return integer     */    public function getId()    {        return $this->id;    }    /**     * Set tempId     *     * @param integer $tempId     *     * @return Feature     */    public function setTempId($tempId)    {        $this->temp_id = $tempId;        return $this;    }    /**     * Get tempId     *     * @return integer     */    public function getTempId()    {        return $this->temp_id;    }    /**     * Set image     *     * @param Media $image     *     * @return Feature     */    public function setImage(Media $image = null)    {        $this->image = $image;        return $this;    }    /**     * Get image     *     * @return Media     */    public function getImage()    {        return $this->image;    }    /**     * Add content     *     * @param FeatureContent $content     *     * @return Feature     */    public function addContent(FeatureContent $content)    {        $this->content[] = $content;        return $this;    }    /**     * Remove content     *     * @param FeatureContent $content     */    public function removeContent(FeatureContent $content)    {        $this->content->removeElement($content);    }    /**     * Get content     *     * @return Collection     */    public function getContent()    {        return $this->content;    }    public function getContentByLocale($locale)    {        /** @var FeatureContent $item */        foreach ($this->getContent() as $item) {            if($item->getLanguage() == $locale) {                return $item;            }        }        return $this->getContent()->first();    }    /**     * Set vehicle     *     * @param Vehicle $vehicle     *     * @return Feature     */    public function setVehicle(Vehicle $vehicle = null)    {        $this->vehicle = $vehicle;        return $this;    }    /**     * Get vehicle     *     * @return Vehicle     */    public function getVehicle()    {        return $this->vehicle;    }    /**     * Set group     *     * @param FeatureGroup $group     *     * @return Feature     */    public function setGroup(FeatureGroup $group = null)    {        $this->group = $group;        return $this;    }    /**     * Get group     *     * @return FeatureGroup     */    public function getGroup()    {        return $this->group;    }    public function __toString()    {        if(!$this->content->count()) {            return '';        }        return (string) $this->content->first()->getTitle();    }    /**     * @var Gallery     */    private $video;    /**     * Set video     *     * @param Gallery $video     *     * @return Feature     */    public function setVideo(Gallery $video = null)    {        $this->video = $video;        return $this;    }    /**     * Get video     *     * @return Gallery     */    public function getVideo()    {        return $this->video;    }}