src/DcSiteBundle/Entity/ServiceWork.php line 15

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Entity;
  3. use CoreBundle\Entity\Dealer;
  4. use Application\Sonata\MediaBundle\Entity\Gallery;
  5. use Application\Sonata\MediaBundle\Entity\Media;
  6. use CoreBundle\Entity\AccessoriesReview;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. /**
  10.  * ServiceWork
  11.  */
  12. class ServiceWork
  13. {
  14.     /**
  15.      * @var integer
  16.      */
  17.     private $id;
  18.     /**
  19.      * @var integer
  20.      */
  21.     private $mileage;
  22.     /**
  23.      * @var string
  24.      */
  25.     private $uid_1c;
  26.     /**
  27.      * @var Collection
  28.      */
  29.     private $parts;
  30.     /**
  31.      * @var Collection
  32.      */
  33.     private $jobs;
  34.     /**
  35.      * @var ServiceVariation
  36.      */
  37.     private $variation;
  38.     /**
  39.      * @var Dealer
  40.      */
  41.     private $dealer;
  42.     /**
  43.      * @var string
  44.      */
  45.     private $articul;
  46.     /**
  47.      * @var Collection
  48.      */
  49.     private $work_group_relations;
  50.     /**
  51.      * Constructor
  52.      */
  53.     public function __construct()
  54.     {
  55.         $this->parts = new ArrayCollection();
  56.         $this->jobs = new ArrayCollection();
  57.         $this->variations = new ArrayCollection();
  58.         $this->content = new ArrayCollection();
  59.         $this->content->add((new ServiceWorkContent())->setLanguage('ru'));
  60.         $this->content->add((new ServiceWorkContent())->setLanguage('ua'));
  61.     }
  62.     public function getArticul()
  63.     {
  64.         return $this->articul;
  65.     }
  66.     public function setArticul($articul)
  67.     {
  68.         $this->articul $articul;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return string
  73.      */
  74.     public function __toString()
  75.     {
  76.         return (string) $this->getTitle();
  77.     }
  78.     /**
  79.      * Get id
  80.      *
  81.      * @return integer
  82.      */
  83.     public function getId()
  84.     {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * Set mileage
  89.      *
  90.      * @param integer $mileage
  91.      *
  92.      * @return ServiceWork
  93.      */
  94.     public function setMileage($mileage)
  95.     {
  96.         $this->mileage $mileage;
  97.         return $this;
  98.     }
  99.     /**
  100.      * Get mileage
  101.      *
  102.      * @return integer
  103.      */
  104.     public function getMileage()
  105.     {
  106.         return $this->mileage;
  107.     }
  108.     /**
  109.      * Set uid1c
  110.      *
  111.      * @param string $uid1c
  112.      *
  113.      * @return ServiceWork
  114.      */
  115.     public function setUid1c($uid1c)
  116.     {
  117.         $this->uid_1c $uid1c;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get uid1c
  122.      *
  123.      * @return string
  124.      */
  125.     public function getUid1c()
  126.     {
  127.         return $this->uid_1c;
  128.     }
  129.     /**
  130.      * Add part
  131.      *
  132.      * @param ServiceWorkPart $part
  133.      *
  134.      * @return ServiceWork
  135.      */
  136.     public function addPart(ServiceWorkPart $part)
  137.     {
  138.         $this->parts[] = $part;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Remove part
  143.      *
  144.      * @param ServiceWorkPart $part
  145.      */
  146.     public function removePart(ServiceWorkPart $part)
  147.     {
  148.         $this->parts->removeElement($part);
  149.     }
  150.     /**
  151.      * Get parts
  152.      *
  153.      * @return Collection
  154.      */
  155.     public function getParts()
  156.     {
  157.         return $this->parts;
  158.     }
  159.     /**
  160.      * Add job
  161.      *
  162.      * @param ServiceWorkJob $job
  163.      *
  164.      * @return ServiceWork
  165.      */
  166.     public function addJob(ServiceWorkJob $job)
  167.     {
  168.         $this->jobs[] = $job;
  169.         return $this;
  170.     }
  171.     /**
  172.      * Remove job
  173.      *
  174.      * @param ServiceWorkJob $job
  175.      */
  176.     public function removeJob(ServiceWorkJob $job)
  177.     {
  178.         $this->jobs->removeElement($job);
  179.     }
  180.     /**
  181.      * Get jobs
  182.      *
  183.      * @return Collection
  184.      */
  185.     public function getJobs()
  186.     {
  187.         return $this->jobs;
  188.     }
  189.     /**
  190.      * Set variation
  191.      *
  192.      * @param ServiceVariation $variation
  193.      *
  194.      * @return ServiceWork
  195.      */
  196.     public function setVariation(ServiceVariation $variation null)
  197.     {
  198.         $this->variation $variation;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Get variation
  203.      *
  204.      * @return ServiceVariation
  205.      */
  206.     public function getVariation()
  207.     {
  208.         return $this->variation;
  209.     }
  210.     /**
  211.      * Set dealer
  212.      *
  213.      * @param Dealer $dealer
  214.      *
  215.      * @return ServiceWork
  216.      */
  217.     public function setDealer(Dealer $dealer null)
  218.     {
  219.         $this->dealer $dealer;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get dealer
  224.      *
  225.      * @return Dealer
  226.      */
  227.     public function getDealer()
  228.     {
  229.         return $this->dealer;
  230.     }
  231.     /**
  232.      * @var integer
  233.      */
  234.     private $is_regulations;
  235.     /**
  236.      * Set isRegulations
  237.      *
  238.      * @param integer $isRegulations
  239.      *
  240.      * @return ServiceWork
  241.      */
  242.     public function setIsRegulations($isRegulations)
  243.     {
  244.         $this->is_regulations $isRegulations;
  245.         return $this;
  246.     }
  247.     /**
  248.      * Get isRegulations
  249.      *
  250.      * @return integer
  251.      */
  252.     public function getIsRegulations()
  253.     {
  254.         return $this->is_regulations;
  255.     }
  256.     /**
  257.      * @var string
  258.      */
  259.     private $title_ru;
  260.     /**
  261.      * @var string
  262.      */
  263.     private $title_ua;
  264.     public function getTitle($locale 'ua')
  265.     {
  266.         return $locale == 'ru' $this->getTitleRu() : $this->getTitleUa();
  267.     }
  268.     /**
  269.      * Set titleRu
  270.      *
  271.      * @param string $titleRu
  272.      *
  273.      * @return ServiceWork
  274.      */
  275.     public function setTitleRu($titleRu)
  276.     {
  277.         $this->title_ru $titleRu;
  278.         return $this;
  279.     }
  280.     /**
  281.      * Get titleRu
  282.      *
  283.      * @return string
  284.      */
  285.     public function getTitleRu()
  286.     {
  287.         return $this->title_ru;
  288.     }
  289.     /**
  290.      * Set titleUa
  291.      *
  292.      * @param string $titleUa
  293.      *
  294.      * @return ServiceWork
  295.      */
  296.     public function setTitleUa($titleUa)
  297.     {
  298.         $this->title_ua $titleUa;
  299.         return $this;
  300.     }
  301.     /**
  302.      * Get titleUa
  303.      *
  304.      * @return string
  305.      */
  306.     public function getTitleUa()
  307.     {
  308.         return $this->title_ua;
  309.     }
  310.     /**
  311.      * @var ServiceWorkGroup
  312.      */
  313.     private $group;
  314.     /**
  315.      * Set group
  316.      *
  317.      * @param ServiceWorkGroup $group
  318.      *
  319.      * @return ServiceWork
  320.      */
  321.     public function setGroup(ServiceWorkGroup $group null)
  322.     {
  323.         $this->group $group;
  324.         return $this;
  325.     }
  326.     /**
  327.      * Get group
  328.      *
  329.      * @return ServiceWorkGroup
  330.      */
  331.     public function getGroup()
  332.     {
  333.         return $this->group;
  334.     }
  335.     /**
  336.      * @var integer
  337.      */
  338.     private $is_post_warranty;
  339.     /**
  340.      * Set isPostWarranty
  341.      *
  342.      * @param integer $isPostWarranty
  343.      *
  344.      * @return ServiceWork
  345.      */
  346.     public function setIsPostWarranty($isPostWarranty)
  347.     {
  348.         $this->is_post_warranty $isPostWarranty;
  349.         return $this;
  350.     }
  351.     /**
  352.      * Get isPostWarranty
  353.      *
  354.      * @return integer
  355.      */
  356.     public function getIsPostWarranty()
  357.     {
  358.         return $this->is_post_warranty;
  359.     }
  360.     /**
  361.      * @var integer
  362.      */
  363.     private $position;
  364.     /**
  365.      * Set position
  366.      *
  367.      * @param integer $position
  368.      *
  369.      * @return ServiceWork
  370.      */
  371.     public function setPosition($position)
  372.     {
  373.         $this->position $position;
  374.         return $this;
  375.     }
  376.     /**
  377.      * Get position
  378.      *
  379.      * @return integer
  380.      */
  381.     public function getPosition()
  382.     {
  383.         return $this->position;
  384.     }
  385.     /**
  386.      * @var string
  387.      */
  388.     private $title;
  389.     /**
  390.      * @var string
  391.      */
  392.     private $url;
  393.     /**
  394.      * @var Gallery
  395.      */
  396.     private $gallery;
  397.     /**
  398.      * @var Collection
  399.      */
  400.     private $content;
  401.     /**
  402.      * @var Collection
  403.      */
  404.     private $categories;
  405.     /**
  406.      * Set title
  407.      *
  408.      * @param string $title
  409.      *
  410.      * @return ServiceWork
  411.      */
  412.     public function setTitle($title)
  413.     {
  414.         $this->title $title;
  415.         return $this;
  416.     }
  417.     /**
  418.      * Set url
  419.      *
  420.      * @param string $url
  421.      *
  422.      * @return ServiceWork
  423.      */
  424.     public function setUrl($url)
  425.     {
  426.         $this->url $url;
  427.         return $this;
  428.     }
  429.     /**
  430.      * Get url
  431.      *
  432.      * @return string
  433.      */
  434.     public function getUrl()
  435.     {
  436.         return $this->url;
  437.     }
  438.     /**
  439.      * Set gallery
  440.      *
  441.      * @param Gallery $gallery
  442.      *
  443.      * @return ServiceWork
  444.      */
  445.     public function setGallery(Gallery $gallery null)
  446.     {
  447.         $this->gallery $gallery;
  448.         return $this;
  449.     }
  450.     /**
  451.      * Get gallery
  452.      *
  453.      * @return Gallery
  454.      */
  455.     public function getGallery()
  456.     {
  457.         return $this->gallery;
  458.     }
  459.     /**
  460.      * Add content
  461.      *
  462.      * @param ServiceWorkContent $content
  463.      *
  464.      * @return ServiceWork
  465.      */
  466.     public function addContent(ServiceWorkContent $content)
  467.     {
  468.         $this->content[] = $content;
  469.         return $this;
  470.     }
  471.     /**
  472.      * Remove content
  473.      *
  474.      * @param ServiceWorkContent $content
  475.      */
  476.     public function removeContent(ServiceWorkContent $content)
  477.     {
  478.         $this->content->removeElement($content);
  479.     }
  480.     /**
  481.      * Get content
  482.      *
  483.      * @return Collection
  484.      */
  485.     public function getContent()
  486.     {
  487.         return $this->content;
  488.     }
  489.     /**
  490.      * Add category
  491.      *
  492.      * @param ServiceWorkCategory $category
  493.      *
  494.      * @return ServiceWork
  495.      */
  496.     public function addCategory(ServiceWorkCategory $category)
  497.     {
  498.         $this->categories[] = $category;
  499.         return $this;
  500.     }
  501.     /**
  502.      * Remove category
  503.      *
  504.      * @param ServiceWorkCategory $category
  505.      */
  506.     public function removeCategory(ServiceWorkCategory $category)
  507.     {
  508.         $this->categories->removeElement($category);
  509.     }
  510.     /**
  511.      * Get categories
  512.      *
  513.      * @return Collection
  514.      */
  515.     public function getCategories()
  516.     {
  517.         return $this->categories;
  518.     }
  519.     /**
  520.      * @var Media
  521.      */
  522.     private $image;
  523.     /**
  524.      * Set image
  525.      *
  526.      * @param Media $image
  527.      *
  528.      * @return ServiceWork
  529.      */
  530.     public function setImage(Media $image null)
  531.     {
  532.         $this->image $image;
  533.         return $this;
  534.     }
  535.     /**
  536.      * Get image
  537.      *
  538.      * @return Media
  539.      */
  540.     public function getImage()
  541.     {
  542.         return $this->image;
  543.     }
  544.     private function getContentByLocale($locale 'ru')
  545.     {
  546.         if(!$locale) return $this->content->first();
  547.         /** @var ServiceWorkContent $content */
  548.         foreach ($this->content as $content) {
  549.             if ($content->getLanguage() === $locale) {
  550.                 return $content;
  551.             }
  552.         }
  553.         return $this->content->first();
  554.     }
  555.     /**
  556.      * @param null $locale
  557.      * @return string
  558.      */
  559.     public function getDescription($locale null)
  560.     {
  561.         $content $this->getContentByLocale($locale);
  562.         if(!$content) return '';
  563.         return $content->getDescription();
  564.     }
  565.     /**
  566.      * @param null $locale
  567.      * @return string
  568.      */
  569.     public function getSeoTitle($locale null)
  570.     {
  571.         $content $this->getContentByLocale($locale);
  572.         if(!$content) return '';
  573.         return $content->getSeoTitle();
  574.     }
  575.     /**
  576.      * @param null $locale
  577.      * @return string
  578.      */
  579.     public function getSeoDescription($locale null)
  580.     {
  581.         $content $this->getContentByLocale($locale);
  582.         if(!$content) return '';
  583.         return $content->getSeoDescription();
  584.     }
  585.     /**
  586.      * @var Collection
  587.      */
  588.     private $variations;
  589.     /**
  590.      * Add variation
  591.      *
  592.      * @param ServiceVariation $variation
  593.      *
  594.      * @return ServiceWork
  595.      */
  596.     public function addVariation(ServiceVariation $variation)
  597.     {
  598.         $this->variations[] = $variation;
  599.         return $this;
  600.     }
  601.     /**
  602.      * Remove variation
  603.      *
  604.      * @param ServiceVariation $variation
  605.      */
  606.     public function removeVariation(ServiceVariation $variation)
  607.     {
  608.         $this->variations->removeElement($variation);
  609.     }
  610.     /**
  611.      * Get variations
  612.      *
  613.      * @return Collection
  614.      */
  615.     public function getVariations()
  616.     {
  617.         return $this->variations;
  618.     }
  619.     /**
  620.      * @var string
  621.      */
  622.     private $image_hash;
  623.     /**
  624.      * Set imageHash
  625.      *
  626.      * @param string $imageHash
  627.      *
  628.      * @return ServiceWork
  629.      */
  630.     public function setImageHash($imageHash)
  631.     {
  632.         $this->image_hash $imageHash;
  633.         return $this;
  634.     }
  635.     /**
  636.      * Get imageHash
  637.      *
  638.      * @return string
  639.      */
  640.     public function getImageHash()
  641.     {
  642.         return $this->image_hash;
  643.     }
  644.     /**
  645.      * @var integer
  646.      */
  647.     private $is_accessory;
  648.     /**
  649.      * Set isAccessory
  650.      *
  651.      * @param integer $isAccessory
  652.      *
  653.      * @return ServiceWork
  654.      */
  655.     public function setIsAccessory($isAccessory)
  656.     {
  657.         $this->is_accessory $isAccessory;
  658.         return $this;
  659.     }
  660.     /**
  661.      * Get isAccessory
  662.      *
  663.      * @return integer
  664.      */
  665.     public function getIsAccessory()
  666.     {
  667.         return $this->is_accessory;
  668.     }
  669.     /**
  670.      * @var Collection
  671.      */
  672.     private $accessory_works;
  673.     /**
  674.      * Add accessoryWork
  675.      *
  676.      * @param AccessoryWorkGroup $accessoryWork
  677.      *
  678.      * @return ServiceWork
  679.      */
  680.     public function addAccessoryWork(AccessoryWorkGroup $accessoryWork)
  681.     {
  682.         $this->accessory_works[] = $accessoryWork;
  683.         return $this;
  684.     }
  685.     /**
  686.      * Remove accessoryWork
  687.      *
  688.      * @param AccessoryWorkGroup $accessoryWork
  689.      */
  690.     public function removeAccessoryWork(AccessoryWorkGroup $accessoryWork)
  691.     {
  692.         $this->accessory_works->removeElement($accessoryWork);
  693.     }
  694.     /**
  695.      * Get accessoryWorks
  696.      *
  697.      * @return Collection
  698.      */
  699.     public function getAccessoryWorks()
  700.     {
  701.         return $this->accessory_works;
  702.     }
  703.     /**
  704.      * @var Collection
  705.      */
  706.     private $review;
  707.     /**
  708.      * Add review
  709.      *
  710.      * @param AccessoriesReview $review
  711.      *
  712.      * @return ServiceWork
  713.      */
  714.     public function addReview(AccessoriesReview $review)
  715.     {
  716.         $this->review[] = $review;
  717.         return $this;
  718.     }
  719.     /**
  720.      * Remove review
  721.      *
  722.      * @param AccessoriesReview $review
  723.      */
  724.     public function removeReview(AccessoriesReview $review)
  725.     {
  726.         $this->review->removeElement($review);
  727.     }
  728.     /**
  729.      * Get review
  730.      *
  731.      * @return Collection
  732.      */
  733.     public function getReview()
  734.     {
  735.         return $this->review;
  736.     }
  737.     /**
  738.      * Add workGroupRelation.
  739.      *
  740.      * @param WorkGroupRelation $workGroupRelation
  741.      *
  742.      * @return ServiceWork
  743.      */
  744.     public function addWorkGroupRelation(WorkGroupRelation $workGroupRelation)
  745.     {
  746.         $this->work_group_relations[] = $workGroupRelation;
  747.         return $this;
  748.     }
  749.     /**
  750.      * Remove workGroupRelation.
  751.      *
  752.      * @param WorkGroupRelation $workGroupRelation
  753.      *
  754.      * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  755.      */
  756.     public function removeWorkGroupRelation(WorkGroupRelation $workGroupRelation)
  757.     {
  758.         return $this->work_group_relations->removeElement($workGroupRelation);
  759.     }
  760.     /**
  761.      * Get workGroupRelations.
  762.      *
  763.      * @return Collection
  764.      */
  765.     public function getWorkGroupRelations()
  766.     {
  767.         return $this->work_group_relations;
  768.     }
  769.     /**
  770.      * @var bool|null
  771.      */
  772.     private $advertise;
  773.     /**
  774.      * Set advertise.
  775.      *
  776.      * @param bool|null $advertise
  777.      *
  778.      * @return ServiceWork
  779.      */
  780.     public function setAdvertise($advertise null)
  781.     {
  782.         $this->advertise $advertise;
  783.         return $this;
  784.     }
  785.     /**
  786.      * Get advertise.
  787.      *
  788.      * @return bool|null
  789.      */
  790.     public function getAdvertise()
  791.     {
  792.         return $this->advertise;
  793.     }
  794. }