src/ImporterBundle/Entity/Vacancy.php line 12

Open in your IDE?
  1. <?php
  2. namespace ImporterBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Application\Sonata\MediaBundle\Entity\Media;
  5. use Doctrine\Common\Collections\Collection;
  6. /**
  7.  * Vacancy
  8.  */
  9. class Vacancy
  10. {
  11.     /**
  12.      * @var integer
  13.      */
  14.     private $id;
  15.     /**
  16.      * @var integer
  17.      */
  18.     private $state;
  19.     /**
  20.      * @var boolean
  21.      */
  22.     private $hot;
  23.     /**
  24.      * @var Media
  25.      */
  26.     private $image;
  27.     /**
  28.      * @var Collection
  29.      */
  30.     private $content;
  31.     /**
  32.      * @var Dealer
  33.      */
  34.     private $dealer;
  35.     /**
  36.      * Constructor
  37.      */
  38.     public function __construct()
  39.     {
  40.         $this->content = new ArrayCollection();
  41.         $this->content->add((new VacancyContent())->setLanguage('ru'));
  42.         $this->content->add((new VacancyContent())->setLanguage('ua'));
  43.     }
  44.     /**
  45.      * Get id
  46.      *
  47.      * @return integer
  48.      */
  49.     public function getId()
  50.     {
  51.         return $this->id;
  52.     }
  53.     /**
  54.      * Set state
  55.      *
  56.      * @param integer $state
  57.      *
  58.      * @return Vacancy
  59.      */
  60.     public function setState($state)
  61.     {
  62.         $this->state $state;
  63.         return $this;
  64.     }
  65.     /**
  66.      * Get state
  67.      *
  68.      * @return integer
  69.      */
  70.     public function getState()
  71.     {
  72.         return $this->state 0;
  73.     }
  74.     /**
  75.      * Set hot
  76.      *
  77.      * @param boolean $hot
  78.      *
  79.      * @return Vacancy
  80.      */
  81.     public function setHot($hot)
  82.     {
  83.         $this->hot $hot;
  84.         return $this;
  85.     }
  86.     /**
  87.      * Get hot
  88.      *
  89.      * @return boolean
  90.      */
  91.     public function getHot()
  92.     {
  93.         return $this->hot;
  94.     }
  95.     /**
  96.      * Set image
  97.      *
  98.      * @param Media $image
  99.      *
  100.      * @return Vacancy
  101.      */
  102.     public function setImage(Media $image null)
  103.     {
  104.         $this->image $image;
  105.         return $this;
  106.     }
  107.     /**
  108.      * Get image
  109.      *
  110.      * @return Media
  111.      */
  112.     public function getImage()
  113.     {
  114.         return $this->image;
  115.     }
  116.     /**
  117.      * Add content
  118.      *
  119.      * @param VacancyContent $content
  120.      *
  121.      * @return Vacancy
  122.      */
  123.     public function addContent(VacancyContent $content)
  124.     {
  125.         $this->content[] = $content;
  126.         return $this;
  127.     }
  128.     /**
  129.      * Remove content
  130.      *
  131.      * @param VacancyContent $content
  132.      */
  133.     public function removeContent(VacancyContent $content)
  134.     {
  135.         $this->content->removeElement($content);
  136.     }
  137.     /**
  138.      * Get content
  139.      *
  140.      * @return Collection
  141.      */
  142.     public function getContent()
  143.     {
  144.         return $this->content;
  145.     }
  146.     /**
  147.      * Set dealer
  148.      *
  149.      * @param Dealer $dealer
  150.      *
  151.      * @return Vacancy
  152.      */
  153.     public function setDealer(Dealer $dealer null)
  154.     {
  155.         $this->dealer $dealer;
  156.         return $this;
  157.     }
  158.     /**
  159.      * Get dealer
  160.      *
  161.      * @return Dealer
  162.      */
  163.     public function getDealer()
  164.     {
  165.         return $this->dealer;
  166.     }
  167.     /**
  168.      * @return string
  169.      */
  170.     public function __toString()
  171.     {
  172.         return (string) $this->getTitle();
  173.     }
  174.     /**
  175.      * @param $locale
  176.      * @return VacancyContent|mixed
  177.      */
  178.     public function getContentByLang($locale) {
  179.         /** @var VacancyContent $row */
  180.         foreach ($this->content as $row) {
  181.             if($row->getLanguage() == $locale) return $row;
  182.         }
  183.         return $this->content->first();
  184.     }
  185.     /**
  186.      * @return string
  187.      */
  188.     public function getTitle($locale null) {
  189.          $this->getContentByLang($locale)->getTitle();
  190.     }
  191. }