public function initialize()
{
if ($this->initialized) {
return;
}
// init locale
$this->initLocale();
// init session
if (!$this->isSessionStarted()) {
$this->initSession();
}
// init twig
$this->initRendering();
// init provider
$this->register(new \Silex\Provider\HttpCacheServiceProvider(), array('http_cache.cache_dir' => __DIR__ . '/../../app/cache/http/'));
$this->register(new \Silex\Provider\HttpFragmentServiceProvider());
$this->register(new \Silex\Provider\UrlGeneratorServiceProvider());
$this->register(new \Silex\Provider\FormServiceProvider());
$this->register(new \Silex\Provider\SerializerServiceProvider());
$this->register(new \Silex\Provider\ValidatorServiceProvider());
$app = $this;
$this->error(function (\Exception $e, $code) use($app) {
if ($app['debug']) {
return;
}
switch ($code) {
case 403:
$title = 'アクセスできません。';
$message = 'お探しのページはアクセスができない状況にあるか、移動もしくは削除された可能性があります。';
break;
case 404:
$title = 'ページがみつかりません。';
$message = 'URLに間違いがないかご確認ください。';
break;
default:
$title = 'システムエラーが発生しました。';
$message = '大変お手数ですが、サイト管理者までご連絡ください。';
break;
}
return $app->render('error.twig', array('error_title' => $title, 'error_message' => $message));
});
// init mailer
$this->initMailer();
// init doctrine orm
$this->initDoctrine();
// Set up the DBAL connection now to check for a proper connection to the database.
$this->checkDatabaseConnection();
// init security
$this->initSecurity();
// init ec-cube service provider
$this->register(new ServiceProvider\EccubeServiceProvider());
// mount controllers
$this->register(new \Silex\Provider\ServiceControllerServiceProvider());
$this->mount('', new ControllerProvider\FrontControllerProvider());
$this->mount('/' . trim($this['config']['admin_route'], '/') . '/', new ControllerProvider\AdminControllerProvider());
Request::enableHttpMethodParameterOverride();
// PUTやDELETEできるようにする
// add transaction listener
$this['dispatcher']->addSubscriber(new TransactionListener($this));
// init http cache
$this->initCacheRequest();
$this->initialized = true;
}