-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathFile.php
More file actions
66 lines (52 loc) · 1.4 KB
/
File.php
File metadata and controls
66 lines (52 loc) · 1.4 KB
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
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[Orm\MappedSuperclass]
abstract class File
{
protected ?\SplFileInfo $file = null;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
protected ?int $id = null;
#[ORM\Column(length: 255)]
protected ?string $path = null;
#[ORM\Column(nullable: true)]
protected ?\DateTimeImmutable $updatedAt = null;
public function getId(): ?int
{
return $this->id;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): void
{
$this->path = $path;
}
public function getFile(): ?\SplFileInfo
{
return $this->file;
}
public function setFile(?\SplFileInfo $file): void
{
$this->file = $file;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($file) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTimeImmutable('now');
}
}
}