1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller; |
4
|
|
|
|
5
|
|
|
use App\Service\SettingsService; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
8
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class SettingsController |
13
|
|
|
* @package App\Controller |
14
|
|
|
* |
15
|
|
|
* @Route("/settings", name="settings-") |
16
|
|
|
*/ |
17
|
|
|
class SettingsController extends AbstractController |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var SettingsService |
21
|
|
|
*/ |
22
|
|
|
protected $settingsService; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* DefaultController constructor. |
26
|
|
|
* @param SettingsService $settingsService |
27
|
|
|
*/ |
28
|
|
|
public function __construct(SettingsService $settingsService) |
29
|
|
|
{ |
30
|
|
|
$this->settingsService = $settingsService; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @Route("/", name="index", methods={"GET"}) |
35
|
|
|
* |
36
|
|
|
* @return Response |
37
|
|
|
*/ |
38
|
|
|
public function settingsList() |
39
|
|
|
{ |
40
|
|
|
return $this->render('settings/index.html.twig'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @Route("/", name="save", methods={"POST"}) |
45
|
|
|
* |
46
|
|
|
* @return Response |
47
|
|
|
*/ |
48
|
|
|
public function settingsSave() |
49
|
|
|
{ |
50
|
|
|
$request = Request::createFromGlobals(); |
51
|
|
|
$settings = $request->request->all(); |
52
|
|
|
$this->settingsService->storeSettings($settings); |
53
|
|
|
return new Response(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Route("/", name="clear", methods={"DELETE"}) |
58
|
|
|
* |
59
|
|
|
* @return Response |
60
|
|
|
*/ |
61
|
|
|
public function settingsClear() |
62
|
|
|
{ |
63
|
|
|
$this->settingsService->clearSettings(); |
64
|
|
|
return new Response(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|