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