1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\MediaBundle\Controller; |
15
|
|
|
|
16
|
|
|
use Sonata\AdminBundle\Controller\CRUDController as Controller; |
17
|
|
|
use Symfony\Component\Form\FormRenderer; |
18
|
|
|
use Symfony\Component\Form\FormView; |
19
|
|
|
use Symfony\Component\HttpFoundation\Request; |
20
|
|
|
use Symfony\Component\HttpFoundation\Response; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @final since sonata-project/media-bundle 3.21.0 |
24
|
|
|
*/ |
25
|
|
|
class GalleryAdminController extends Controller |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @param string $view |
29
|
|
|
* @param Response $response |
30
|
|
|
* |
31
|
|
|
* @return Response |
32
|
|
|
*/ |
33
|
|
|
public function render($view, array $parameters = [], ?Response $response = null) |
34
|
|
|
{ |
35
|
|
|
$parameters['media_pool'] = $this->get('sonata.media.pool'); |
36
|
|
|
$parameters['persistent_parameters'] = $this->admin->getPersistentParameters(); |
37
|
|
|
|
38
|
|
|
return parent::renderWithExtraParams($view, $parameters, $response); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* return the Response object associated to the list action. |
43
|
|
|
* |
44
|
|
|
* @param Request $request |
45
|
|
|
* |
46
|
|
|
* @return Response |
47
|
|
|
*/ |
48
|
|
|
public function listAction(?Request $request = null) |
49
|
|
|
{ |
50
|
|
|
$this->admin->checkAccess('list'); |
51
|
|
|
|
52
|
|
|
if ($listMode = $request->get('_list_mode')) { |
|
|
|
|
53
|
|
|
$this->admin->setListMode($listMode); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$datagrid = $this->admin->getDatagrid(); |
57
|
|
|
$datagrid->setValue('context', null, $this->admin->getPersistentParameter('context')); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$formView = $datagrid->getForm()->createView(); |
60
|
|
|
|
61
|
|
|
// set the theme for the current Admin Form |
62
|
|
|
$this->setFormTheme($formView, $this->admin->getFilterTheme()); |
63
|
|
|
|
64
|
|
|
return $this->render($this->admin->getTemplate('list'), [ |
|
|
|
|
65
|
|
|
'action' => 'list', |
66
|
|
|
'form' => $formView, |
67
|
|
|
'datagrid' => $datagrid, |
68
|
|
|
'csrf_token' => $this->getCsrfToken('sonata.batch'), |
69
|
|
|
]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Sets the admin form theme to form view. Used for compatibility between Symfony versions. |
74
|
|
|
*/ |
75
|
|
|
private function setFormTheme(FormView $formView, array $theme) |
|
|
|
|
76
|
|
|
{ |
77
|
|
|
$twig = $this->get('twig'); |
78
|
|
|
|
79
|
|
|
$twig->getRuntime(FormRenderer::class)->setTheme($formView, $theme); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.