|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Laravel AmoCrm. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) dotzero <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Dotzero\LaravelAmoCrm; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Support\ServiceProvider; |
|
15
|
|
|
use Illuminate\Contracts\Container\Container; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* This is the AmoCrm service provider class. |
|
19
|
|
|
* |
|
20
|
|
|
* @package Dotzero\LaravelAmoCrm |
|
21
|
|
|
* @author dotzero <[email protected]> |
|
22
|
|
|
* @link http://www.dotzero.ru/ |
|
23
|
|
|
* @link https://github.com/dotzero/laravel-amocrm |
|
24
|
|
|
*/ |
|
25
|
|
|
class AmoCrmServiceProvider extends ServiceProvider |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Indicates if loading of the provider is deferred. |
|
29
|
|
|
* |
|
30
|
|
|
* @var bool |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $defer = false; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Bootstrap the application events. |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
7 |
|
public function boot() |
|
40
|
|
|
{ |
|
41
|
7 |
|
$config = realpath(__DIR__ . '/../config/amocrm.php'); |
|
42
|
|
|
|
|
43
|
7 |
|
$this->publishes([ |
|
44
|
7 |
|
$config => config_path('amocrm.php'), |
|
45
|
7 |
|
], 'config'); |
|
46
|
|
|
|
|
47
|
7 |
|
$this->mergeConfigFrom($config, 'amocrm'); |
|
48
|
7 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Register the service provider. |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
7 |
|
public function register() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->app->singleton('amocrm', function (Container $app) { |
|
58
|
1 |
|
$config = $app['config']; |
|
59
|
7 |
|
return new AmoCrmManager($config); |
|
60
|
7 |
|
}); |
|
61
|
|
|
|
|
62
|
|
|
$this->app->singleton('amocrm.fields', function (Container $app) { |
|
63
|
|
|
$manager = $app['amocrm']; |
|
64
|
|
|
|
|
65
|
|
|
return $manager->getFields(); |
|
66
|
7 |
|
}); |
|
67
|
|
|
|
|
68
|
7 |
|
$this->app->singleton('amocrm.b2bfamily', function (Container $app) { |
|
69
|
|
|
$manager = $app['amocrm']; |
|
70
|
|
|
|
|
71
|
|
|
return $manager->getB2BFamily(); |
|
72
|
7 |
|
}); |
|
73
|
7 |
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get the services provided by the provider. |
|
77
|
|
|
* |
|
78
|
|
|
* @return array |
|
79
|
|
|
*/ |
|
80
|
2 |
|
public function provides() |
|
81
|
|
|
{ |
|
82
|
|
|
return [ |
|
83
|
2 |
|
'amocrm', |
|
84
|
2 |
|
'amocrm.fields', |
|
85
|
2 |
|
'amocrm.b2bfamily', |
|
86
|
2 |
|
]; |
|
87
|
|
|
} |
|
88
|
|
|
} |