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 cb89896 commit e1e4f0e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 @@ -37,5 +39,12 @@
"scripts": {
"test": "vendor/bin/phpunit",
"cs": "php-cs-fixer fix"
},
"extra": {
"laravel": {
"providers": [
"BotMan\\Drivers\\BotFramework\\Providers\\BotFrameworkServiceProvider"
]
}
}
}
47 changes: 47 additions & 0 deletions src/Providers/BotFrameworkServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace BotMan\Drivers\BotFramework\Providers;

use Illuminate\Support\ServiceProvider;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Studio\Providers\StudioServiceProvider;
use BotMan\Drivers\BotFramework\BotFrameworkDriver;
use BotMan\Drivers\BotFramework\BotFrameworkImageDriver;

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

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

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

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

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

0 comments on commit e1e4f0e

Please sign in to comment.