|
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
|
8 |
|
public function createAction() |
|
16
|
|
|
{ |
|
17
|
8 |
|
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
|
8 |
|
return parent::createAction(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param Request $request |
|
34
|
|
|
* @param $id |
|
35
|
|
|
* @return StreamedResponse |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function downloadAction(Request $request, $id) |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
1 |
|
$object = $this->admin->getObject($id); |
|
40
|
|
|
|
|
41
|
1 |
|
$this->admin->checkAccess('show', $object); |
|
42
|
|
|
|
|
43
|
1 |
|
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
|
|
|
$object, |
|
59
|
|
|
$width, |
|
60
|
|
|
$height, |
|
61
|
3 |
|
$request->query->all() |
|
62
|
|
|
); |
|
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.