-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathRegisterProvider.php
More file actions
41 lines (34 loc) · 1017 Bytes
/
RegisterProvider.php
File metadata and controls
41 lines (34 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* This file is part of fof/oauth.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FoF\OAuth\Extend;
use Flarum\Extend\ExtenderInterface;
use Flarum\Extension\Extension;
use FoF\OAuth\Provider;
use Illuminate\Contracts\Container\Container;
use InvalidArgumentException;
class RegisterProvider implements ExtenderInterface
{
private $provider;
public function __construct(string $provider)
{
$this->provider = $provider;
}
public function extend(Container $container, ?Extension $extension = null)
{
$provider = $container->make($this->provider);
if ($provider instanceof Provider) {
$container->tag([
$this->provider,
], 'fof-oauth.providers');
} else {
throw new InvalidArgumentException("{$this->provider} has to extend ".Provider::class);
}
}
}