<?phpnamespace ImporterBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use Doctrine\Common\Collections\Collection;/** * Vacancy */class Vacancy{ /** * @var integer */ private $id; /** * @var integer */ private $state; /** * @var boolean */ private $hot; /** * @var Media */ private $image; /** * @var Collection */ private $content; /** * @var Dealer */ private $dealer; /** * Constructor */ public function __construct() { $this->content = new ArrayCollection(); $this->content->add((new VacancyContent())->setLanguage('ru')); $this->content->add((new VacancyContent())->setLanguage('ua')); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set state * * @param integer $state * * @return Vacancy */ public function setState($state) { $this->state = $state; return $this; } /** * Get state * * @return integer */ public function getState() { return $this->state > 0; } /** * Set hot * * @param boolean $hot * * @return Vacancy */ public function setHot($hot) { $this->hot = $hot; return $this; } /** * Get hot * * @return boolean */ public function getHot() { return $this->hot; } /** * Set image * * @param Media $image * * @return Vacancy */ public function setImage(Media $image = null) { $this->image = $image; return $this; } /** * Get image * * @return Media */ public function getImage() { return $this->image; } /** * Add content * * @param VacancyContent $content * * @return Vacancy */ public function addContent(VacancyContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param VacancyContent $content */ public function removeContent(VacancyContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } /** * Set dealer * * @param Dealer $dealer * * @return Vacancy */ public function setDealer(Dealer $dealer = null) { $this->dealer = $dealer; return $this; } /** * Get dealer * * @return Dealer */ public function getDealer() { return $this->dealer; } /** * @return string */ public function __toString() { return (string) $this->getTitle(); } /** * @param $locale * @return VacancyContent|mixed */ public function getContentByLang($locale) { /** @var VacancyContent $row */ foreach ($this->content as $row) { if($row->getLanguage() == $locale) return $row; } return $this->content->first(); } /** * @return string */ public function getTitle($locale = null) { $this->getContentByLang($locale)->getTitle(); }}