blob: 5400db421df777e28ec2f1c5f109fab97f8aa401 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
// src/model/entities/Asset.php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
#[ORM\Entity]
#[ORM\Table(name: TABLE_PREFIX . "asset")]
class Asset
{
const PATH = 'assets/';
const USER_PATH = 'user_data/assets/';
// choisir un répertoire du genre /var/www/html/uploads/? ou au moins hors de /src? j'en sais rien
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
private int $id_asset;
#[ORM\Column(type: "string", length: 255)] // nom de fichier modifié avec uniqid (fichiers différents de même nom)
private string $file_name;
#[ORM\Column(type: "string", length: 255, nullable: true)]
private string $mime_type; // image/jpeg, image/png, etc
#[ORM\Column(type: "string", length: 64, unique: true)] // doctrine n'a pas d'équivalent au type CHAR des BDD (on voulait CHAR(64)), c'est pas grave!
private string $hash; // pour détecter deux fichiers identiques, même si leurs noms et les métadonnées changent
#[ORM\OneToMany(mappedBy: 'asset', targetEntity: NodeDataAsset::class)]
private Collection $nda_collection;
public function __construct(string $name, string $mime_type, string $hash)
{
$this->file_name = $name;
$this->mime_type = $mime_type;
$this->hash = $hash;
}
public function getFileName(): string
{
return $this->file_name;
}
public function setFileName(string $name): void
{
$this->file_name = $name;
}
public function getMimeType(): string
{
return $this->mime_type;
}
public function setMimeType(string $mime_type): void
{
$this->mime_type = $mime_type;
}
public function getHash(): string
{
return $this->hash;
}
public function getNodeDataAssets(): Collection
{
return $this->nda_collection;
}
}
|