コード例 #1
0
ファイル: Client.php プロジェクト: hachi-zzq/oauth2-demo-php
 /**
  * Connect the controller classes to the routes
  */
 public function connect(Application $app)
 {
     // set up the service container
     $this->setup($app);
     // Load routes from the controller classes
     $routing = $app['controllers_factory'];
     Controllers\Homepage::addRoutes($routing);
     Controllers\ReceiveAuthorizationCode::addRoutes($routing);
     Controllers\RequestToken::addRoutes($routing);
     Controllers\RequestResource::addRoutes($routing);
     Controllers\ReceiveImplicitToken::addRoutes($routing);
     return $routing;
 }
コード例 #2
0
ファイル: Client.php プロジェクト: rachid804/oauth
 public function connect(Application $app)
 {
     // set up silex application
     $app->register(new UrlGeneratorServiceProvider());
     $app->register(new TwigServiceProvider(), array('twig.path' => __DIR__ . '/../../../views'));
     // sets twig extension for client debug rendering
     $app->extend('twig', function (\Twig_Environment $twig) {
         $twig->addExtension(new Twig\JsonStringifyExtension());
         return $twig;
     });
     $this->configureSecurity($app);
     // set up the service container
     $this->setup($app);
     // create http client
     $app['http_client'] = new GuzzleClient('', array('request.options' => array('exceptions' => false)));
     // create the session
     $app->register(new SessionServiceProvider());
     if (!$app['session']->isStarted()) {
         $app['session']->start();
     }
     // creates a new controller based on the default route
     $routing = $app['controllers_factory'];
     /** @var EventDispatcher $dispatcher */
     $dispatcher = $app['dispatcher'];
     // a quick event listener to inject the container into our BaseController
     $dispatcher->addListener(KernelEvents::CONTROLLER, function (FilterControllerEvent $event) use($app) {
         $controller = $event->getController();
         if (!is_array($controller)) {
             return;
         }
         $controllerObject = $controller[0];
         if ($controllerObject instanceof BaseController) {
             $controllerObject->setContainer($app);
         }
     });
     // Set corresponding endpoints on the controller classes
     Controllers\Homepage::addRoutes($routing);
     Controllers\CoopOAuthController::addRoutes($routing);
     Controllers\CountEggs::addRoutes($routing);
     Controllers\UserManagement::addRoutes($routing);
     Controllers\FacebookOAuthController::addRoutes($routing);
     return $routing;
 }