ProjectRun.php (2933B)
1 <?php 2 3 namespace PartKeepr\ProjectBundle\Entity; 4 5 use Doctrine\Common\Collections\ArrayCollection; 6 use Doctrine\ORM\Mapping as ORM; 7 use PartKeepr\CoreBundle\Entity\BaseEntity; 8 use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; 9 use Symfony\Component\Serializer\Annotation\Groups; 10 11 /** 12 * Represents a project. 13 * 14 * @ORM\Entity 15 * @TargetService("/api/project_runs") 16 */ 17 class ProjectRun extends BaseEntity 18 { 19 /** 20 * Stores the date and time of a project run. 21 * 22 * @ORM\Column(type="datetime") 23 * @Groups({"default"}) 24 * 25 * @var \DateTime 26 */ 27 private $runDateTime; 28 29 /** 30 * Stores the project used in a production run. 31 * 32 * @ORM\ManyToOne(targetEntity="PartKeepr\ProjectBundle\Entity\Project") 33 * @Groups({"default"}) 34 * 35 * @var Project 36 */ 37 private $project; 38 39 /** 40 * Stores the quantity this project has been build. 41 * 42 * @ORM\Column(type="integer") 43 * @Groups({"default"}) 44 * 45 * @var int 46 */ 47 private $quantity; 48 49 /** 50 * Stores the parts. 51 * 52 * @ORM\OneToMany( 53 * targetEntity="PartKeepr\ProjectBundle\Entity\ProjectRunPart", 54 * mappedBy="projectRun", 55 * cascade={"persist", "remove"}, 56 * orphanRemoval=true) 57 * 58 * @Groups({"default"}) 59 * 60 * @var ArrayCollection 61 */ 62 private $parts; 63 64 public function __construct() 65 { 66 $this->parts = new ArrayCollection(); 67 } 68 69 /** 70 * @return int 71 */ 72 public function getQuantity() 73 { 74 return $this->quantity; 75 } 76 77 /** 78 * @param int $quantity 79 */ 80 public function setQuantity($quantity) 81 { 82 $this->quantity = $quantity; 83 } 84 85 /** 86 * @return \DateTime 87 */ 88 public function getRunDateTime() 89 { 90 return $this->runDateTime; 91 } 92 93 /** 94 * @param \DateTime $runDateTime 95 */ 96 public function setRunDateTime($runDateTime) 97 { 98 $this->runDateTime = $runDateTime; 99 } 100 101 /** 102 * @return Project 103 */ 104 public function getProject() 105 { 106 return $this->project; 107 } 108 109 /** 110 * @param Project $project 111 */ 112 public function setProject($project) 113 { 114 $this->project = $project; 115 } 116 117 /** 118 * @return ArrayCollection 119 */ 120 public function getParts() 121 { 122 return $this->parts->getValues(); 123 } 124 125 /** 126 * Adds a project run part. 127 * 128 * @param ProjectRunPart 129 */ 130 public function addPart($part) 131 { 132 if ($part instanceof ProjectRunPart) { 133 $part->setProjectRun($this); 134 } 135 $this->parts->add($part); 136 } 137 138 /** 139 * Removes a project run part. 140 * 141 * @param ProjectRunPart 142 */ 143 public function removePart($part) 144 { 145 if ($part instanceof ProjectRunPart) { 146 $part->setProjectRun(null); 147 } 148 $this->parts->removeElement($part); 149 } 150 }