Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Bus;
4
 
5
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
6
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
7
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
8
use Illuminate\Contracts\Support\DeferrableProvider;
9
use Illuminate\Support\ServiceProvider;
10
 
11
class BusServiceProvider extends ServiceProvider implements DeferrableProvider
12
{
13
    /**
14
     * Register the service provider.
15
     *
16
     * @return void
17
     */
18
    public function register()
19
    {
20
        $this->app->singleton(Dispatcher::class, function ($app) {
21
            return new Dispatcher($app, function ($connection = null) use ($app) {
22
                return $app[QueueFactoryContract::class]->connection($connection);
23
            });
24
        });
25
 
26
        $this->registerBatchServices();
27
 
28
        $this->app->alias(
29
            Dispatcher::class, DispatcherContract::class
30
        );
31
 
32
        $this->app->alias(
33
            Dispatcher::class, QueueingDispatcherContract::class
34
        );
35
    }
36
 
37
    /**
38
     * Register the batch handling services.
39
     *
40
     * @return void
41
     */
42
    protected function registerBatchServices()
43
    {
44
        $this->app->singleton(BatchRepository::class, DatabaseBatchRepository::class);
45
 
46
        $this->app->singleton(DatabaseBatchRepository::class, function ($app) {
47
            return new DatabaseBatchRepository(
48
                $app->make(BatchFactory::class),
49
                $app->make('db')->connection($app->config->get('queue.batching.database')),
50
                $app->config->get('queue.batching.table', 'job_batches')
51
            );
52
        });
53
    }
54
 
55
    /**
56
     * Get the services provided by the provider.
57
     *
58
     * @return array
59
     */
60
    public function provides()
61
    {
62
        return [
63
            Dispatcher::class,
64
            DispatcherContract::class,
65
            QueueingDispatcherContract::class,
66
            BatchRepository::class,
67
            DatabaseBatchRepository::class,
68
        ];
69
    }
70
}