Inheritance: extends Silex\Application
 public function __construct(array $values = array())
 {
     $app = $this;
     parent::__construct($values);
     $app->register(new \Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => __DIR__ . '/../../app/log/install.log'));
     $app->register(new \Silex\Provider\SessionServiceProvider());
     $app->register(new \Silex\Provider\TwigServiceProvider(), array('twig.path' => array(__DIR__ . '/Resource/template/install'), 'twig.form.templates' => array('bootstrap_3_horizontal_layout.html.twig')));
     $this->register(new \Silex\Provider\UrlGeneratorServiceProvider());
     $this->register(new \Silex\Provider\FormServiceProvider());
     $this->register(new \Silex\Provider\ValidatorServiceProvider());
     $this->register(new \Silex\Provider\TranslationServiceProvider(), array('locale' => 'ja'));
     $app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
         $translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
         $translator->addResource('yaml', __DIR__ . '/Resource/locale/ja.yml', 'ja');
         return $translator;
     }));
     $app->mount('', new ControllerProvider\InstallControllerProvider());
     $app->register(new ServiceProvider\InstallServiceProvider());
     $app->error(function (\Exception $e, $code) use($app) {
         if ($code === 404) {
             return $app->redirect($app['url_generator']->generate('install'));
         } elseif ($app['debug']) {
             return;
         }
         return $app['twig']->render('error.twig', array('error' => 'エラーが発生しました.'));
     });
 }
Beispiel #2
0
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     // load config
     $this->initConfig();
     // init monolog
     $this->initLogger();
 }
 public function __construct(array $values = array())
 {
     $app = $this;
     parent::__construct($values);
     $app->register(new \Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => __DIR__ . '/../../app/log/install.log'));
     // load config
     $app['config'] = $app->share(function () {
         $distPath = __DIR__ . '/../../src/Eccube/Resource/config';
         $configConstant = array();
         $constantYamlPath = $distPath . '/constant.yml.dist';
         if (file_exists($constantYamlPath)) {
             $configConstant = Yaml::parse($constantYamlPath);
         }
         $configLog = array();
         $logYamlPath = $distPath . '/log.yml.dist';
         if (file_exists($logYamlPath)) {
             $configLog = Yaml::parse($logYamlPath);
         }
         $config = array_replace_recursive($configConstant, $configLog);
         return $config;
     });
     $distPath = __DIR__ . '/../../src/Eccube/Resource/config';
     $config_dist = Yaml::parse($distPath . '/config.yml.dist');
     if (!empty($config_dist['timezone'])) {
         date_default_timezone_set($config_dist['timezone']);
     }
     $app->register(new \Silex\Provider\SessionServiceProvider());
     $app->register(new \Silex\Provider\TwigServiceProvider(), array('twig.path' => array(__DIR__ . '/Resource/template/install'), 'twig.form.templates' => array('bootstrap_3_horizontal_layout.html.twig')));
     $this->register(new \Silex\Provider\UrlGeneratorServiceProvider());
     $this->register(new \Silex\Provider\FormServiceProvider());
     $this->register(new \Silex\Provider\ValidatorServiceProvider());
     $this->register(new \Silex\Provider\TranslationServiceProvider(), array('locale' => 'ja'));
     $app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
         $translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
         $r = new \ReflectionClass('Symfony\\Component\\Validator\\Validator');
         $file = dirname($r->getFilename()) . '/Resources/translations/validators.' . $app['locale'] . '.xlf';
         if (file_exists($file)) {
             $translator->addResource('xliff', $file, $app['locale'], 'validators');
         }
         $file = __DIR__ . '/Resource/locale/validator.' . $app['locale'] . '.yml';
         if (file_exists($file)) {
             $translator->addResource('yaml', $file, $app['locale'], 'validators');
         }
         $translator->addResource('yaml', __DIR__ . '/Resource/locale/ja.yml', $app['locale']);
         return $translator;
     }));
     $app->mount('', new ControllerProvider\InstallControllerProvider());
     $app->register(new ServiceProvider\InstallServiceProvider());
     $app->error(function (\Exception $e, $code) use($app) {
         if ($code === 404) {
             return $app->redirect($app['url_generator']->generate('install'));
         } elseif ($app['debug']) {
             return;
         }
         return $app['twig']->render('error.twig', array('error' => 'エラーが発生しました.'));
     });
 }
Beispiel #4
0
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     if (is_null(self::$instance)) {
         self::$instance = $this;
     }
     // load config
     $this->initConfig();
     // init monolog
     $this->initLogger();
 }