Skip to content

Commit 94f1d3a

Browse files
committed
Add Service Provider
1 parent adc2218 commit 94f1d3a

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

composer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"botman/botman": "~2.0"
2020
},
2121
"require-dev": {
22+
"botman/studio-addons": "~1.0",
23+
"illuminate/contracts": "~5.5.0",
2224
"phpunit/phpunit": "~5.0",
2325
"mockery/mockery": "dev-master",
2426
"ext-curl": "*"
@@ -36,5 +38,12 @@
3638
"scripts": {
3739
"test": "vendor/bin/phpunit",
3840
"cs": "php-cs-fixer fix"
41+
},
42+
"extra": {
43+
"laravel": {
44+
"providers": [
45+
"BotMan\\Drivers\\Nexmo\\Providers\\NexmoServiceProvider"
46+
]
47+
}
3948
}
4049
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace BotMan\Drivers\Nexmo\Providers;
4+
5+
use BotMan\Drivers\Nexmo\NexmoDriver;
6+
use Illuminate\Support\ServiceProvider;
7+
use BotMan\BotMan\Drivers\DriverManager;
8+
use BotMan\Studio\Providers\StudioServiceProvider;
9+
10+
class NexmoServiceProvider extends ServiceProvider
11+
{
12+
/**
13+
* Perform post-registration booting of services.
14+
*
15+
* @return void
16+
*/
17+
public function boot()
18+
{
19+
if (! $this->isRunningInBotManStudio()) {
20+
$this->loadDrivers();
21+
22+
$this->publishes([
23+
__DIR__.'/../../stubs/nexmo.php' => config_path('botman/nexmo.php'),
24+
]);
25+
26+
$this->mergeConfigFrom(__DIR__.'/../../stubs/nexmo.php', 'botman.nexmo');
27+
}
28+
}
29+
30+
/**
31+
* Load BotMan drivers.
32+
*/
33+
protected function loadDrivers()
34+
{
35+
DriverManager::loadDriver(NexmoDriver::class);
36+
}
37+
38+
/**
39+
* @return bool
40+
*/
41+
protected function isRunningInBotManStudio()
42+
{
43+
return class_exists(StudioServiceProvider::class);
44+
}
45+
}

0 commit comments

Comments
 (0)