Skip to content

Commit b197acd

Browse files
Remove deprecated l4 and l5 references
1 parent fea636a commit b197acd

File tree

8 files changed

+41
-149
lines changed

8 files changed

+41
-149
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
},
2222
"require-dev": {
2323
"friendsofphp/php-cs-fixer": "^2.16",
24-
"illuminate/console": "~4||~5",
25-
"illuminate/support": "~4||~5",
26-
"phpunit/phpunit": "~8.0"
24+
"illuminate/console": "~6||~7",
25+
"illuminate/support": "~6||~7",
26+
"phpunit/phpunit": "^8.0"
2727
},
2828
"autoload": {
2929
"psr-4": {

src/Commands/TwilioCallCommand.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,22 @@ public function __construct(TwilioInterface $twilio)
4343
/**
4444
* Execute the console command.
4545
*/
46-
public function fire()
46+
public function handle()
4747
{
4848
$this->line('Creating a call via Twilio to: '.$this->argument('phone'));
4949

5050
// Grab options
5151
$from = $this->option('from');
5252
$url = $this->option('url');
5353

54-
// Set a default URL if we havent specified one since is mandatory.
54+
// Set a default URL if we haven't specified one since is mandatory.
5555
if (is_null($url)) {
5656
$url = 'http://demo.twilio.com/docs/voice.xml';
5757
}
5858

5959
$this->twilio->call($this->argument('phone'), $url, [], $from);
6060
}
6161

62-
/**
63-
* Proxy method for Laravel 5.1+.
64-
*/
65-
public function handle()
66-
{
67-
return $this->fire();
68-
}
69-
7062
/**
7163
* Get the console command arguments.
7264
*

src/Commands/TwilioSmsCommand.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ public function fire()
5959
$this->twilio->message($this->argument('phone'), $text);
6060
}
6161

62-
/**
63-
* Proxy method for Laravel 5.1+.
64-
*/
65-
public function handle()
66-
{
67-
return $this->fire();
68-
}
69-
7062
/**
7163
* Get the console command arguments.
7264
*

src/Support/Laravel/L4ServiceProvider.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Support/Laravel/L5ServiceProvider.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Support/Laravel/ServiceProvider.php

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,56 @@
22

33
namespace Aloha\Twilio\Support\Laravel;
44

5+
use Aloha\Twilio\Commands\TwilioCallCommand;
6+
use Aloha\Twilio\Commands\TwilioSmsCommand;
7+
use Aloha\Twilio\Manager;
8+
use Aloha\Twilio\TwilioInterface;
59
use Illuminate\Foundation\Application;
6-
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
10+
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
711

8-
class ServiceProvider extends LaravelServiceProvider
12+
class ServiceProvider extends BaseServiceProvider
913
{
10-
/**
11-
* @var \Illuminate\Support\ServiceProvider
12-
*/
13-
protected $provider;
14-
15-
/**
16-
* Boot method.
17-
*/
18-
public function boot()
19-
{
20-
return $this->provider()->boot();
21-
}
22-
2314
/**
2415
* Register the service provider.
2516
*/
2617
public function register()
2718
{
28-
return $this->provider()->register();
19+
// Register manager for usage with the Facade.
20+
$this->app->singleton('twilio', function() {
21+
$config = $this->app['config']->get('twilio.twilio');
22+
23+
return new Manager($config['default'], $config['connections']);
24+
});
25+
26+
// Define an alias.
27+
$this->app->alias('twilio', Manager::class);
28+
29+
// Register Twilio Test SMS Command.
30+
$this->app->singleton('twilio.sms', TwilioSmsCommand::class);
31+
32+
// Register Twilio Test Call Command.
33+
$this->app->singleton('twilio.call', TwilioCallCommand::class);
34+
35+
// Register TwilioInterface concretion.
36+
$this->app->singleton(TwilioInterface::class, function() {
37+
return $this->app->make('twilio')->defaultConnection();
38+
});
2939
}
3040

3141
/**
32-
* @return \Illuminate\Support\ServiceProvider
42+
* Boot method.
3343
*/
34-
protected function provider()
44+
public function boot()
3545
{
36-
if ($this->provider) {
37-
return $this->provider;
38-
}
46+
$this->publishes([
47+
__DIR__.'/../../config/config.php' => config_path('twilio.php'),
48+
], 'config');
3949

40-
if (version_compare(Application::VERSION, '5.0', '<')) {
41-
$this->provider = new L4ServiceProvider($this->app);
42-
} else {
43-
$this->provider = new L5ServiceProvider($this->app);
44-
}
50+
$this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'twilio');
4551

46-
return $this->provider;
52+
$this->commands([
53+
TwilioCallCommand::class,
54+
TwilioSmsCommand::class,
55+
]);
4756
}
4857
}

src/Support/Laravel/ServiceProviderTrait.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/config/config.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
return [
44
'twilio' => [
55
'default' => 'twilio',
6-
76
'connections' => [
87
'twilio' => [
98
/*
@@ -14,7 +13,6 @@
1413
| Your Twilio Account SID #
1514
|
1615
*/
17-
1816
'sid' => env('TWILIO_SID', ''),
1917

2018
/*
@@ -25,7 +23,6 @@
2523
| Access token that can be found in your Twilio dashboard
2624
|
2725
*/
28-
2926
'token' => env('TWILIO_TOKEN', ''),
3027

3128
/*
@@ -36,7 +33,6 @@
3633
| The Phone number registered with Twilio that your SMS & Calls will come from
3734
|
3835
*/
39-
4036
'from' => env('TWILIO_FROM', ''),
4137
],
4238
],

0 commit comments

Comments
 (0)