Permalink
Browse files

Convert to new bindShared method on container.

  • Loading branch information...
taylorotwell committed Oct 29, 2013
1 parent 41c829f commit 07233b32eb190dffde427b3aee1e5e4f855abd00
Showing with 87 additions and 87 deletions.
  1. +1 −1 src/Illuminate/Auth/AuthServiceProvider.php
  2. +4 −8 src/Illuminate/Auth/Reminders/ReminderServiceProvider.php
  3. +3 −3 src/Illuminate/Cache/CacheServiceProvider.php
  4. +12 −0 src/Illuminate/Container/Container.php
  5. +1 −1 src/Illuminate/Cookie/CookieServiceProvider.php
  6. +2 −2 src/Illuminate/Database/DatabaseServiceProvider.php
  7. +9 −9 src/Illuminate/Database/MigrationServiceProvider.php
  8. +2 −2 src/Illuminate/Database/SeedServiceProvider.php
  9. +1 −1 src/Illuminate/Encryption/EncryptionServiceProvider.php
  10. +1 −1 src/Illuminate/Filesystem/FilesystemServiceProvider.php
  11. +4 −4 src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
  12. +1 −1 src/Illuminate/Foundation/Providers/CommandCreatorServiceProvider.php
  13. +2 −2 src/Illuminate/Foundation/Providers/ComposerServiceProvider.php
  14. +1 −1 src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php
  15. +2 −2 src/Illuminate/Foundation/Providers/MaintenanceServiceProvider.php
  16. +2 −2 src/Illuminate/Foundation/Providers/OptimizeServiceProvider.php
  17. +8 −8 src/Illuminate/Foundation/Providers/PublisherServiceProvider.php
  18. +1 −1 src/Illuminate/Foundation/Providers/RouteListServiceProvider.php
  19. +1 −1 src/Illuminate/Foundation/Providers/ServerServiceProvider.php
  20. +1 −1 src/Illuminate/Foundation/Providers/TinkerServiceProvider.php
  21. +1 −1 src/Illuminate/Hashing/HashServiceProvider.php
  22. +2 −2 src/Illuminate/Html/HtmlServiceProvider.php
  23. +1 −1 src/Illuminate/Mail/MailServiceProvider.php
  24. +1 −1 src/Illuminate/Pagination/PaginationServiceProvider.php
  25. +6 −12 src/Illuminate/Queue/QueueServiceProvider.php
  26. +1 −1 src/Illuminate/Redis/RedisServiceProvider.php
  27. +1 −1 src/Illuminate/Remote/RemoteServiceProvider.php
  28. +1 −1 src/Illuminate/Routing/ControllerServiceProvider.php
  29. +1 −3 src/Illuminate/Session/CommandsServiceProvider.php
  30. +2 −2 src/Illuminate/Session/SessionServiceProvider.php
  31. +3 −3 src/Illuminate/Translation/TranslationServiceProvider.php
  32. +2 −2 src/Illuminate/Validation/ValidationServiceProvider.php
  33. +4 −4 src/Illuminate/View/ViewServiceProvider.php
  34. +2 −2 src/Illuminate/Workbench/WorkbenchServiceProvider.php
@@ -18,7 +18,7 @@ class AuthServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['auth'] = $this->app->share(function($app)
$this->app->bindShared('auth', function($app)
{
// Once the authentication service has actually been requested by the developer
// we will set a variable in the application indicating such. This helps us
@@ -35,7 +35,7 @@ public function register()
*/
protected function registerPasswordBroker()
{
$this->app['auth.reminder'] = $this->app->share(function($app)
$this->app->bindShared('auth.reminder', function($app)
{
// The reminder repository is responsible for storing the user e-mail addresses
// and password reset tokens. It will be used to verify the tokens are valid
@@ -64,9 +64,7 @@ protected function registerPasswordBroker()
*/
protected function registerReminderRepository()
{
$app = $this->app;
$app['auth.reminder.repository'] = $app->share(function($app)
$this->app->bindShared('auth.reminder.repository', function($app)
{
$connection = $app['db']->connection();
@@ -90,14 +88,12 @@ protected function registerReminderRepository()
*/
protected function registerCommands()
{
$app = $this->app;
$app['command.auth.reminders'] = $app->share(function($app)
$this->app->bindShared('command.auth.reminders', function($app)
{
return new MakeRemindersCommand($app['files']);
});
$app['command.auth.reminders.clear'] = $app->share(function($app)
$this->app->bindShared('command.auth.reminders.clear', function($app)
{
return new ClearRemindersCommand;
});
@@ -18,12 +18,12 @@ class CacheServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['cache'] = $this->app->share(function($app)
$this->app->bindShared('cache', function($app)
{
return new CacheManager($app);
});
$this->app['memcached.connector'] = $this->app->share(function()
$this->app->bindShared('memcached.connector', function()
{
return new MemcachedConnector;
});
@@ -38,7 +38,7 @@ public function register()
*/
public function registerCommands()
{
$this->app['command.cache.clear'] = $this->app->share(function($app)
$this->app->bindShared('command.cache.clear', function($app)
{
return new Console\ClearCommand($app['cache'], $app['files']);
});
@@ -182,6 +182,18 @@ public function share(Closure $closure)
};
}
/**
* Bind a shared Closure into the container.
*
* @param string $abstract
* @param \Closure $closure
* @return void
*/
public function bindShared($abstract, Closure $closure)
{
return $this->bind($abstract, $this->share($closure), true);
}
/**
* "Extend" an abstract type in the container.
*
@@ -11,7 +11,7 @@ class CookieServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['cookie'] = $this->app->share(function($app)
$this->app->bindShared('cookie', function($app)
{
$config = $app['config']['session'];
@@ -28,15 +28,15 @@ public function register()
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->app['db.factory'] = $this->app->share(function($app)
$this->app->bindShared('db.factory', function($app)
{
return new ConnectionFactory($app);
});
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->app['db'] = $this->app->share(function($app)
$this->app->bindShared('db', function($app)
{
return new DatabaseManager($app, $app['db.factory']);
});
@@ -44,7 +44,7 @@ public function register()
*/
protected function registerRepository()
{
$this->app['migration.repository'] = $this->app->share(function($app)
$this->app->bindShared('migration.repository', function($app)
{
$table = $app['config']['database.migrations'];
@@ -62,7 +62,7 @@ protected function registerMigrator()
// The migrator is responsible for actually running and rollback the migration
// files in the application. We'll pass in our database connection resolver
// so the migrator can resolve any of these connections when it needs to.
$this->app['migrator'] = $this->app->share(function($app)
$this->app->bindShared('migrator', function($app)
{
$repository = $app['migration.repository'];
@@ -104,7 +104,7 @@ protected function registerCommands()
*/
protected function registerMigrateCommand()
{
$this->app['command.migrate'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate', function($app)
{
$packagePath = $app['path.base'].'/vendor';
@@ -119,7 +119,7 @@ protected function registerMigrateCommand()
*/
protected function registerRollbackCommand()
{
$this->app['command.migrate.rollback'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate.rollback', function($app)
{
return new RollbackCommand($app['migrator']);
});
@@ -132,7 +132,7 @@ protected function registerRollbackCommand()
*/
protected function registerResetCommand()
{
$this->app['command.migrate.reset'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate.reset', function($app)
{
return new ResetCommand($app['migrator']);
});
@@ -145,7 +145,7 @@ protected function registerResetCommand()
*/
protected function registerRefreshCommand()
{
$this->app['command.migrate.refresh'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate.refresh', function($app)
{
return new RefreshCommand;
});
@@ -158,7 +158,7 @@ protected function registerRefreshCommand()
*/
protected function registerInstallCommand()
{
$this->app['command.migrate.install'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate.install', function($app)
{
return new InstallCommand($app['migration.repository']);
});
@@ -171,12 +171,12 @@ protected function registerInstallCommand()
*/
protected function registerMakeCommand()
{
$this->app['migration.creator'] = $this->app->share(function($app)
$this->app->bindShared('migration.creator', function($app)
{
return new MigrationCreator($app['files']);
});
$this->app['command.migrate.make'] = $this->app->share(function($app)
$this->app->bindShared('command.migrate.make', function($app)
{
// Once we have the migration creator registered, we will create the command
// and inject the creator. The creator is responsible for the actual file
@@ -21,7 +21,7 @@ public function register()
{
$this->registerSeedCommand();
$this->app['seeder'] = $this->app->share(function($app)
$this->app->bindShared('seeder', function($app)
{
return new Seeder;
});
@@ -36,7 +36,7 @@ public function register()
*/
protected function registerSeedCommand()
{
$this->app['command.seed'] = $this->app->share(function($app)
$this->app->bindShared('command.seed', function($app)
{
return new SeedCommand($app['db']);
});
@@ -11,7 +11,7 @@ class EncryptionServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['encrypter'] = $this->app->share(function($app)
$this->app->bindShared('encrypter', function($app)
{
return new Encrypter($app['config']['app.key']);
});
@@ -11,7 +11,7 @@ class FilesystemServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['files'] = $this->app->share(function() { return new Filesystem; });
$this->app->bindShared('files', function() { return new Filesystem; });
}
}
@@ -22,22 +22,22 @@ class ArtisanServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['artisan'] = $this->app->share(function($app)
$this->app->bindShared('artisan', function($app)
{
return new Artisan($app);
});
$this->app['command.tail'] = $this->app->share(function($app)
$this->app->bindShared('command.tail', function($app)
{
return new TailCommand;
});
$this->app['command.changes'] = $this->app->share(function($app)
$this->app->bindShared('command.changes', function($app)
{
return new ChangesCommand;
});
$this->app['command.environment'] = $this->app->share(function($app)
$this->app->bindShared('command.environment', function($app)
{
return new EnvironmentCommand;
});
@@ -19,7 +19,7 @@ class CommandCreatorServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['command.command.make'] = $this->app->share(function($app)
$this->app->bindShared('command.command.make', function($app)
{
return new CommandMakeCommand($app['files']);
});
@@ -20,12 +20,12 @@ class ComposerServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['composer'] = $this->app->share(function($app)
$this->app->bindShared('composer', function($app)
{
return new Composer($app['files'], $app['path.base']);
});
$this->app['command.dump-autoload'] = $this->app->share(function($app)
$this->app->bindShared('command.dump-autoload', function($app)
{
return new AutoloadCommand($app['composer']);
});
@@ -19,7 +19,7 @@ class KeyGeneratorServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['command.key.generate'] = $this->app->share(function($app)
$this->app->bindShared('command.key.generate', function($app)
{
return new KeyGenerateCommand($app['files']);
});
@@ -20,12 +20,12 @@ class MaintenanceServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['command.up'] = $this->app->share(function($app)
$this->app->bindShared('command.up', function($app)
{
return new UpCommand;
});
$this->app['command.down'] = $this->app->share(function($app)
$this->app->bindShared('command.down', function($app)
{
return new DownCommand;
});
@@ -34,7 +34,7 @@ public function register()
*/
protected function registerOptimizeCommand()
{
$this->app['command.optimize'] = $this->app->share(function($app)
$this->app->bindShared('command.optimize', function($app)
{
return new OptimizeCommand($app['composer']);
});
@@ -47,7 +47,7 @@ protected function registerOptimizeCommand()
*/
protected function registerClearCompiledCommand()
{
$this->app['command.clear-compiled'] = $this->app->share(function()
$this->app->bindShared('command.clear-compiled', function()
{
return new ClearCompiledCommand;
});
@@ -42,7 +42,7 @@ protected function registerAssetPublisher()
{
$this->registerAssetPublishCommand();
$this->app['asset.publisher'] = $this->app->share(function($app)
$this->app->bindShared('asset.publisher', function($app)
{
$publicPath = $app['path.public'];
@@ -64,7 +64,7 @@ protected function registerAssetPublisher()
*/
protected function registerAssetPublishCommand()
{
$this->app['command.asset.publish'] = $this->app->share(function($app)
$this->app->bindShared('command.asset.publish', function($app)
{
return new AssetPublishCommand($app['asset.publisher']);
});
@@ -79,14 +79,14 @@ protected function registerConfigPublisher()
{
$this->registerConfigPublishCommand();
$this->app['config.publisher'] = $this->app->share(function($app)
$this->app->bindShared('config.publisher', function($app)
{
$configPath = $app['path'].'/config';
$path = $app['path'].'/config';
// Once we have created the configuration publisher, we will set the default
// package path on the object so that it knows where to find the packages
// that are installed for the application and can move them to the app.
$publisher = new ConfigPublisher($app['files'], $configPath);
$publisher = new ConfigPublisher($app['files'], $path);
$publisher->setPackagePath($app['path.base'].'/vendor');
@@ -101,7 +101,7 @@ protected function registerConfigPublisher()
*/
protected function registerConfigPublishCommand()
{
$this->app['command.config.publish'] = $this->app->share(function($app)
$this->app->bindShared('command.config.publish', function($app)
{
return new ConfigPublishCommand($app['config.publisher']);
});
@@ -116,7 +116,7 @@ protected function registerViewPublisher()
{
$this->registerViewPublishCommand();
$this->app['view.publisher'] = $this->app->share(function($app)
$this->app->bindShared('view.publisher', function($app)
{
$viewPath = $app['path'].'/views';
@@ -138,7 +138,7 @@ protected function registerViewPublisher()
*/
protected function registerViewPublishCommand()
{
$this->app['command.view.publish'] = $this->app->share(function($app)
$this->app->bindShared('command.view.publish', function($app)
{
return new ViewPublishCommand($app['view.publisher']);
});
@@ -19,7 +19,7 @@ class RouteListServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->app['command.routes'] = $this->app->share(function($app)
$this->app->bindShared('command.routes', function($app)
{
return new RoutesCommand($app['router']);
});
Oops, something went wrong.

0 comments on commit 07233b3

Please sign in to comment.