|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2017 |
|
4
|
|
|
* |
|
5
|
|
|
* @package Majima |
|
6
|
|
|
* @author David Neustadt <[email protected]> |
|
7
|
|
|
* @copyright 2017 David Neustadt |
|
8
|
|
|
* @license MIT |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Majima\Controller; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\DependencyInjection\Container; |
|
14
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
18
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class AdminController |
|
22
|
|
|
* @package Majima\Controller |
|
23
|
|
|
*/ |
|
24
|
|
|
class AdminController |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var Container |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $container; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var RouterInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $router; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* AdminController constructor. |
|
38
|
|
|
* @param Container $container |
|
39
|
|
|
* @param RouterInterface $router |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(Container $container, RouterInterface $router) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->container = $container; |
|
44
|
|
|
$this->router = $router; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param Request $request |
|
49
|
|
|
* @return Response |
|
50
|
|
|
*/ |
|
51
|
|
|
public function clearcacheAction(Request $request) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
$fs = new Filesystem(); |
|
54
|
|
|
$fs->remove($this->container->getParameter('kernel.cache_dir')); |
|
55
|
|
|
|
|
56
|
|
|
$cssPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'css', 'style.min.css']); |
|
|
|
|
|
|
57
|
|
|
$backendCssPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'css', 'style.backend.min.css']); |
|
58
|
|
|
$jsPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'js', 'scripts.min.js']); |
|
59
|
|
|
$backendJsPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['web', 'js', 'scripts.backend.min.js']); |
|
60
|
|
|
|
|
61
|
|
|
if (file_exists($cssPath)) { |
|
62
|
|
|
$fs->remove($cssPath); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if (file_exists($backendCssPath)) { |
|
66
|
|
|
$fs->remove($backendCssPath); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if (file_exists($jsPath)) { |
|
70
|
|
|
$fs->remove($jsPath); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (file_exists($backendJsPath)) { |
|
74
|
|
|
$fs->remove($backendJsPath); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return new RedirectResponse($this->router->generate('index_index')); |
|
78
|
|
|
} |
|
79
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.