|
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
|
|
|
namespace Eccube; |
|
25
|
|
|
|
|
26
|
|
|
use Eccube\Application\ApplicationTrait; |
|
27
|
|
|
use Eccube\ServiceProvider\DiServiceProvider; |
|
28
|
|
|
|
|
29
|
|
|
class InstallApplication extends \Silex\Application |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
use \Silex\Application\FormTrait; |
|
32
|
|
|
use \Silex\Application\UrlGeneratorTrait; |
|
33
|
|
|
use \Silex\Application\MonologTrait; |
|
34
|
|
|
use \Silex\Application\SwiftmailerTrait; |
|
35
|
|
|
use \Silex\Application\SecurityTrait; |
|
36
|
|
|
use \Eccube\Application\ApplicationTrait; |
|
37
|
|
|
use \Eccube\Application\SecurityTrait; |
|
38
|
|
|
use \Eccube\Application\TwigTrait; |
|
39
|
|
|
|
|
40
|
42 |
|
public function __construct(array $values = array()) |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
42 |
|
$app = $this; |
|
43
|
|
|
|
|
44
|
42 |
|
parent::__construct($values); |
|
45
|
|
|
|
|
46
|
42 |
|
$logDir = realpath(__DIR__.'/../../app/log'); |
|
47
|
42 |
|
$installLog = $logDir.'/install.log'; |
|
48
|
|
|
|
|
49
|
42 |
|
if (is_writable($logDir)) { |
|
50
|
42 |
|
if (file_exists($installLog) && !is_writable($installLog)) { |
|
51
|
|
|
die($installLog . ' の書込権限を変更して下さい。'); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
// install step2 でログディレクトリに書き込み権限が付与されればログ出力を開始する. |
|
54
|
42 |
|
$app->register(new \Silex\Provider\MonologServiceProvider(), array( |
|
55
|
42 |
|
'monolog.logfile' => $installLog, |
|
56
|
|
|
)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
// load config |
|
60
|
|
|
$app['config'] = function() { |
|
|
|
|
|
|
61
|
28 |
|
$distPath = __DIR__.'/../../src/Eccube/Resource/config'; |
|
62
|
|
|
|
|
63
|
28 |
|
$configConstant = array(); |
|
64
|
28 |
|
$constantYamlPath = $distPath.'/constant.php'; |
|
65
|
28 |
|
if (file_exists($constantYamlPath)) { |
|
66
|
28 |
|
$configConstant = require $constantYamlPath; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
28 |
|
$configLog = array(); |
|
70
|
28 |
|
$logYamlPath = $distPath.'/log.php'; |
|
71
|
28 |
|
if (file_exists($logYamlPath)) { |
|
72
|
28 |
|
$configLog = require $logYamlPath; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
28 |
|
$config = array_replace_recursive($configConstant, $configLog); |
|
76
|
|
|
|
|
77
|
28 |
|
return $config; |
|
78
|
|
|
}; |
|
79
|
|
|
|
|
80
|
42 |
|
$distPath = __DIR__.'/../../src/Eccube/Resource/config'; |
|
81
|
42 |
|
$config_dist = require $distPath.'/config.php'; |
|
82
|
42 |
|
if (!empty($config_dist['timezone'])) { |
|
83
|
42 |
|
date_default_timezone_set($config_dist['timezone']); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
42 |
|
$app->register(new \Silex\Provider\SessionServiceProvider()); |
|
87
|
42 |
|
$app->register(new \Silex\Provider\TwigServiceProvider(), array( |
|
88
|
42 |
|
'twig.path' => array(__DIR__.'/Resource/template/install'), |
|
89
|
|
|
'twig.form.templates' => array('bootstrap_3_horizontal_layout.html.twig'), |
|
90
|
|
|
)); |
|
91
|
|
|
|
|
92
|
42 |
|
$this->register(new \Silex\Provider\FormServiceProvider()); |
|
93
|
42 |
|
$this->register(new \Silex\Provider\ValidatorServiceProvider()); |
|
94
|
|
|
|
|
95
|
42 |
|
$this->register(new \Silex\Provider\TranslationServiceProvider(), array( |
|
96
|
42 |
|
'locale' => 'ja', |
|
97
|
|
|
)); |
|
98
|
|
|
$app->extend('translator', function($translator, \Silex\Application $app) { |
|
|
|
|
|
|
99
|
42 |
|
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader()); |
|
100
|
|
|
|
|
101
|
42 |
|
$r = new \ReflectionClass('Symfony\Component\Validator\Validation'); |
|
102
|
42 |
|
$file = dirname($r->getFilename()).'/Resources/translations/validators.'.$app['locale'].'.xlf'; |
|
103
|
42 |
|
if (file_exists($file)) { |
|
104
|
42 |
|
$translator->addResource('xliff', $file, $app['locale'], 'validators'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
42 |
|
$file = __DIR__.'/Resource/locale/validator.'.$app['locale'].'.yml'; |
|
108
|
42 |
|
if (file_exists($file)) { |
|
109
|
|
|
$translator->addResource('yaml', $file, $app['locale'], 'validators'); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
42 |
|
$translator->addResource('yaml', __DIR__.'/Resource/locale/ja.yml', $app['locale']); |
|
113
|
|
|
|
|
114
|
42 |
|
return $translator; |
|
115
|
42 |
|
}); |
|
116
|
|
|
|
|
117
|
42 |
|
$app->mount('', new ControllerProvider\InstallControllerProvider()); |
|
|
|
|
|
|
118
|
42 |
|
$app->register(new ServiceProvider\InstallServiceProvider()); |
|
119
|
42 |
|
$app->register(new \Silex\Provider\CsrfServiceProvider()); |
|
120
|
|
|
|
|
121
|
42 |
|
$app->error(function(\Exception $e, $code) use ($app) { |
|
|
|
|
|
|
122
|
|
|
if ($code === 404) { |
|
123
|
|
|
return $app->redirect($app->url('install')); |
|
124
|
|
|
} elseif ($app['debug']) { |
|
125
|
|
|
return; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
return $app['twig']->render('error.twig', array( |
|
129
|
|
|
'error' => 'エラーが発生しました.', |
|
130
|
|
|
)); |
|
131
|
42 |
|
}); |
|
132
|
|
|
|
|
133
|
42 |
|
$app->register(new DiServiceProvider(), [ |
|
|
|
|
|
|
134
|
42 |
|
'eccube.di.scanners' => [ |
|
|
|
|
|
|
135
|
42 |
|
new \Eccube\Di\Scanner\FormTypeScanner([ |
|
|
|
|
|
|
136
|
42 |
|
__DIR__.'/Form/Type/Install' |
|
137
|
|
|
]) |
|
138
|
|
|
], |
|
139
|
|
|
'eccube.di.generator.dir' => __DIR__.'/../../app/cache/provider', |
|
140
|
42 |
|
'eccube.di.generator.class' => 'InstallServiceProviderCache' |
|
141
|
|
|
]); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|