1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Linkeys\UrlSigner\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Event; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Linkeys\UrlSigner\Contracts\UrlSigner as UrlSignerContract; |
8
|
|
|
use Linkeys\UrlSigner\Contracts\Models\Group as GroupContract; |
9
|
|
|
use Linkeys\UrlSigner\Contracts\Models\Link as LinkContract; |
10
|
|
|
use Linkeys\UrlSigner\Events\LinkClicked; |
11
|
|
|
use Linkeys\UrlSigner\Middleware\AddLinkDataToRequest; |
12
|
|
|
use Linkeys\UrlSigner\Middleware\AddLinkToRequest; |
13
|
|
|
use Linkeys\UrlSigner\Middleware\CheckLinkUnchanged; |
14
|
|
|
use Linkeys\UrlSigner\Middleware\CheckLinkValid; |
15
|
|
|
use Linkeys\UrlSigner\Support\GroupRepository\EloquentGroupRepository; |
16
|
|
|
use Linkeys\UrlSigner\Support\GroupRepository\GroupRepository; |
17
|
|
|
use Linkeys\UrlSigner\Support\LinkRepository\EloquentLinkRepository; |
18
|
|
|
use Linkeys\UrlSigner\Support\LinkRepository\LinkRepository; |
19
|
|
|
use Linkeys\UrlSigner\UrlSigner; |
20
|
|
|
use Linkeys\UrlSigner\Listeners\RecordLinkClick; |
21
|
|
|
use Linkeys\UrlSigner\Models\Group; |
22
|
|
|
use Linkeys\UrlSigner\Models\Link; |
23
|
|
|
use Linkeys\UrlSigner\Support\ExpiryNormaliser\NormaliserManager; |
24
|
|
|
use Linkeys\UrlSigner\Support\ExpiryNormaliser\NormaliserManagerContract; |
25
|
|
|
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromDateTime; |
26
|
|
|
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromInteger; |
27
|
|
|
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromString; |
28
|
|
|
use Linkeys\UrlSigner\Support\UrlManipulator\SpatieUrlManipulator; |
29
|
|
|
use Linkeys\UrlSigner\Support\UrlManipulator\UrlManipulator; |
30
|
|
|
use Linkeys\UrlSigner\Support\Uuid\RamseyUuidCreator; |
31
|
|
|
use Linkeys\UrlSigner\Support\Uuid\UuidCreator; |
32
|
|
|
|
33
|
|
|
class UrlSignerServiceProvider extends ServiceProvider |
34
|
|
|
{ |
35
|
73 |
|
public function boot() |
36
|
|
|
{ |
37
|
|
|
|
38
|
73 |
|
$this->publishes([ |
39
|
73 |
|
__DIR__.'/../../config/links.php' => config_path('links.php') |
40
|
73 |
|
], 'config'); |
41
|
|
|
|
42
|
73 |
|
$this->publishes([ |
43
|
73 |
|
__DIR__.'/../../database/migrations/' => database_path('migrations') |
44
|
73 |
|
], 'migrations'); |
45
|
|
|
|
46
|
73 |
|
$this->mergeConfigFrom( |
47
|
73 |
|
__DIR__.'/../../config/links.php', 'links' |
48
|
|
|
); |
49
|
73 |
|
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
50
|
|
|
|
51
|
73 |
|
$this->app['router']->middlewareGroup('link', [ |
52
|
73 |
|
AddLinkToRequest::class, |
53
|
|
|
AddLinkDataToRequest::class, |
54
|
|
|
CheckLinkUnchanged::class, |
55
|
|
|
CheckLinkValid::class |
56
|
|
|
]); |
57
|
|
|
|
58
|
73 |
|
Event::listen(LinkClicked::class, RecordLinkClick::class); |
59
|
73 |
|
} |
60
|
|
|
|
61
|
73 |
|
public function register() |
62
|
|
|
{ |
63
|
73 |
|
$this->app->bind(UrlSignerContract::class, UrlSigner::class); |
64
|
73 |
|
$this->app->bind(LinkContract::class, Link::class); |
65
|
73 |
|
$this->app->bind(GroupContract::class, Group::class); |
66
|
73 |
|
$this->app->bind(UrlManipulator::class, SpatieUrlManipulator::class); |
67
|
73 |
|
$this->app->bind(UuidCreator::class, RamseyUuidCreator::class); |
68
|
73 |
|
$this->app->bind(LinkRepository::class, EloquentLinkRepository::class); |
69
|
73 |
|
$this->app->bind(GroupRepository::class, EloquentGroupRepository::class); |
70
|
|
|
|
71
|
|
|
|
72
|
73 |
|
$normaliserManager = new NormaliserManager(); |
73
|
73 |
|
$normaliserManager->pushNormaliser(new FromDateTime); |
74
|
73 |
|
$normaliserManager->pushNormaliser(new FromString); |
75
|
73 |
|
$normaliserManager->pushNormaliser(new FromInteger); |
76
|
73 |
|
$this->app->instance(NormaliserManagerContract::class, $normaliserManager); |
77
|
|
|
|
78
|
73 |
|
$this->mergeConfigFrom(__DIR__.'/../../config/links.php', config_path('links.php')); |
79
|
73 |
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|