|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of EC-CUBE |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* http://www.lockon.co.jp/ |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software; you can redistribute it and/or |
|
10
|
|
|
* modify it under the terms of the GNU General Public License |
|
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
12
|
|
|
* of the License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with this program; if not, write to the Free Software |
|
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
namespace Eccube\Controller\Admin\Content; |
|
26
|
|
|
|
|
27
|
|
|
use Eccube\Application; |
|
28
|
|
|
use Eccube\Controller\AbstractController; |
|
29
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
30
|
|
|
use Symfony\Component\Finder\Finder; |
|
31
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
32
|
|
|
|
|
33
|
|
|
class CacheController extends AbstractController |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
2 |
|
public function index(Application $app, Request $request) |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
2 |
|
$builder = $app['form.factory']->createBuilder('admin_cache'); |
|
40
|
|
|
|
|
41
|
2 |
|
$form = $builder->getForm(); |
|
42
|
|
|
|
|
43
|
2 |
|
$form->handleRequest($request); |
|
44
|
|
|
|
|
45
|
2 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
1 |
|
$data = $form->get('cache')->getData(); |
|
48
|
|
|
|
|
49
|
1 |
|
$cacheDir = $app['config']['root_dir'].'/app/cache'; |
|
50
|
|
|
|
|
51
|
1 |
|
$filesystem = new Filesystem(); |
|
52
|
|
|
|
|
53
|
1 |
|
foreach ($data as $dir) { |
|
54
|
1 |
View Code Duplication |
if (is_dir($cacheDir.'/'.$dir)) { |
|
|
|
|
|
|
55
|
|
|
// 指定されたキャッシュディレクトリを削除 |
|
56
|
1 |
|
$finder = Finder::create()->in($cacheDir.'/'.$dir); |
|
57
|
1 |
|
$filesystem->remove($finder); |
|
58
|
1 |
|
} |
|
59
|
1 |
|
if ($dir == 'doctrine') { |
|
60
|
|
|
// doctrineが指定された場合は, cache driver経由で削除. |
|
61
|
|
|
$config = $app['orm.em']->getConfiguration(); |
|
62
|
|
|
$this->deleteDoctrineCache($config->getMetadataCacheImpl()); |
|
63
|
|
|
$this->deleteDoctrineCache($config->getQueryCacheImpl()); |
|
64
|
|
|
$this->deleteDoctrineCache($config->getResultCacheImpl()); |
|
65
|
|
|
$this->deleteDoctrineCache($config->getHydrationCacheImpl()); |
|
66
|
|
|
} |
|
67
|
1 |
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
$app->addSuccess('admin.content.cache.save.complete', 'admin'); |
|
70
|
1 |
|
} |
|
71
|
|
|
|
|
72
|
2 |
|
return $app->render('Content/cache.twig', array( |
|
73
|
2 |
|
'form' => $form->createView(), |
|
74
|
2 |
|
)); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
protected function deleteDoctrineCache(\Doctrine\Common\Cache\Cache $cacheDriver) |
|
78
|
|
|
{ |
|
79
|
|
|
$cacheDriver->deleteAll(); |
|
|
|
|
|
|
80
|
|
|
$cacheDriver->flushAll(); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|