1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Google Adsense Ads for Laravel. |
5
|
|
|
* |
6
|
|
|
* Package for easily including Google Adsense Ad units |
7
|
|
|
* in Laravel and Lumen. |
8
|
|
|
* |
9
|
|
|
* @developer Crypto Technology srl <https://cryptotech.srl/> |
10
|
|
|
* |
11
|
|
|
* @copyright Copyright (c) 2019 Crypto Technology srl |
12
|
|
|
* @license MIT |
13
|
|
|
* |
14
|
|
|
* Copyright (c) 2016 Galen Han |
15
|
|
|
* Copyright (c) 2019 Crypto Technology srl |
16
|
|
|
* |
17
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
18
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
19
|
|
|
* the Software without restriction, including without limitation the rights to |
20
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
21
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so, |
22
|
|
|
* subject to the following conditions: |
23
|
|
|
* |
24
|
|
|
* The above copyright notice and this permission notice shall be included in all |
25
|
|
|
* copies or substantial portions of the Software. |
26
|
|
|
* |
27
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
28
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
29
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
30
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
31
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
32
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
33
|
|
|
*/ |
34
|
|
|
|
35
|
|
|
declare(strict_types=1); |
36
|
|
|
|
37
|
|
|
namespace CryptoTech\Laravel\Adsense\Providers; |
38
|
|
|
|
39
|
|
|
use CryptoTech\Laravel\Adsense\AdsenseBuilder; |
40
|
|
|
use Illuminate\Support\ServiceProvider; |
41
|
|
|
use Laravel\Lumen\Application as LumenApplication; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Class AdsenseServiceProvider. |
45
|
|
|
* |
46
|
|
|
* @see \Illuminate\Support\ServiceProvider |
47
|
|
|
*/ |
48
|
|
|
class AdsenseServiceProvider extends ServiceProvider |
49
|
|
|
{ |
50
|
|
|
/** |
51
|
|
|
* Bootstrap any application services. |
52
|
|
|
*/ |
53
|
1 |
|
public function boot(): void |
54
|
|
|
{ |
55
|
1 |
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'adsense'); |
56
|
|
|
|
57
|
1 |
|
if ($this->app instanceof LumenApplication) { |
58
|
|
|
/* @scrutinizer ignore-call */ $this->app->configure('adsense'); |
59
|
|
|
} else { |
60
|
|
|
// Publishing the configuration file. |
61
|
1 |
|
$this->publishes([ |
62
|
1 |
|
$this->getConfigFile() => config_path('adsense-ads.php'), |
63
|
1 |
|
], 'config'); |
64
|
|
|
// Publishing the views. |
65
|
1 |
|
$this->publishes([ |
66
|
1 |
|
__DIR__.'/../resources/views' => resource_path('views/vendor/adsense'), |
67
|
1 |
|
], 'adsense.views'); |
68
|
|
|
} |
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
1 |
|
public function register(): void |
75
|
|
|
{ |
76
|
1 |
|
$this->mergeConfigFrom( |
77
|
1 |
|
$this->getConfigFile(), |
78
|
1 |
|
'adsense' |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
$this->app->bind(AdsenseBuilder::class, function () { |
82
|
|
|
return new AdsenseBuilder(); |
83
|
1 |
|
}); |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function provides(): array |
90
|
|
|
{ |
91
|
|
|
return [ |
92
|
|
|
'adsense', |
93
|
|
|
]; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Return the path of configuration file. |
98
|
|
|
*/ |
99
|
1 |
|
protected function getConfigFile(): string |
100
|
|
|
{ |
101
|
1 |
|
return __DIR__.'/../resources/config/adsense-ads.php'; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|