-
Notifications
You must be signed in to change notification settings - Fork 1
/
GoogleAnalyticsServiceProvider.php
54 lines (46 loc) · 1.46 KB
/
GoogleAnalyticsServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Statamic\Addons\GoogleAnalytics;
use Statamic\Extend\ServiceProvider;
use Statamic\Extend\Meta;
class GoogleAnalyticsServiceProvider extends ServiceProvider
{
public $providers = [
\JRC9DS\Analytics\AnalyticsServiceProvider::class
];
public $aliases = [
'Analytics' => \JRC9DS\Analytics\AnalyticsFacade::class,
];
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot() {
//
}
/**
* Register the application services.
*
* @return void
*/
public function register() {
$this->app->bind('GoogleAnalytics.resolve-resource-path', function () {
/**
* @param string $path The filename relative to the `resources/assets` directory.
* eg. `js/foo.js`
* @param Addon $addon An instance of Statamic\Extend\Addon for your addon.
* @return string The filename relative to `resources/assets`
* eg. `js/foo.js?id=1234` or `js/foo.somehash.js`
*/
return function ($path, $addon) {
$meta = new Meta($addon);
$version = '';
if ($meta->exists()) {
$meta->load();
$version = $meta->get('version');
}
return $path . '?v=' . $version;
};
});
}
}