Eccube\Application::initialize PHP Метод

initialize() публичный Метод

public initialize ( )
    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;
    }

Usage Example

Пример #1
0
 public function setUp()
 {
     parent::setUp();
     $this->app = new \Eccube\Application(array('env' => 'test'));
     $this->app->initialize();
     $this->app->boot();
     // CSRF tokenを無効にしてFormを作成
     $this->form = $this->app['form.factory']->createBuilder('form', null, array('csrf_protection' => false))->add('tel', 'tel')->getForm();
 }
All Usage Examples Of Eccube\Application::initialize