2018-06-20 19:30:00 +00:00
|
|
|
<?php
|
|
|
|
|
2018-06-23 14:57:10 +00:00
|
|
|
namespace App\Magnetico\Entity;
|
2018-06-20 19:30:00 +00:00
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2018-06-22 19:45:17 +00:00
|
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
2018-06-20 19:30:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Table(name="files", indexes={
|
|
|
|
* @ORM\Index(name="file_info_hash_index", columns={"torrent_id"})
|
|
|
|
* })
|
|
|
|
* @ORM\Entity(readOnly=true)
|
|
|
|
*/
|
|
|
|
class File
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="id", type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
2018-06-22 15:21:10 +00:00
|
|
|
* @var Torrent
|
2018-06-20 19:30:00 +00:00
|
|
|
*
|
2018-06-23 14:57:10 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\Magnetico\Entity\Torrent", inversedBy="files")
|
2018-06-20 19:30:00 +00:00
|
|
|
* @ORM\JoinColumn(name="torrent_id")
|
|
|
|
*/
|
|
|
|
private $torrent;
|
|
|
|
|
|
|
|
/**
|
2018-06-22 15:21:10 +00:00
|
|
|
* @var int File size in bytes
|
2018-06-20 19:30:00 +00:00
|
|
|
*
|
2018-06-22 19:45:17 +00:00
|
|
|
* @Serializer\Groups({"api_v1_show"})
|
|
|
|
*
|
2018-06-20 19:30:00 +00:00
|
|
|
* @ORM\Column(name="size", type="integer", nullable=false)
|
|
|
|
*/
|
|
|
|
private $size;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*
|
2018-06-22 19:45:17 +00:00
|
|
|
* @Serializer\Groups({"api_v1_show"})
|
|
|
|
*
|
2018-06-20 19:30:00 +00:00
|
|
|
* @ORM\Column(name="path", type="text", nullable=false)
|
|
|
|
*/
|
|
|
|
private $path;
|
|
|
|
|
|
|
|
public function getId(): int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
2018-06-22 15:21:10 +00:00
|
|
|
public function getTorrent(): Torrent
|
2018-06-20 19:30:00 +00:00
|
|
|
{
|
|
|
|
return $this->torrent;
|
|
|
|
}
|
|
|
|
|
2018-06-22 15:21:10 +00:00
|
|
|
/** Returns file size in bytes */
|
2018-06-20 19:30:00 +00:00
|
|
|
public function getSize(): int
|
|
|
|
{
|
|
|
|
return $this->size;
|
|
|
|
}
|
|
|
|
|
2018-06-22 15:21:10 +00:00
|
|
|
/** Returns file path relative to the torrent root directory */
|
2018-06-20 19:30:00 +00:00
|
|
|
public function getPath(): string
|
|
|
|
{
|
|
|
|
return $this->path;
|
|
|
|
}
|
|
|
|
}
|