Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Improved service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Jan 30, 2016
1 parent 0bbe5c2 commit 2b52553
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 3.2.2 (released 2016-01-30)

- Improved service provider

## 3.2.1 (released 2016-01-17)

- Lumen 5.2 support
Expand Down
32 changes: 13 additions & 19 deletions src/InstagramServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Vinkla\Instagram;

use Illuminate\Contracts\Container\Container as Application;
use Illuminate\Contracts\Container\Container;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
Expand Down Expand Up @@ -59,62 +59,56 @@ protected function setupConfig()
*/
public function register()
{
$this->registerFactory($this->app);
$this->registerManager($this->app);
$this->registerBindings($this->app);
$this->registerFactory();
$this->registerManager();
$this->registerBindings();
}

/**
* Register the factory class.
*
* @param \Illuminate\Contracts\Container\Container $app
*
* @return void
*/
protected function registerFactory(Application $app)
protected function registerFactory()
{
$app->singleton('instagram.factory', function () {
$this->app->singleton('instagram.factory', function () {
return new InstagramFactory();
});

$app->alias('instagram.factory', InstagramFactory::class);
$this->app->alias('instagram.factory', InstagramFactory::class);
}

/**
* Register the manager class.
*
* @param \Illuminate\Contracts\Container\Container $app
*
* @return void
*/
protected function registerManager(Application $app)
protected function registerManager()
{
$app->singleton('instagram', function ($app) {
$this->app->singleton('instagram', function (Container $app) {
$config = $app['config'];
$factory = $app['instagram.factory'];

return new InstagramManager($config, $factory);
});

$app->alias('instagram', InstagramManager::class);
$this->app->alias('instagram', InstagramManager::class);
}

/**
* Register the bindings.
*
* @param \Illuminate\Contracts\Container\Container $app
*
* @return void
*/
protected function registerBindings(Application $app)
protected function registerBindings()
{
$app->bind('instagram.connection', function ($app) {
$this->app->bind('instagram.connection', function (Container $app) {
$manager = $app['instagram'];

return $manager->connection();
});

$app->alias('instagram.connection', Instagram::class);
$this->app->alias('instagram.connection', Instagram::class);
}

/**
Expand Down

0 comments on commit 2b52553

Please sign in to comment.