|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Routes. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Zikula contributors (Zikula) |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
* @author Zikula contributors <[email protected]>. |
|
8
|
|
|
* @link http://www.zikula.org |
|
9
|
|
|
* @link http://zikula.org |
|
10
|
|
|
* @version Generated by ModuleStudio 0.7.1 (http://modulestudio.de). |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Zikula\RoutesModule\Controller; |
|
14
|
|
|
|
|
15
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Zikula\Core\Controller\AbstractController; |
|
18
|
|
|
use Zikula\Core\Response\Ajax\AjaxResponse; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Sort controller class handling resort functionality. |
|
22
|
|
|
* |
|
23
|
|
|
* @Route("/ajax") |
|
24
|
|
|
*/ |
|
25
|
|
|
class SortController extends AbstractController |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Resort routes. |
|
29
|
|
|
* |
|
30
|
|
|
* @param Request $request Current request instance |
|
31
|
|
|
* |
|
32
|
|
|
* @return boolean|AjaxResponse The response |
|
33
|
|
|
*/ |
|
34
|
|
|
public function resortAction(Request $request) |
|
35
|
|
|
{ |
|
36
|
|
|
if (!$this->hasPermission('ZikulaRoutesModule::Ajax', '::', ACCESS_EDIT)) { |
|
37
|
|
|
return true; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$sort = $request->request->get('sort', []); |
|
41
|
|
|
|
|
42
|
|
|
$entityManager = $this->get('doctrine.orm.default_entity_manager'); |
|
43
|
|
|
|
|
44
|
|
|
foreach ($sort as $position => $id) { |
|
45
|
|
|
$id = substr($id, 4); |
|
46
|
|
|
$object = $entityManager->find('ZikulaRoutesModule:RouteEntity', $id); |
|
47
|
|
|
$object->setSort($position); |
|
48
|
|
|
$entityManager->persist($object); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$entityManager->flush(); |
|
52
|
|
|
|
|
53
|
|
|
$this->get('zikula.cache_clearer')->clear('symfony.routing'); |
|
54
|
|
|
|
|
55
|
|
|
return new AjaxResponse([]); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|