1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace IrishDan\ResponsiveImageBundle\Tests\Entity; |
4
|
|
|
|
5
|
|
|
use IrishDan\ResponsiveImageBundle\ResponsiveImageInterface; |
6
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Entity(repositoryClass="IrishDan\ResponsiveImageBundle\Repository\ImageRepository") |
12
|
|
|
* @ORM\Table(name="image") |
13
|
|
|
* @ORM\HasLifecycleCallbacks() |
14
|
|
|
*/ |
15
|
|
|
class TestImage implements ResponsiveImageInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @ORM\Column(name="id", type="integer") |
19
|
|
|
* @ORM\Id |
20
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
21
|
|
|
*/ |
22
|
|
|
private $id = 1; |
23
|
|
|
/** |
24
|
|
|
* @ORM\Column(name="title", type="string", length=255) |
25
|
|
|
*/ |
26
|
|
|
private $title = 'Test image'; |
27
|
|
|
/** |
28
|
|
|
* @ORM\Column(name="path", type="string", length=255, unique=true) |
29
|
|
|
*/ |
30
|
|
|
private $path = 'dummy.jpg'; |
31
|
|
|
/** |
32
|
|
|
* @ORM\Column(name="alt", type="string", length=255, nullable=true) |
33
|
|
|
*/ |
34
|
|
|
private $alt = 'Test image alt text'; |
35
|
|
|
/** |
36
|
|
|
* @ORM\Column(name="width", type="integer", nullable=true) |
37
|
|
|
*/ |
38
|
|
|
private $width = 1000; |
39
|
|
|
/** |
40
|
|
|
* @ORM\Column(name="height", type="integer", nullable=true) |
41
|
|
|
*/ |
42
|
|
|
private $height = 1600; |
43
|
|
|
/** |
44
|
|
|
* @Assert\File(maxSize="6000000") |
45
|
|
|
*/ |
46
|
|
|
private $file; |
47
|
|
|
/** |
48
|
|
|
* @ORM\Column(name="crop_coordinations", type="string", nullable=true) |
49
|
|
|
*/ |
50
|
|
|
private $cropCoordinates = '200, 3, 800, 1400:310, 145, 750, 617'; |
51
|
|
|
private $src; |
52
|
|
|
|
53
|
|
|
public function getId() |
54
|
|
|
{ |
55
|
|
|
return $this->id; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getPath() |
59
|
|
|
{ |
60
|
|
|
return $this->path; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setPath($path) |
64
|
|
|
{ |
65
|
|
|
$this->path = $path; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getTitle() |
69
|
|
|
{ |
70
|
|
|
return $this->title; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function setTitle($title) |
74
|
|
|
{ |
75
|
|
|
$this->title = $title; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getStyleData() |
79
|
|
|
{ |
80
|
|
|
return $this->style; |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function setStyle($style) |
84
|
|
|
{ |
85
|
|
|
$this->style = $style; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getAlt() |
89
|
|
|
{ |
90
|
|
|
return $this->alt; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function setAlt($alt) |
94
|
|
|
{ |
95
|
|
|
$this->alt = $alt; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getWidth() |
99
|
|
|
{ |
100
|
|
|
return $this->width; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setWidth($width) |
104
|
|
|
{ |
105
|
|
|
$this->width = $width; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getHeight() |
109
|
|
|
{ |
110
|
|
|
return $this->height; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function setHeight($height) |
114
|
|
|
{ |
115
|
|
|
$this->height = $height; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getCropCoordinates() |
119
|
|
|
{ |
120
|
|
|
return $this->cropCoordinates; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function setCropCoordinates($cords) |
124
|
|
|
{ |
125
|
|
|
$this->cropCoordinates = $cords; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function setFile(UploadedFile $file) |
129
|
|
|
{ |
130
|
|
|
$this->file = $file; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getFile() |
134
|
|
|
{ |
135
|
|
|
return $this->file; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function setSrc($src) |
139
|
|
|
{ |
140
|
|
|
$this->src = $src; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getSrc() |
144
|
|
|
{ |
145
|
|
|
return $this->src; |
146
|
|
|
} |
147
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: