diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
| commit | f27cca08ff786ceff1870147f6d6bad14d71117f (patch) | |
| tree | d36597a72025313d6faf4ed228755fa267ebe2f6 /src/Model/Entity/Asset.php | |
| parent | c7309f900ef05bd5cb313110ec159b761af394ec (diff) | |
| download | cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2 cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip | |
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
Diffstat (limited to 'src/Model/Entity/Asset.php')
| -rw-r--r-- | src/Model/Entity/Asset.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/Model/Entity/Asset.php b/src/Model/Entity/Asset.php new file mode 100644 index 0000000..51e21fe --- /dev/null +++ b/src/Model/Entity/Asset.php | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | <?php | ||
| 2 | // src/Model/Entity/Asset.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | namespace App\Entity; | ||
| 7 | |||
| 8 | use Doctrine\ORM\Mapping as ORM; | ||
| 9 | use Doctrine\Common\Collections\Collection; | ||
| 10 | |||
| 11 | #[ORM\Entity] | ||
| 12 | #[ORM\Table(name: TABLE_PREFIX . "asset")] | ||
| 13 | class Asset | ||
| 14 | { | ||
| 15 | const PATH = 'assets/'; | ||
| 16 | const USER_PATH = 'user_data/assets/'; | ||
| 17 | // choisir un répertoire du genre /var/www/html/uploads/? ou au moins hors de /src? j'en sais rien | ||
| 18 | |||
| 19 | #[ORM\Id] | ||
| 20 | #[ORM\GeneratedValue] | ||
| 21 | #[ORM\Column(type: "integer")] | ||
| 22 | private int $id_asset; | ||
| 23 | |||
| 24 | #[ORM\Column(type: "string", length: 255)] // nom de fichier modifié avec uniqid (fichiers différents de même nom) | ||
| 25 | private string $file_name; | ||
| 26 | |||
| 27 | #[ORM\Column(type: "string", length: 255, nullable: true)] | ||
| 28 | private string $mime_type; // image/jpeg, image/png, etc | ||
| 29 | |||
| 30 | #[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! | ||
| 31 | private string $hash; // pour détecter deux fichiers identiques, même si leurs noms et les métadonnées changent | ||
| 32 | |||
| 33 | #[ORM\OneToMany(mappedBy: 'asset', targetEntity: AssetEmployment::class)] | ||
| 34 | private Collection $asset_employment; | ||
| 35 | |||
| 36 | public function __construct(string $name, string $mime_type, string $hash) | ||
| 37 | { | ||
| 38 | $this->file_name = $name; | ||
| 39 | $this->mime_type = $mime_type; | ||
| 40 | $this->hash = $hash; | ||
| 41 | } | ||
| 42 | |||
| 43 | public function getFileName(): string | ||
| 44 | { | ||
| 45 | return $this->file_name; | ||
| 46 | } | ||
| 47 | public function setFileName(string $name): void | ||
| 48 | { | ||
| 49 | $this->file_name = $name; | ||
| 50 | } | ||
| 51 | public function getMimeType(): string | ||
| 52 | { | ||
| 53 | return $this->mime_type; | ||
| 54 | } | ||
| 55 | public function setMimeType(string $mime_type): void | ||
| 56 | { | ||
| 57 | $this->mime_type = $mime_type; | ||
| 58 | } | ||
| 59 | public function getHash(): string | ||
| 60 | { | ||
| 61 | return $this->hash; | ||
| 62 | } | ||
| 63 | |||
| 64 | public function getAssetEmployments(): Collection | ||
| 65 | { | ||
| 66 | return $this->asset_employment; | ||
| 67 | } | ||
| 68 | } | ||
