|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula Foundation - https://ziku.la/ |
|
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 Zikula\ExtensionsModule\Controller; |
|
15
|
|
|
|
|
16
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
19
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
20
|
|
|
use Zikula\Bundle\CoreBundle\CacheClearer; |
|
21
|
|
|
use Zikula\Bundle\CoreBundle\Controller\AbstractController; |
|
22
|
|
|
use Zikula\ExtensionsModule\Form\Type\ConfigType; |
|
23
|
|
|
use Zikula\ExtensionsModule\Helper\BundleSyncHelper; |
|
24
|
|
|
use Zikula\PermissionsModule\Annotation\PermissionCheck; |
|
25
|
|
|
use Zikula\ThemeModule\Engine\Annotation\Theme; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class ConfigController |
|
29
|
|
|
* |
|
30
|
|
|
* @Route("/config") |
|
31
|
|
|
* @PermissionCheck("admin") |
|
32
|
|
|
*/ |
|
33
|
|
|
class ConfigController extends AbstractController |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @Route("") |
|
37
|
|
|
* @Theme("admin") |
|
38
|
|
|
* @Template("@ZikulaExtensionsModule/Config/config.html.twig") |
|
39
|
|
|
* |
|
40
|
|
|
* @return array|Response |
|
41
|
|
|
*/ |
|
42
|
|
|
public function configAction( |
|
43
|
|
|
Request $request, |
|
44
|
|
|
BundleSyncHelper $bundleSyncHelper, |
|
45
|
|
|
CacheClearer $cacheClearer |
|
46
|
|
|
) { |
|
47
|
|
|
$form = $this->createForm(ConfigType::class, $this->getVars()); |
|
48
|
|
|
$form->handleRequest($request); |
|
49
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
|
50
|
|
|
if ($form->get('save')->isClicked()) { |
|
|
|
|
|
|
51
|
|
|
$this->setVars($form->getData()); |
|
52
|
|
|
if (true === $form->get('hardreset')->getData()) { |
|
53
|
|
|
$extensionsInFileSystem = $bundleSyncHelper->scanForBundles(); |
|
54
|
|
|
$bundleSyncHelper->syncExtensions($extensionsInFileSystem, true); |
|
55
|
|
|
$cacheClearer->clear('symfony.routing'); |
|
56
|
|
|
} |
|
57
|
|
|
$this->addFlash('status', 'Done! Configuration updated.'); |
|
58
|
|
|
} |
|
59
|
|
|
if ($form->get('cancel')->isClicked()) { |
|
60
|
|
|
$this->addFlash('status', 'Operation cancelled.'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return $this->redirectToRoute('zikulaextensionsmodule_extension_list'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return [ |
|
67
|
|
|
'form' => $form->createView() |
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|