forked from sonata-project/SonataMediaBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediaProviderInterface.php
248 lines (214 loc) · 5.77 KB
/
MediaProviderInterface.php
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
/*
* This file is part of the Sonata project.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\MediaBundle\Provider;
use Sonata\MediaBundle\Model\MediaInterface;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\MediaBundle\Resizer\ResizerInterface;
use Gaufrette\Filesystem;
use Sonata\AdminBundle\Validator\ErrorElement;
use Symfony\Component\Form\FormBuilder;
interface MediaProviderInterface
{
/**
* @param string $name
* @param array $format
*
* @return void
*/
function addFormat($name, $format);
/**
* return the format settings
*
* @param string $name
*
* @return array|false the format settings
*/
function getFormat($name);
/**
* return true if the media related to the provider required thumbnails (generation)
*
* @return boolean
*/
function requireThumbnails();
/**
* generated thumbnails linked to the media, a thumbnail is a format used on the website
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function generateThumbnails(MediaInterface $media);
/**
* remove all linked thumbnails
*
* @param MediaInterface $media
* @return void
*/
function removeThumbnails(MediaInterface $media);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return \Gaufrette\File
*/
function getReferenceFile(MediaInterface $media);
/**
* return the correct format name : providerName_format
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @param string $format
* @return string
*/
function getFormatName(MediaInterface $media, $format);
/**
* return the reference image of the media, can be the video thumbnail or the original uploaded picture
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return string to the reference image
*/
function getReferenceImage(MediaInterface $media);
/**
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function preUpdate(MediaInterface $media);
/**
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function postUpdate(MediaInterface $media);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function preRemove(MediaInterface $media);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function postRemove(MediaInterface $media);
/**
* build the related create form
*
* @param \Sonata\AdminBundle\Form\FormMapper $formMapper
*/
function buildCreateForm(FormMapper $formMapper);
/**
* build the related create form
*
* @param \Sonata\AdminBundle\Form\FormMapper $formMapper
*/
function buildEditForm(FormMapper $formMapper);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function prePersist(MediaInterface $media);
/**
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function postPersist(MediaInterface $media);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @param string $format
*/
function getHelperProperties(MediaInterface $media, $format);
/**
* Generate the media path
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return string
*/
function generatePath(MediaInterface $media);
/**
* Generate the public path
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @param string $format
* @return string
*/
function generatePublicUrl(MediaInterface $media, $format);
/**
* Generate the private path
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @param string $format
* @return string
*/
function generatePrivateUrl(MediaInterface $media, $format);
/**
*
* @return array
*/
function getFormats();
/**
*
* @param string $name
*/
function setName($name);
/**
* @return string
*/
function getName();
/**
*
* @param array $templates
*/
function setTemplates(array $templates);
/**
*
* @return array
*/
function getTemplates();
/**
* @param string $name
* @return void
*/
function getTemplate($name);
/**
* Mode can be x-file
*
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @param $format
* @param $mode
* @return \Symfony\Component\HttpFoundation\Response
*/
function getDownloadResponse(MediaInterface $media, $format, $mode);
/**
* @return \Sonata\MediaBundle\Media\ResizerInterface
*/
function getResizer();
/**
* @return \Gaufrette\Filesystem
*/
function getFilesystem();
/**
* @param string $relativePath
* @param bool $isFlushable
*/
function getCdnPath($relativePath, $isFlushable);
/**
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function transform(MediaInterface $media);
/**
* @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
* @param \Sonata\MediaBundle\Model\MediaInterface $media
* @return void
*/
function validate(ErrorElement $errorElement, MediaInterface $media);
/**
* @param \Symfony\Component\Form\FormBuilder $formBuilder
* @return void
*/
function buildMediaType(FormBuilder $formBuilder);
}