path = $path; return $this; } /** * Get path * * @return string */ public function getPath() { return $this->path; } /** * Sets file. * * @param UploadedFile $file */ public function setFile(UploadedFile $file = null) { $this->file = $file; } /** * Get file. * * @return UploadedFile */ public function getFile() { return $this->file; } public function getAbsolutePath() { return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->path; } public function getWebPath() { return null === $this->path ? null : $this->getUploadDir().'/'.$this->path; } protected function getUploadRootDir() { // the absolute directory path where uploaded // documents should be saved return __DIR__.'/../../../../web/'.$this->getUploadDir(); } protected function getUploadDir() { // get rid of the __DIR__ so it doesn't screw up // when displaying uploaded doc/image in the view. return 'uploads/documents'; } /** * @ORM\PrePersist() * @ORM\PreUpdate() */ public function preUpload() { if (null !== $this->file) { $filename = sha1(uniqid(mt_rand(), true)); $this->path = $filename.'.'.$this->getFile()->guessExtension(); } } /** * @ORM\PostPersist() * @ORM\PostUpdate() */ public function upload() { if (null === $this->file) { return; } $this->file->move($this->getUploadRootDir(), $this->path); unset($this->file); } /** * @ORM\PostRemove() */ public function removeUpload() { if ($file = $this->getAbsolutePath()) { unlink($file); } } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set ip * * @param string $ip * @return Machine */ public function setIp($ip) { $this->ip = $ip; return $this; } /** * Get ip * * @return string */ public function getIp() { return $this->ip; } /** * Set macAddress * * @param string $macAddress * @return Machine */ public function setMacAddress($macAddress) { $this->macAddress = $macAddress; return $this; } /** * Get macAddress * * @return string */ public function getMacAddress() { return $this->macAddress; } /** * Set gateway * * @param \Cocar\CocarBundle\Entity\Circuits $gateway * @return Circuits */ public function setGateway(\Swpb\Bundle\CocarBundle\Entity\Circuits $gateway = null) { $this->gateway = $gateway; return $this; } /** * Get gateway * * @return \Swpb\Bundle\CocarBundle\Entity\Circuits */ public function getGateway() { return $this->gateway; } }