src/CoreBundle/Entity/City.php line 11

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. /**
  6.  * City
  7.  */
  8. class City
  9. {
  10.     /**
  11.      * @var int
  12.      */
  13.     private $id;
  14.     /**
  15.      * @var string|null
  16.      */
  17.     private $nameRu;
  18.     /**
  19.      * @var string|null
  20.      */
  21.     private $nameUa;
  22.     /**
  23.      * @var Collection
  24.      */
  25.     private $dealer;
  26.     /**
  27.      * Constructor
  28.      */
  29.     public function __construct()
  30.     {
  31.         $this->dealer = new ArrayCollection();
  32.     }
  33.     /**
  34.      * Get id.
  35.      *
  36.      * @return int
  37.      */
  38.     public function getId()
  39.     {
  40.         return $this->id;
  41.     }
  42.     /**
  43.      * Set nameRu.
  44.      *
  45.      * @param string|null $nameRu
  46.      *
  47.      * @return City
  48.      */
  49.     public function setNameRu($nameRu null)
  50.     {
  51.         $this->nameRu $nameRu;
  52.         return $this;
  53.     }
  54.     /**
  55.      * Get nameRu.
  56.      *
  57.      * @return string|null
  58.      */
  59.     public function getNameRu()
  60.     {
  61.         return $this->nameRu;
  62.     }
  63.     /**
  64.      * Set nameUa.
  65.      *
  66.      * @param string|null $nameUa
  67.      *
  68.      * @return City
  69.      */
  70.     public function setNameUa($nameUa null)
  71.     {
  72.         $this->nameUa $nameUa;
  73.         return $this;
  74.     }
  75.     /**
  76.      * Get nameUa.
  77.      *
  78.      * @return string|null
  79.      */
  80.     public function getNameUa()
  81.     {
  82.         return $this->nameUa;
  83.     }
  84.     /**
  85.      * Add dealer.
  86.      *
  87.      * @param Dealer $dealer
  88.      *
  89.      * @return City
  90.      */
  91.     public function addDealer(Dealer $dealer)
  92.     {
  93.         $this->dealer[] = $dealer;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Remove dealer.
  98.      *
  99.      * @param Dealer $dealer
  100.      *
  101.      * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  102.      */
  103.     public function removeDealer(Dealer $dealer)
  104.     {
  105.         return $this->dealer->removeElement($dealer);
  106.     }
  107.     /**
  108.      * Get dealer.
  109.      *
  110.      * @return Collection
  111.      */
  112.     public function getDealer()
  113.     {
  114.         return $this->dealer;
  115.     }
  116.     public function getCityByLocale($locale) {
  117.         if($locale == 'ru') {
  118.             return $this->getNameRu();
  119.         }
  120.         return $this->getNameUa();
  121.     }
  122.     public function __toString()
  123.     {
  124.         return (string) $this->getNameRu();
  125.     }
  126. }