Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 4.8 into 5.0 #3077

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/MongoDBBusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
use MongoDB\Laravel\Bus\MongoBatchRepository;

use function sprintf;

class MongoDBBusServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
Expand All @@ -18,14 +21,21 @@ class MongoDBBusServiceProvider extends ServiceProvider implements DeferrablePro
public function register()
{
$this->app->singleton(MongoBatchRepository::class, function (Container $app) {
$connection = $app->make('db')->connection($app->config->get('queue.batching.database'));

if (! $connection instanceof Connection) {
throw new InvalidArgumentException(sprintf('The "mongodb" batch driver requires a MongoDB connection. The "%s" connection uses the "%s" driver.', $connection->getName(), $connection->getDriverName()));
}

return new MongoBatchRepository(
$app->make(BatchFactory::class),
$app->make('db')->connection($app->config->get('queue.batching.database')),
$connection,
$app->config->get('queue.batching.collection', 'job_batches'),
);
});

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

Expand Down
Loading