1 | <?php namespace Arcanedev\LaravelTracker; |
||
11 | class LaravelTrackerServiceProvider extends PackageServiceProvider |
||
12 | { |
||
13 | /* ------------------------------------------------------------------------------------------------ |
||
14 | | Properties |
||
15 | | ------------------------------------------------------------------------------------------------ |
||
16 | */ |
||
17 | /** |
||
18 | * Package name. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $package = 'laravel-tracker'; |
||
23 | |||
24 | /* ------------------------------------------------------------------------------------------------ |
||
25 | | Getters & Setters |
||
26 | | ------------------------------------------------------------------------------------------------ |
||
27 | */ |
||
28 | /** |
||
29 | * Get the base path of the package. |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | 48 | public function getBasePath() |
|
37 | |||
38 | /* ------------------------------------------------------------------------------------------------ |
||
39 | | Main Functions |
||
40 | | ------------------------------------------------------------------------------------------------ |
||
41 | */ |
||
42 | /** |
||
43 | * Register the service provider. |
||
44 | */ |
||
45 | 48 | public function register() |
|
58 | |||
59 | /** |
||
60 | * Boot the service provider. |
||
61 | */ |
||
62 | 48 | public function boot() |
|
69 | |||
70 | /** |
||
71 | * Get the services provided by the provider. |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | 6 | public function provides() |
|
82 | |||
83 | /* ------------------------------------------------------------------------------------------------ |
||
84 | | Other Functions |
||
85 | | ------------------------------------------------------------------------------------------------ |
||
86 | */ |
||
87 | /** |
||
88 | * Register the detectors. |
||
89 | */ |
||
90 | 48 | private function registerDetectors() |
|
91 | { |
||
92 | $this->singleton(Contracts\Detectors\CrawlerDetector::class, function ($app) { |
||
93 | $crawler = new \Jaybizzle\CrawlerDetect\CrawlerDetect( |
||
94 | $app['request']->headers->all(), |
||
95 | $app['request']->server('HTTP_USER_AGENT') |
||
96 | ); |
||
97 | |||
98 | return new Detectors\CrawlerDetector($crawler); |
||
99 | 48 | }); |
|
100 | |||
101 | $this->singleton(Contracts\Detectors\DeviceDetector::class, function ($app) { |
||
102 | 6 | return new Detectors\DeviceDetector($app['agent']); |
|
103 | 48 | }); |
|
104 | |||
105 | 48 | $this->singleton( |
|
106 | 48 | Contracts\Detectors\GeoIpDetector::class, |
|
107 | 24 | Detectors\GeoIpDetector::class |
|
108 | 24 | ); |
|
109 | |||
110 | $this->singleton(Contracts\Detectors\LanguageDetector::class, function ($app) { |
||
111 | return new Detectors\LanguageDetector($app['agent']); |
||
112 | 48 | }); |
|
113 | |||
114 | $this->singleton(Contracts\Detectors\UserDetector::class, function ($app) { |
||
115 | return new Detectors\UserDetector($app); |
||
116 | 48 | }); |
|
117 | 48 | } |
|
118 | |||
119 | /** |
||
120 | * Register the parsers. |
||
121 | */ |
||
122 | 48 | private function registerParsers() |
|
123 | { |
||
124 | $this->singleton(Contracts\Parsers\RefererParser::class, function () { |
||
125 | return new Parsers\RefererParser( |
||
126 | new \Snowplow\RefererParser\Parser |
||
127 | ); |
||
128 | 48 | }); |
|
129 | |||
130 | 48 | $this->singleton(Contracts\Parsers\UserAgentParser::class, function ($app) { |
|
131 | 6 | return new Parsers\UserAgentParser( |
|
132 | 6 | \UAParser\Parser::create(), |
|
133 | 6 | $app->make('path.base') |
|
134 | 3 | ); |
|
135 | 48 | }); |
|
136 | 48 | } |
|
137 | |||
138 | /** |
||
139 | * Register the tracker. |
||
140 | */ |
||
141 | 48 | private function registerTracker() |
|
146 | } |
||
147 |