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