1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2015-2017 Libre Informatique |
6
|
|
|
* |
7
|
|
|
* This file is licenced under the GNU LGPL v3. |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Blast\Bundle\CoreBundle\Controller; |
13
|
|
|
|
14
|
|
|
use Sonata\AdminBundle\Admin\AdminInterface; |
15
|
|
|
use Sonata\AdminBundle\Controller\CoreController as BaseCoreController; |
16
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Extension of Sonata CoreController. |
21
|
|
|
* |
22
|
|
|
* @author Marcos Bezerra de Menezes <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class CoreController extends BaseCoreController |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @param Request $request |
28
|
|
|
* |
29
|
|
|
* @return JsonResponse|Response |
30
|
|
|
* |
31
|
|
|
* @throws \RuntimeException |
32
|
|
|
*/ |
33
|
|
|
public function searchAction(Request $request) |
34
|
|
|
{ |
35
|
|
|
if ($request->get('admin') && $request->isXmlHttpRequest()) { |
36
|
|
|
try { |
37
|
|
|
$admin = $this->getAdminPool()->getAdminByAdminCode($request->get('admin')); |
38
|
|
|
} catch (ServiceNotFoundException $e) { |
|
|
|
|
39
|
|
|
throw new \RuntimeException('Unable to find the Admin instance', $e->getCode(), $e); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (!$admin instanceof AdminInterface) { |
43
|
|
|
throw new \RuntimeException('The requested service is not an Admin instance'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$handler = $this->getSearchHandler(); |
47
|
|
|
|
48
|
|
|
$results = array(); |
49
|
|
|
|
50
|
|
|
if ($pager = $handler->search($admin, $request->get('q'), $request->get('page'), $request->get('offset'))) { |
51
|
|
|
foreach ($pager->getResults() as $result) { |
52
|
|
|
$results[] = array( |
53
|
|
|
'label' => $admin->toString($result), |
54
|
|
|
'link' => $admin->generateObjectUrl('show', $result), // Sonata uses "edit", we prefer "show" |
55
|
|
|
'id' => $admin->id($result), |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$response = new JsonResponse(array( |
61
|
|
|
'results' => $results, |
62
|
|
|
'page' => $pager ? (int) $pager->getPage() : false, |
63
|
|
|
'total' => $pager ? (int) $pager->getNbResults() : false, |
|
|
|
|
64
|
|
|
)); |
65
|
|
|
$response->setPrivate(); |
66
|
|
|
|
67
|
|
|
return $response; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return $this->render($this->container->get('sonata.admin.pool')->getTemplate('search'), array( |
71
|
|
|
'base_template' => $this->getBaseTemplate(), |
72
|
|
|
'breadcrumbs_builder' => $this->get('sonata.admin.breadcrumbs_builder'), |
73
|
|
|
'admin_pool' => $this->container->get('sonata.admin.pool'), |
74
|
|
|
'query' => $request->get('q'), |
75
|
|
|
'groups' => $this->getAdminPool()->getDashboardGroups(), |
76
|
|
|
)); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.