Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit c3a592e

Browse files
committed
ADD: Lumen support
1 parent 194e079 commit c3a592e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/PubSubLumenManager.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Superbalist\LaravelPubSub;
4+
5+
use Laravel\Lumen\Application;
6+
7+
class PubSubLumenManager extends PubSubManager
8+
{
9+
10+
/**
11+
* @param Application $app
12+
* @param PubSubConnectionFactory $factory
13+
*/
14+
public function __construct(Application $app, PubSubConnectionFactory $factory)
15+
{
16+
$this->app = $app;
17+
$this->factory = $factory;
18+
}
19+
}

src/PubSubLumenServiceProvider.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Superbalist\LaravelPubSub;
4+
5+
use Superbalist\PubSub\PubSubAdapterInterface;
6+
7+
class PubSubLumenServiceProvider extends PubSubServiceProvider
8+
{
9+
/**
10+
* Perform post-registration booting of services.
11+
*/
12+
public function boot()
13+
{
14+
$this->app->configure('pubsub');
15+
}
16+
17+
/**
18+
* Register bindings in the container.
19+
*/
20+
public function register()
21+
{
22+
$this->mergeConfigFrom(__DIR__ . '/../config/pubsub.php', 'pubsub');
23+
24+
$this->app->singleton('pubsub.factory', function ($app) {
25+
return new PubSubConnectionFactory($app);
26+
});
27+
28+
$this->app->singleton('pubsub', function ($app) {
29+
return new PubSubLumenManager($app, $app['pubsub.factory']);
30+
});
31+
32+
$this->app->bind('pubsub.connection', PubSubAdapterInterface::class);
33+
34+
$this->app->bind(PubSubAdapterInterface::class, function ($app) {
35+
$manager = $app['pubsub']; /* @var PubSubManager $manager */
36+
return $manager->connection();
37+
});
38+
39+
$this->registerAdapterDependencies();
40+
41+
$this->commands(SubscriberMakeCommand::class);
42+
}
43+
}

0 commit comments

Comments
 (0)