예제 #1
2
 /**
  * Initialize the Laravel framework.
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $this->oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $this->oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     // Load the application object
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     $this->app->instance('middleware.disable', $this->module->config['disable_middleware']);
     // Reset the old database after the DatabaseServiceProvider ran.
     // This way other service providers that rely on the $app['db'] entry
     // have the correct instance available.
     if ($this->oldDb) {
         $this->app['events']->listen('Illuminate\\Database\\DatabaseServiceProvider', function () {
             $this->app->singleton('db', function () {
                 return $this->oldDb;
             });
         });
     }
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // If events should be disabled mock the event dispatcher instance
     if ($this->module->config['disable_events']) {
         $this->mockEventDispatcher();
     }
     // Setup an event listener to listen for all events that are triggered
     $this->setupEventListener();
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
예제 #2
2
파일: Laravel5.php 프로젝트: Dossar/boltbse
 /**
  * Initialize the Laravel framework.
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     // Load the application object
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     $this->app->instance('middleware.disable', $this->module->config['disable_middleware']);
     // Bootstrap the application
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Restore the old database object if available
     if ($oldDb) {
         $this->app['db'] = $oldDb;
         Model::setConnectionResolver($this->app['db']);
     }
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
예제 #3
1
파일: Laravel5.php 프로젝트: corcre/elabftw
 /**
  * Initialize the Laravel framework.
  */
 private function initialize()
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     $this->app = $this->kernel = $this->loadApplication();
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Set the base url for the Request object
     $url = $this->app['config']->get('app.url', 'http://localhost');
     $this->app->instance('request', Request::createFromBase(SymfonyRequest::create($url)));
     if ($oldDb) {
         $this->app['db'] = $oldDb;
         Model::setConnectionResolver($this->app['db']);
     }
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
예제 #4
0
 /**
  * Initialize the Laravel framework.
  *
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $this->oldDb = null;
     if (isset($this->app['db']) && $this->app['db']->connection()) {
         $this->oldDb = $this->app['db'];
     }
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application,
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     // Reset the old database after the DatabaseServiceProvider ran.
     // This way other service providers that rely on the $app['db'] entry
     // have the correct instance available.
     if ($this->oldDb) {
         $this->app['events']->listen('Illuminate\\Database\\DatabaseServiceProvider', function () {
             $this->app->singleton('db', function () {
                 return $this->oldDb;
             });
         });
     }
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Record all triggered events by adding a wildcard event listener
     $this->app['events']->listen('*', function () {
         $this->triggeredEvents[] = $this->normalizeEvent($this->app['events']->firing());
     });
     // Replace the Laravel exception handler with our decorated exception handler,
     // so exceptions can be intercepted for the disable_exception_handling functionality.
     $decorator = new ExceptionHandlerDecorator($this->app['Illuminate\\Contracts\\Debug\\ExceptionHandler']);
     $decorator->exceptionHandlingDisabled($this->exceptionHandlingDisabled);
     $this->app->instance('Illuminate\\Contracts\\Debug\\ExceptionHandler', $decorator);
     if ($this->module->config['disable_middleware'] || $this->middlewareDisabled) {
         $this->app->instance('middleware.disable', true);
     }
     if ($this->module->config['disable_events'] || $this->eventsDisabled) {
         $this->mockEventDispatcher();
     }
     if ($this->module->config['disable_model_events'] || $this->modelEventsDisabled) {
         Model::unsetEventDispatcher();
     }
     $this->applyBindings();
     $this->applyContextualBindings();
     $this->applyInstances();
     $this->module->setApplication($this->app);
 }