Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c9adc7d

Browse files
Merge 4.7 into 4.8 (#3075)
2 parents 046b92a + 895dcc7 commit c9adc7d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎src/MongoDBBusServiceProvider.php‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
use Illuminate\Container\Container;
99
use Illuminate\Contracts\Support\DeferrableProvider;
1010
use Illuminate\Support\ServiceProvider;
11+
use InvalidArgumentException;
1112
use MongoDB\Laravel\Bus\MongoBatchRepository;
1213

14+
use function sprintf;
15+
1316
class MongoDBBusServiceProvider extends ServiceProvider implements DeferrableProvider
1417
{
1518
/**
@@ -18,14 +21,21 @@ class MongoDBBusServiceProvider extends ServiceProvider implements DeferrablePro
1821
public function register()
1922
{
2023
$this->app->singleton(MongoBatchRepository::class, function (Container $app) {
24+
$connection = $app->make('db')->connection($app->config->get('queue.batching.database'));
25+
26+
if (! $connection instanceof Connection) {
27+
throw new InvalidArgumentException(sprintf('The "mongodb" batch driver requires a MongoDB connection. The "%s" connection uses the "%s" driver.', $connection->getName(), $connection->getDriverName()));
28+
}
29+
2130
return new MongoBatchRepository(
2231
$app->make(BatchFactory::class),
23-
$app->make('db')->connection($app->config->get('queue.batching.database')),
32+
$connection,
2433
$app->config->get('queue.batching.collection', 'job_batches'),
2534
);
2635
});
2736

28-
/** @see BusServiceProvider::registerBatchServices() */
37+
/** The {@see BatchRepository} service is registered in {@see BusServiceProvider} */
38+
$this->app->register(BusServiceProvider::class);
2939
$this->app->extend(BatchRepository::class, function (BatchRepository $repository, Container $app) {
3040
$driver = $app->config->get('queue.batching.driver');
3141

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /