src/CoreBundle/Entity/Vehicles/ConfiguratorColor.php line 13

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity\Vehicles;
  3. use Application\Sonata\MediaBundle\Entity\Media;
  4. use Application\Sonata\MediaBundle\Entity\Gallery;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. /**
  8.  * ConfiguratorColor
  9.  */
  10. class ConfiguratorColor
  11. {
  12.     /**
  13.      * @var integer
  14.      */
  15.     private $id;
  16.     /**
  17.      * @var integer
  18.      */
  19.     private $state;
  20.     /**
  21.      * @var string
  22.      */
  23.     private $name_ru;
  24.     /**
  25.      * @var string
  26.      */
  27.     private $name_ua;
  28.     /**
  29.      * @var integer
  30.      */
  31.     private $price_usd;
  32.     /**
  33.      * @var integer
  34.      */
  35.     private $price_uah;
  36.     /**
  37.      * @var Media
  38.      */
  39.     private $image;
  40.     /**
  41.      * @var Gallery
  42.      */
  43.     private $gallery;
  44.     /**
  45.      * @var Vehicle
  46.      */
  47.     private $vehicle;
  48.     /**
  49.      * Get id
  50.      *
  51.      * @return integer
  52.      */
  53.     public function getId()
  54.     {
  55.         return $this->id;
  56.     }
  57.     /**
  58.      * Set state
  59.      *
  60.      * @param integer $state
  61.      *
  62.      * @return ConfiguratorColor
  63.      */
  64.     public function setState($state)
  65.     {
  66.         $this->state $state;
  67.         return $this;
  68.     }
  69.     /**
  70.      * Get state
  71.      *
  72.      * @return integer
  73.      */
  74.     public function getState()
  75.     {
  76.         return $this->state;
  77.     }
  78.     /**
  79.      * Set nameRu
  80.      *
  81.      * @param string $nameRu
  82.      *
  83.      * @return ConfiguratorColor
  84.      */
  85.     public function setNameRu($nameRu)
  86.     {
  87.         $this->name_ru $nameRu;
  88.         return $this;
  89.     }
  90.     /**
  91.      * Get nameRu
  92.      *
  93.      * @return string
  94.      */
  95.     public function getNameRu()
  96.     {
  97.         return $this->name_ru;
  98.     }
  99.     /**
  100.      * Set nameUa
  101.      *
  102.      * @param string $nameUa
  103.      *
  104.      * @return ConfiguratorColor
  105.      */
  106.     public function setNameUa($nameUa)
  107.     {
  108.         $this->name_ua $nameUa;
  109.         return $this;
  110.     }
  111.     /**
  112.      * Get nameUa
  113.      *
  114.      * @return string
  115.      */
  116.     public function getNameUa()
  117.     {
  118.         return $this->name_ua;
  119.     }
  120.     public function getName($locale)
  121.     {
  122.         return $locale == 'ru' $this->name_ru $this->name_ua;
  123.     }
  124.     public function calcPrice()
  125.     {
  126.         if($this->getPriceUah()) {
  127.             return $this->getPriceUah();
  128.         }
  129.         if($this->getPriceUsd()) {
  130.             $rate $this->getVehicle()->getDealer()->getRate();
  131.             return ceil($rate*$this->getPriceUsd());
  132.         }
  133.         return 0;
  134.     }
  135.     /**
  136.      * Set priceUsd
  137.      *
  138.      * @param integer $priceUsd
  139.      *
  140.      * @return ConfiguratorColor
  141.      */
  142.     public function setPriceUsd($priceUsd)
  143.     {
  144.         $this->price_usd $priceUsd;
  145.         return $this;
  146.     }
  147.     /**
  148.      * Get priceUsd
  149.      *
  150.      * @return integer
  151.      */
  152.     public function getPriceUsd()
  153.     {
  154.         return $this->price_usd;
  155.     }
  156.     /**
  157.      * Set priceUah
  158.      *
  159.      * @param integer $priceUah
  160.      *
  161.      * @return ConfiguratorColor
  162.      */
  163.     public function setPriceUah($priceUah)
  164.     {
  165.         $this->price_uah $priceUah;
  166.         return $this;
  167.     }
  168.     /**
  169.      * Get priceUah
  170.      *
  171.      * @return integer
  172.      */
  173.     public function getPriceUah()
  174.     {
  175.         return $this->price_uah;
  176.     }
  177.     /**
  178.      * Set image
  179.      *
  180.      * @param Media $image
  181.      *
  182.      * @return ConfiguratorColor
  183.      */
  184.     public function setImage(Media $image null)
  185.     {
  186.         $this->image $image;
  187.         return $this;
  188.     }
  189.     /**
  190.      * Get image
  191.      *
  192.      * @return Media
  193.      */
  194.     public function getImage()
  195.     {
  196.         return $this->image;
  197.     }
  198.     /**
  199.      * Set gallery
  200.      *
  201.      * @param Gallery $gallery
  202.      *
  203.      * @return ConfiguratorColor
  204.      */
  205.     public function setGallery(Gallery $gallery null)
  206.     {
  207.         $this->gallery $gallery;
  208.         return $this;
  209.     }
  210.     /**
  211.      * Get gallery
  212.      *
  213.      * @return Gallery
  214.      */
  215.     public function getGallery()
  216.     {
  217.         return $this->gallery;
  218.     }
  219.     /**
  220.      * Set vehicle
  221.      *
  222.      * @param Vehicle $vehicle
  223.      *
  224.      * @return ConfiguratorColor
  225.      */
  226.     public function setVehicle(Vehicle $vehicle null)
  227.     {
  228.         $this->vehicle $vehicle;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get vehicle
  233.      *
  234.      * @return Vehicle
  235.      */
  236.     public function getVehicle()
  237.     {
  238.         return $this->vehicle;
  239.     }
  240.     public function __toString()
  241.     {
  242.         return (string) $this->getNameRu();
  243.     }
  244.     /**
  245.      * @var Collection
  246.      */
  247.     private $equipments;
  248.     /**
  249.      * Constructor
  250.      */
  251.     public function __construct()
  252.     {
  253.         $this->equipments = new ArrayCollection();
  254.     }
  255.     /**
  256.      * Add equipment
  257.      *
  258.      * @param Equipment $equipment
  259.      *
  260.      * @return ConfiguratorColor
  261.      */
  262.     public function addEquipment(Equipment $equipment)
  263.     {
  264.         $this->equipments[] = $equipment;
  265.         return $this;
  266.     }
  267.     /**
  268.      * Remove equipment
  269.      *
  270.      * @param Equipment $equipment
  271.      */
  272.     public function removeEquipment(Equipment $equipment)
  273.     {
  274.         $this->equipments->removeElement($equipment);
  275.     }
  276.     /**
  277.      * Get equipments
  278.      *
  279.      * @return Collection
  280.      */
  281.     public function getEquipments()
  282.     {
  283.         return $this->equipments;
  284.     }
  285.     public function clearEquipments()
  286.     {
  287.         $this->equipments->clear();
  288.     }
  289. }