src/Entity/Pro/OpeningHour.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Pro;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. /**
  6.  * OpeningHour
  7.  *
  8.  * @ORM\Table(name="tam_opening_hours")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Pro\OpeningHourRepository")
  10.  */
  11. class OpeningHour
  12. {
  13.     /**
  14.      * @var int
  15.      *
  16.      * @ORM\Column(name="id", type="integer")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="IDENTITY")
  19.      */
  20.     private $id;
  21.     
  22.     /**
  23.      * @var \Pro
  24.      *
  25.      * @ORM\ManyToOne(targetEntity="\App\Entity\Pro\Pro", inversedBy="openingHours")
  26.      * @ORM\JoinColumns({
  27.      *   @ORM\JoinColumn(name="pro", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  28.      * })
  29.      */
  30.     private $pro;
  31.     
  32.     /**
  33.      * @var integer
  34.      *
  35.      * @ORM\Column(name="day", type="integer", options={"default": 0})
  36.      */
  37.     private $day;
  38.     
  39.     /**
  40.      * @var \Time
  41.      *
  42.      * @ORM\Column(name="hour_start", type="time", nullable=true)
  43.      */
  44.     private $hourStart;
  45.     
  46.     /**
  47.      * @var \Time
  48.      *
  49.      * @ORM\Column(name="hour_end", type="time", nullable=true)
  50.      */
  51.     private $hourEnd;
  52.     
  53.     /**
  54.      * @var \Time
  55.      *
  56.      * @ORM\Column(name="hour_start2", type="time", nullable=true)
  57.      */
  58.     private $hourStart2;
  59.     
  60.     /**
  61.      * @var \Time
  62.      *
  63.      * @ORM\Column(name="hour_end2", type="time", nullable=true)
  64.      */
  65.     private $hourEnd2;
  66.     
  67.     /**
  68.      * @var boolean
  69.      *
  70.      * @ORM\Column(name="all_day_service", type="boolean", options={"default": FALSE})
  71.      */
  72.     private $allDayService;
  73.     
  74.     /**
  75.      * @var boolean
  76.      *
  77.      * @ORM\Column(name="closed", type="boolean", options={"default": FALSE})
  78.      */
  79.     private $closed;
  80.     
  81.     
  82.     
  83.     public function __construct($_id null)
  84.     {
  85.         if($_id)
  86.             $this->id $_id;
  87.         $this->allDayService false;
  88.         $this->closed false;   
  89.      
  90.     }
  91.     /**
  92.      * Get id
  93.      *
  94.      * @return int
  95.      */
  96.     public function getId()
  97.     {
  98.         return $this->id;
  99.     }
  100.     
  101.     /**
  102.      * Set pro
  103.      *
  104.      * @param \App\Entity\Pro\Pro $pro
  105.      *
  106.      * @return OpeningHour
  107.      */
  108.     public function setPro(\App\Entity\Pro\Pro $pro)
  109.     {
  110.         $this->pro $pro;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get pro
  115.      *
  116.      * @return \App\Entity\Pro\Pro
  117.      */
  118.     public function getPro()
  119.     {
  120.         return $this->pro;
  121.     }
  122.     
  123.     /**
  124.      * Set day
  125.      *
  126.      * @param integer $day
  127.      *
  128.      * @return OpeningHour
  129.      */
  130.     public function setDay($day)
  131.     {
  132.         $this->day $day;
  133.         return $this;
  134.     }
  135.     /**
  136.      * Get day
  137.      *
  138.      * @return integer
  139.      */
  140.     public function getDay()
  141.     {
  142.         return $this->day;
  143.     }
  144.     
  145.     /**
  146.      * Set hourStart
  147.      *
  148.      * @param \Time $hourStart
  149.      *
  150.      * @return OpeningHour
  151.      */
  152.     public function setHourStart($hourStart)
  153.     {
  154.         $this->hourStart $hourStart;
  155.         return $this;
  156.     }
  157.     /**
  158.      * Get hourStart
  159.      *
  160.      * @return \Time
  161.      */
  162.     public function getHourStart()
  163.     {
  164.         return $this->hourStart;
  165.     }
  166.     
  167.     /**
  168.      * Set hourEnd
  169.      *
  170.      * @param \Time $hourEnd
  171.      *
  172.      * @return OpeningHour
  173.      */
  174.     public function setHourEnd($hourEnd)
  175.     {
  176.         $this->hourEnd $hourEnd;
  177.         return $this;
  178.     }
  179.     /**
  180.      * Get hourEnd
  181.      *
  182.      * @return \Time
  183.      */
  184.     public function getHourEnd()
  185.     {
  186.         return $this->hourEnd;
  187.     }
  188.     
  189.     /**
  190.      * Set hourStart2
  191.      *
  192.      * @param \Time $hourStart2
  193.      *
  194.      * @return OpeningHour
  195.      */
  196.     public function setHourStart2($hourStart2)
  197.     {
  198.         $this->hourStart2 $hourStart2;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Get hourStart2
  203.      *
  204.      * @return \Time
  205.      */
  206.     public function getHourStart2()
  207.     {
  208.         return $this->hourStart2;
  209.     }
  210.     
  211.     /**
  212.      * Set hourEnd2
  213.      *
  214.      * @param \Time $hourEnd2
  215.      *
  216.      * @return OpeningHour
  217.      */
  218.     public function setHourEnd2($hourEnd2)
  219.     {
  220.         $this->hourEnd2 $hourEnd2;
  221.         return $this;
  222.     }
  223.     /**
  224.      * Get hourEnd2
  225.      *
  226.      * @return \Time
  227.      */
  228.     public function getHourEnd2()
  229.     {
  230.         return $this->hourEnd2;
  231.     }
  232.     
  233.     /**
  234.      * Set allDayService
  235.      *
  236.      * @param boolean $allDayService
  237.      *
  238.      * @return OpeningHour
  239.      */
  240.     public function setAllDayService($allDayService)
  241.     {
  242.         $this->allDayService $allDayService;
  243.         return $this;
  244.     }
  245.     /**
  246.      * Get allDayService
  247.      *
  248.      * @return boolean
  249.      */
  250.     public function getAllDayService()
  251.     {
  252.         return $this->allDayService;
  253.     }
  254.     
  255.     /**
  256.      * Set closed
  257.      *
  258.      * @param boolean $closed
  259.      *
  260.      * @return OpeningHour
  261.      */
  262.     public function setClosed($closed)
  263.     {
  264.         $this->closed $closed;
  265.         return $this;
  266.     }
  267.     /**
  268.      * Get closed
  269.      *
  270.      * @return boolean
  271.      */
  272.     public function getClosed()
  273.     {
  274.         return $this->closed;
  275.     }
  276.     
  277.     
  278.     
  279.     /***********************
  280.      * OTHER FUNCTION
  281.      ***********************/
  282.      
  283.     public function updateFromJson($jsonObject){
  284.         $this->day $jsonObject->day;
  285.         if(isset($jsonObject->hourStart) && $jsonObject->hourStart != "NULL"){
  286.             $this->setHourStart(\DateTime::createFromFormat("H:i"gmdate("H:i"$jsonObject->hourStart)));
  287.         }else{
  288.             $this->setHourStart(null);
  289.         }
  290.         if(isset($jsonObject->hourEnd) && $jsonObject->hourEnd != "NULL"){
  291.             $this->setHourEnd(\DateTime::createFromFormat("H:i"gmdate("H:i"$jsonObject->hourEnd)));
  292.         }else{
  293.             $this->setHourEnd(null);
  294.         }
  295.         
  296.         if(isset($jsonObject->hourStart2) && $jsonObject->hourStart2 != "NULL"){
  297.             $this->setHourStart2(\DateTime::createFromFormat("H:i"gmdate("H:i"$jsonObject->hourStart2)));
  298.         }else{
  299.             $this->setHourStart2(null);
  300.         }
  301.         if(isset($jsonObject->hourEnd2) && $jsonObject->hourEnd2 != "NULL"){
  302.             $this->setHourEnd2(\DateTime::createFromFormat("H:i"gmdate("H:i"$jsonObject->hourEnd2)));
  303.         }else{
  304.             $this->setHourEnd2(null);
  305.         }
  306.         $this->setClosed($jsonObject->closed);
  307.         
  308.     }
  309.     
  310.     public function getArrayForJson(){
  311.         $array = array();
  312.         $array['id'] = $this->getId();
  313.         $array['day'] = $this->getDay();
  314.         if($this->getHourStart())
  315.             $array['hourStart'] = $this->getHourStart()->format("H") * 3600 $this->getHourStart()->format("i") * 60;
  316.         else
  317.             $array['hourStart'] = null;
  318.         if($this->getHourEnd())
  319.             $array['hourEnd'] = $this->getHourEnd()->format("H") * 3600 $this->getHourEnd()->format("i") * 60;
  320.         else
  321.             $array['hourEnd'] = null;
  322.         if($this->getHourStart2())
  323.             $array['hourStart2'] = $this->getHourStart2()->format("H") * 3600 $this->getHourStart2()->format("i") * 60;
  324.         else
  325.             $array['hourStart2'] = null;
  326.         if($this->getHourEnd2())
  327.             $array['hourEnd2'] = $this->getHourEnd2()->format("H") * 3600 $this->getHourEnd2()->format("i") * 60;
  328.         else
  329.             $array['hourEnd2'] = null;
  330.         $array['closed'] = $this->getClosed();
  331.         
  332.         
  333.         
  334.         return $array;
  335.         
  336.     }
  337.     
  338.     
  339. }