src/DcSiteBundle/Entity/Vacancy.php line 13

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