Example #1
0
 /**
  * Creates the application.
  *
  * @return Synapse\Application
  */
 public function createApplicationWithServices(array $services)
 {
     defined('WEBDIR') or define('WEBDIR', realpath(__DIR__));
     defined('APPDIR') or define('APPDIR', realpath(WEBDIR . '/..'));
     defined('DATADIR') or define('DATADIR', APPDIR . '/data');
     defined('TMPDIR') or define('TMPDIR', '/tmp');
     date_default_timezone_set('UTC');
     $applicationInitializer = new Synapse\ApplicationInitializer();
     $app = $applicationInitializer->initialize();
     $app->register(new \Silex\Provider\SecurityServiceProvider());
     $app->register(new \Synapse\Controller\ControllerServiceProvider());
     $app->register(new \Silex\Provider\UrlGeneratorServiceProvider());
     $app['security.firewalls'] = $app->share(function () {
         return ['base.api' => ['pattern' => '^/', 'oauth' => true]];
     });
     $app['security.access_rules'] = $app->share(function () {
         return [];
     });
     // synapse's default session provider doesn't allow for testing so override
     $sessionServiceProvider = new SessionServiceProvider();
     $sessionServiceProvider->register($app);
     $app['debug'] = true;
     $app['session.test'] = true;
     $app['exception_handler']->disable();
     foreach ($services as $service) {
         $app->register($service);
     }
     $this->setupOAuth2Provider($app);
     return $app;
 }
 /**
  * Return the Silex application loaded with all routes and services
  *
  * @return Application
  */
 protected function application()
 {
     // Initialize the Silex Application
     $applicationInitializer = new ApplicationInitializer();
     $app = $applicationInitializer->initialize();
     // Set the default services
     $defaultServices = new \Synapse\Application\Services();
     $defaultServices->register($app);
     // Set the application-specific services
     $appServices = new \Application\Services();
     $appServices->register($app);
     return $app;
 }