src/Entity/DnsitShortHour.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * DnsitShortHour
  6.  *
  7.  * @ORM\Table(name="dnsit_hour2")
  8.  * @ORM\Entity(repositoryClass="App\Repository\DnsitShortHourRepository")
  9.  */
  10. class DnsitShortHour
  11. {
  12.     /**
  13.      * @var \DateTime|null
  14.      *
  15.      * @ORM\Column(name="date_from", type="date", nullable=true)
  16.      */
  17.     private $dateFrom;
  18.     /**
  19.      * @var \DateTime|null
  20.      *
  21.      * @ORM\Column(name="date_to", type="date", nullable=true)
  22.      */
  23.     private $dateTo;
  24.     /**
  25.      * @var \DateTime|null
  26.      *
  27.      * @ORM\Column(name="hour_from", type="time", nullable=true)
  28.      */
  29.     private $hourFrom;
  30.     /**
  31.      * @var \DateTime|null
  32.      *
  33.      * @ORM\Column(name="hour_to", type="time", nullable=true)
  34.      */
  35.     private $hourTo;
  36.     /**
  37.      * @var int|null
  38.      *
  39.      * @ORM\Column(name="days", type="integer", nullable=true)
  40.      */
  41.     private $days;
  42.     /**
  43.      * @var bool|null
  44.      *
  45.      * @ORM\Column(name="has_hours", type="boolean", nullable=true)
  46.      */
  47.     private $hasHours;
  48.     /**
  49.      * @var bool|null
  50.      *
  51.      * @ORM\Column(name="permanent_access", type="boolean", nullable=true)
  52.      */
  53.     private $permanentAccess;
  54.     /**
  55.      * @var int|null
  56.      *
  57.      * @ORM\Column(name="access_time", type="integer", nullable=true)
  58.      */
  59.     private $accessTime;
  60.     /**
  61.      * @var int|null
  62.      *
  63.      * @ORM\Column(name="entity", type="bigint", nullable=true)
  64.      */
  65.     private $entity;
  66.     /**
  67.      * @var int|null
  68.      *
  69.      * @ORM\Column(name="marking", type="smallint", nullable=true)
  70.      */
  71.     private $marking;
  72.     /**
  73.      * @var string|null
  74.      *
  75.      * @ORM\Column(name="params", type="text", nullable=true)
  76.      */
  77.     private $params;
  78.     /**
  79.      * @var \DateTime|null
  80.      *
  81.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  82.      */
  83.     private $createdAt;
  84.     /**
  85.      * @var int|null
  86.      *
  87.      * @ORM\Column(name="created_by", type="bigint", nullable=true)
  88.      */
  89.     private $createdBy;
  90.     /**
  91.      * @var \DateTime|null
  92.      *
  93.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  94.      */
  95.     private $updatedAt;
  96.     /**
  97.      * @var int|null
  98.      *
  99.      * @ORM\Column(name="updated_by", type="bigint", nullable=true)
  100.      */
  101.     private $updatedBy;
  102.     /**
  103.      * @var int
  104.      *
  105.      * @ORM\Column(name="id", type="bigint")
  106.      * @ORM\Id
  107.      * @ORM\GeneratedValue(strategy="IDENTITY")
  108.      */
  109.     private $id;
  110.     /**
  111.      * @var string|null
  112.      *
  113.      * @ORM\Column(name="comment", type="string", length=2048, nullable=true)
  114.      */
  115.     private $comment;
  116.     /**
  117.      * @var string|null
  118.      *
  119.      * @ORM\Column(name="comment_translations", type="json", nullable=true)
  120.      */
  121.     private $commentTranslations;
  122.     /**
  123.      * @var \App\Entity\DnsitProduct
  124.      *
  125.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitProduct", inversedBy="shortHours")
  126.      * @ORM\JoinColumns({
  127.      *   @ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="CASCADE")
  128.      * })
  129.      */
  130.     private $product;
  131.     /**
  132.      * @var \App\Entity\DnsitTranslateProduct
  133.      *
  134.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitTranslateProduct")
  135.      * @ORM\JoinColumns({
  136.      *   @ORM\JoinColumn(name="translate_product_id", referencedColumnName="id", onDelete="CASCADE")
  137.      * })
  138.      */
  139.     private $translateProduct;
  140.     protected $dayNames = array(
  141.                     "Lundi",
  142.                     "Mardi",
  143.                     "Mercredi",
  144.                     "Jeudi",
  145.                     "Vendredi",
  146.                     "Samedi",
  147.                     "Dimanche"
  148.                 );
  149.     public function getDateFrom(): ?\DateTimeInterface
  150.     {
  151.         return $this->dateFrom;
  152.     }
  153.     public function setDateFrom(?\DateTimeInterface $dateFrom): self
  154.     {
  155.         $this->dateFrom $dateFrom;
  156.         return $this;
  157.     }
  158.     public function getDateTo(): ?\DateTimeInterface
  159.     {
  160.         return $this->dateTo;
  161.     }
  162.     public function setDateTo(?\DateTimeInterface $dateTo): self
  163.     {
  164.         $this->dateTo $dateTo;
  165.         return $this;
  166.     }
  167.     public function getHourFrom(): ?\DateTimeInterface
  168.     {
  169.         return $this->hourFrom;
  170.     }
  171.     public function setHourFrom($hourFrom): self
  172.     {
  173.         if(! $hourFrom instanceof \Datetime){
  174.             $hourFrom \DateTime::createFromFormat("H:i"$hourFrom);
  175.         }
  176.         $this->hourFrom $hourFrom;
  177.         return $this;
  178.     }
  179.     public function getHourTo(): ?\DateTimeInterface
  180.     {
  181.         return $this->hourTo;
  182.     }
  183.     public function setHourTo($hourTo): self
  184.     {
  185.         if(! $hourTo instanceof \Datetime){
  186.             $hourTo \DateTime::createFromFormat("H:i"$hourTo);
  187.         }
  188.         $this->hourTo $hourTo;
  189.         return $this;
  190.     }
  191.     public function getDays(): ?int
  192.     {
  193.         return $this->days;
  194.     }
  195.     public function setDays(?int $days): self
  196.     {
  197.         $this->days $days;
  198.         return $this;
  199.     }
  200.     public function getHasHours(): ?bool
  201.     {
  202.         return $this->hasHours;
  203.     }
  204.     public function setHasHours(?bool $hasHours): self
  205.     {
  206.         $this->hasHours $hasHours;
  207.         return $this;
  208.     }
  209.     public function getPermanentAccess(): ?bool
  210.     {
  211.         return $this->permanentAccess;
  212.     }
  213.     public function setPermanentAccess(?bool $permanentAccess): self
  214.     {
  215.         $this->permanentAccess $permanentAccess;
  216.         return $this;
  217.     }
  218.     public function getAccessTime(): ?int
  219.     {
  220.         return $this->accessTime;
  221.     }
  222.     public function setAccessTime(?int $accessTime): self
  223.     {
  224.         $this->accessTime $accessTime;
  225.         return $this;
  226.     }
  227.     public function getEntity(): ?int
  228.     {
  229.         return $this->entity;
  230.     }
  231.     public function setEntity(?int $entity): self
  232.     {
  233.         $this->entity $entity;
  234.         return $this;
  235.     }
  236.     public function getMarking(): ?int
  237.     {
  238.         return $this->marking;
  239.     }
  240.     public function setMarking(?int $marking): self
  241.     {
  242.         $this->marking $marking;
  243.         return $this;
  244.     }
  245.     public function getParams(): ?string
  246.     {
  247.         return $this->params;
  248.     }
  249.     public function setParams(?string $params): self
  250.     {
  251.         $this->params $params;
  252.         return $this;
  253.     }
  254.     public function getCreatedAt(): ?\DateTimeInterface
  255.     {
  256.         return $this->createdAt;
  257.     }
  258.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  259.     {
  260.         $this->createdAt $createdAt;
  261.         return $this;
  262.     }
  263.     public function getCreatedBy(): ?int
  264.     {
  265.         return $this->createdBy;
  266.     }
  267.     public function setCreatedBy(?int $createdBy): self
  268.     {
  269.         $this->createdBy $createdBy;
  270.         return $this;
  271.     }
  272.     public function getUpdatedAt(): ?\DateTimeInterface
  273.     {
  274.         return $this->updatedAt;
  275.     }
  276.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  277.     {
  278.         $this->updatedAt $updatedAt;
  279.         return $this;
  280.     }
  281.     public function getUpdatedBy(): ?int
  282.     {
  283.         return $this->updatedBy;
  284.     }
  285.     public function setUpdatedBy(?int $updatedBy): self
  286.     {
  287.         $this->updatedBy $updatedBy;
  288.         return $this;
  289.     }
  290.     public function getId(): ?int
  291.     {
  292.         return $this->id;
  293.     }
  294.     public function getProduct(): ?DnsitProduct
  295.     {
  296.         return $this->product;
  297.     }
  298.     public function setProduct(?DnsitProduct $product): self
  299.     {
  300.         $this->product $product;
  301.         return $this;
  302.     }
  303.     public function getTranslateProduct(): ?DnsitTranslateProduct
  304.     {
  305.         return $this->translateProduct;
  306.     }
  307.     public function setTranslateProduct(?DnsitTranslateProduct $translateProduct): self
  308.     {
  309.         $this->translateProduct $translateProduct;
  310.         return $this;
  311.     }
  312.     public function getFormatedDays(){
  313.                     $formatedDays = array();
  314.                     $binary decbin($this->getDays());
  315.             
  316.                     while(strlen($binary) < 7){
  317.                         $binary "0".$binary;
  318.                     }
  319.                     $binary strrev($binary);
  320.                     for($j 0;$j<7;$j++){
  321.                         if($binary[$j]){
  322.                             $formatedDays[] = $this->dayNames[$j];
  323.                         }
  324.                     }
  325.             
  326.                     return implode(", ",$formatedDays);
  327.             
  328.                 }
  329.     public function getComment(): ?string
  330.     {
  331.         return $this->comment;
  332.     }
  333.     public function setComment(?string $comment): self
  334.     {
  335.         $this->comment $comment;
  336.         return $this;
  337.     }
  338.     public function getCommentTranslations(): ?array
  339.     {
  340.         return $this->commentTranslations;
  341.     }
  342.     public function setCommentTranslations(?array $commentTranslations): self
  343.     {
  344.         $this->commentTranslations $commentTranslations;
  345.         return $this;
  346.     }
  347. }