Skip to content

Commit

Permalink
Add Service Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Jan 21, 2018
1 parent adc2218 commit 94f1d3a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"botman/botman": "~2.0"
},
"require-dev": {
"botman/studio-addons": "~1.0",
"illuminate/contracts": "~5.5.0",
"phpunit/phpunit": "~5.0",
"mockery/mockery": "dev-master",
"ext-curl": "*"
Expand All @@ -36,5 +38,12 @@
"scripts": {
"test": "vendor/bin/phpunit",
"cs": "php-cs-fixer fix"
},
"extra": {
"laravel": {
"providers": [
"BotMan\\Drivers\\Nexmo\\Providers\\NexmoServiceProvider"
]
}
}
}
45 changes: 45 additions & 0 deletions src/Providers/NexmoServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace BotMan\Drivers\Nexmo\Providers;

use BotMan\Drivers\Nexmo\NexmoDriver;
use Illuminate\Support\ServiceProvider;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Studio\Providers\StudioServiceProvider;

class NexmoServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
if (! $this->isRunningInBotManStudio()) {
$this->loadDrivers();

$this->publishes([
__DIR__.'/../../stubs/nexmo.php' => config_path('botman/nexmo.php'),
]);

$this->mergeConfigFrom(__DIR__.'/../../stubs/nexmo.php', 'botman.nexmo');
}
}

/**
* Load BotMan drivers.
*/
protected function loadDrivers()
{
DriverManager::loadDriver(NexmoDriver::class);
}

/**
* @return bool
*/
protected function isRunningInBotManStudio()
{
return class_exists(StudioServiceProvider::class);
}
}

0 comments on commit 94f1d3a

Please sign in to comment.