src/Entity/ProjectData.php line 85

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use JsonSerializable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * Class ProjectData
  10. * @package App\Entity
  11. *
  12. * @ORM\Entity
  13. * @ORM\Table(name="project_data")
  14. *
  15. */
  16. class ProjectData implements JsonSerializable
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=64, nullable=true)
  26.      */
  27.     private $key;
  28.     /**
  29.      * @ORM\Column(type="string", length=64, nullable=true)
  30.      */
  31.     private $keyLower;
  32.     /**
  33.      * @ORM\Column(type="string", length=64, nullable=true)
  34.      */
  35.     private $value;
  36.     /**
  37.      * @ORM\Column(type="string", length=8, nullable=true)
  38.      */
  39.     private $dateYmd// date format: Ymd | result: YYYYmmdd
  40.     /**
  41.      * @ORM\Column(type="string", length=6, nullable=true)
  42.      */
  43.     private $dateHis// date format: His | result: HHiiss
  44.     /**
  45.      * @ORM\Column(type="datetime", nullable=false)
  46.      */
  47.     private $dateAdded;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity="App\Entity\Facility", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
  50.      */
  51.     private $facility;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="App\Entity\NetworkInstallation", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
  54.      */
  55.     private $networkInstallation;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
  58.      */
  59.     private $project;
  60.     public function __construct()
  61.     {
  62.         $this->dateAdded = new \DateTime();
  63.         $this->dateYmd $this->dateAdded->format'Ymd' );
  64.         $this->dateHis $this->dateAdded->format'His' );
  65.     }
  66.     public function jsonSerialize()
  67.     {
  68.         return array(
  69.             'id'=> $this->id,
  70.             'key' => $this->key,
  71.             'value' => $this->value,
  72.             'dateAdded' => $this->dateAdded,
  73.             'dateYmd' => $this->dateYmd,
  74.             'dateHis' => $this->dateHis,
  75.             'dateMjY' => $this->getDateMjY(),
  76.             'facilityId' => !is_null$this->getFacility() ) ? $this->getFacility()->getId() : null,
  77.             'projectId' => !is_null$this->getProject() ) ? $this->getProject()->getId() : null,
  78.         );
  79.     }
  80.     /**
  81.      * get id
  82.      *
  83.      * @return integer
  84.      */
  85.     public function getId()
  86.     {
  87.         return $this->id;
  88.     }
  89.     /**
  90.      * get key
  91.      *
  92.      * @return string
  93.      */
  94.     public function getKey()
  95.     {
  96.         return $this->key;
  97.     }
  98.     /**
  99.      * set key
  100.      *
  101.      * @param string $key
  102.      *
  103.      * @return ProjectData
  104.      */
  105.     public function setKey($key)
  106.     {
  107.         $this->key $key;
  108.         $this->keyLower strtolower($key);
  109.         return $this;
  110.     }
  111.     /**
  112.      * get value
  113.      *
  114.      * @return string
  115.      */
  116.     public function getValue()
  117.     {
  118.         return $this->value;
  119.     }
  120.     /**
  121.      * set value
  122.      *
  123.      * @param string $value
  124.      *
  125.      * @return ProjectData
  126.      */
  127.     public function setValue($value)
  128.     {
  129.         $this->value strtolower($value);
  130.         return $this;
  131.     }
  132.     /**
  133.      * get dateYmd
  134.      *
  135.      * @return string
  136.      */
  137.     public function getDateYmd()
  138.     {
  139.         return $this->dateYmd;
  140.     }
  141.     /**
  142.      * set dateYmd
  143.      *
  144.      * @param string $dateYmd
  145.      *
  146.      * @return ProjectData
  147.      */
  148.     public function setDateYmd($dateYmd)
  149.     {
  150.         $this->dateYmd $dateYmd;
  151.         return $this;
  152.     }
  153.     
  154.     /**
  155.      * get dateHis
  156.      *
  157.      * @return string
  158.      */
  159.     public function getDateGis()
  160.     {
  161.         return $this->dateHis;
  162.     }
  163.     /**
  164.      * set dateHis
  165.      *
  166.      * @param string $dateHis
  167.      *
  168.      * @return ProjectData
  169.      */
  170.     public function setDateGis($dateHis)
  171.     {
  172.         $this->dateHis $dateHis;
  173.         return $this;
  174.     }
  175.     /**
  176.      * get dateMjY
  177.      *
  178.      * @return string
  179.      */
  180.     public function getDateMjY()
  181.     {
  182.         return $this->dateAdded->format'M j, Y' );
  183.     }
  184.     /**
  185.      * get date added
  186.      *
  187.      * @return \DateTime
  188.      */
  189.     public function getDateAdded()
  190.     {
  191.         return $this->dateAdded;
  192.     }
  193.     /**
  194.      * set date added
  195.      *
  196.      * @param \DateTime $date
  197.      * @return \DateTime
  198.      */
  199.     public function setDateAdded(\DateTime $date)
  200.     {
  201.         $this->dateAdded $date;
  202.         $this->dateYmd $this->dateAdded->format'Ymd' );
  203.         $this->dateHis $this->dateAdded->format'His' );
  204.         return $this->dateAdded;
  205.     }
  206.     /**
  207.      * get facility
  208.      *
  209.      * @return Facility
  210.      */
  211.     public function getFacility()
  212.     {
  213.         return $this->facility;
  214.     }
  215.     /**
  216.      * set facility
  217.      *
  218.      * @param Facility|null $facility
  219.      *
  220.      * @return ProjectData
  221.      */
  222.     public function setFacility(Facility $facility null)
  223.     {
  224.         if( !is_null$facility ) ){
  225.             // update the inverse side
  226.             $facility->addProjectData$this );
  227.         } else {
  228.             $facility->addProjectDatanull );
  229.         }
  230.         $this->facility $facility;
  231.         return $this;
  232.     }
  233.     /**
  234.      * get networkInstallation
  235.      *
  236.      * @return NetworkInstallation
  237.      */
  238.     public function getNetworkInstallation()
  239.     {
  240.         return $this->networkInstallation;
  241.     }
  242.     /**
  243.      * set networkInstallation
  244.      *
  245.      * @param \App\Entity\NetworkInstallation $networkInstallation
  246.      *
  247.      * @return NetworkInstallationData
  248.      */
  249.     public function setNetworkInstallation(\App\Entity\NetworkInstallation $networkInstallation)
  250.     {
  251.         $networkInstallation->addNetworkInstallationData$this );
  252.         $this->networkInstallation $networkInstallation;
  253.         return $this;
  254.     }
  255.     
  256.     /**
  257.      * get project
  258.      *
  259.      * @return Project
  260.      */
  261.     public function getProject()
  262.     {
  263.         return $this->project;
  264.     }
  265.     /**
  266.      * set project
  267.      *
  268.      * @param \App\Entity\Project $project
  269.      *
  270.      * @return ProjectData
  271.      */
  272.     public function setProject(\App\Entity\Project $project)
  273.     {
  274.         $project->addProjectData$this );
  275.         $this->project $project;
  276.         return $this;
  277.     }
  278. }