1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MediaMonks\SonataMediaBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Sonata\AdminBundle\Controller\CRUDController as BaseCRUDController; |
6
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
8
|
|
|
use Symfony\Component\HttpFoundation\StreamedResponse; |
9
|
|
|
|
10
|
|
|
class CRUDController extends BaseCRUDController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
14
|
|
|
*/ |
15
|
5 |
|
public function createAction() |
16
|
|
|
{ |
17
|
5 |
|
if (!$this->getRequest()->get('provider') && $this->getRequest()->isMethod('get')) { |
18
|
|
|
return $this->render( |
19
|
|
|
'@MediaMonksSonataMedia/CRUD/select_provider.html.twig', |
20
|
|
|
[ |
21
|
|
|
'providers' => $this->get('mediamonks.sonata_media.provider.pool')->getProviders(), |
22
|
|
|
'base_template' => $this->getBaseTemplate(), |
23
|
|
|
'admin' => $this->admin, |
24
|
|
|
'action' => 'create', |
25
|
|
|
] |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
5 |
|
return parent::createAction(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param Request $request |
34
|
|
|
* @param $id |
35
|
|
|
* @return StreamedResponse |
36
|
|
|
*/ |
37
|
|
|
public function downloadAction(Request $request, $id) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$object = $this->admin->getObject($id); |
40
|
|
|
|
41
|
|
|
$this->admin->checkAccess('show', $object); |
42
|
|
|
|
43
|
|
|
return $this->get('mediamonks.sonata_media.utility.download')->getStreamedResponse($object); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param Request $request |
48
|
|
|
* @param int $id |
49
|
|
|
* @return RedirectResponse |
50
|
|
|
*/ |
51
|
3 |
|
public function imageAction(Request $request, $id, $width, $height) |
52
|
|
|
{ |
53
|
3 |
|
$object = $this->admin->getObject($id); |
54
|
|
|
|
55
|
3 |
|
$this->admin->checkAccess('show', $object); |
56
|
|
|
|
57
|
3 |
|
return $this->get('mediamonks.sonata_media.utility.image')->getRedirectResponse( |
58
|
3 |
|
$object, |
59
|
3 |
|
$width, |
60
|
3 |
|
$height, |
61
|
3 |
|
$request->query->all() |
62
|
3 |
|
); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.