Skip to content

Commit

Permalink
[Example] Extract getting instance for Auth\Service from routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Aug 12, 2015
1 parent 95fda39 commit 4b314d2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions example/index.php
Expand Up @@ -11,11 +11,11 @@
include_once __DIR__ . '/vendor/autoload.php';
$configureProviders = include_once 'config.php';

$app = new \Slim\Slim();
$app->get('/auth/cb/:provider/:params', function ($provider) use (&$configureProviders) {
$service = new \SocialConnect\Auth\Service($configureProviders, null);
$service->setHttpClient(new \SocialConnect\Common\Http\Client\Curl());
$service = new \SocialConnect\Auth\Service($configureProviders, null);
$service->setHttpClient(new \SocialConnect\Common\Http\Client\Curl());

$app = new \Slim\Slim();
$app->get('/auth/cb/:provider/:params', function ($provider) use (&$configureProviders, $service) {
$provider = strtolower($provider);
switch ($provider) {
case 'facebook':
Expand Down Expand Up @@ -46,10 +46,7 @@
include_once 'page.php';
});

$app->post('/', function () use (&$configureProviders) {
$service = new \SocialConnect\Auth\Service($configureProviders, null);
$service->setHttpClient(new \SocialConnect\Common\Http\Client\Guzzle());

$app->post('/', function () use (&$configureProviders, $service) {
try {
if (!empty($_POST['provider'])) {
$providerName = $_POST['provider'];
Expand Down

0 comments on commit 4b314d2

Please sign in to comment.