This repository has been archived by the owner on Feb 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rokde
committed
Nov 18, 2015
1 parent
1a3ccaa
commit 9c4f721
Showing
10 changed files
with
1,045 additions
and
915 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
<?php namespace Ipunkt\LaravelAnalytics; | ||
<?php | ||
|
||
namespace Ipunkt\LaravelAnalytics; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* Class AnalyticsFacade | ||
* | ||
* @package Ipunkt\LaravelAnalytics | ||
*/ | ||
class AnalyticsFacade extends Facade | ||
{ | ||
/** | ||
* facade accessor | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'analytics'; | ||
} | ||
/** | ||
* facade accessor | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'analytics'; | ||
} | ||
} |
156 changes: 79 additions & 77 deletions
156
src/Ipunkt/LaravelAnalytics/AnalyticsServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,86 @@ | ||
<?php namespace Ipunkt\LaravelAnalytics; | ||
<?php | ||
|
||
namespace Ipunkt\LaravelAnalytics; | ||
|
||
use Config; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class AnalyticsServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
/** | ||
* Bootstrap the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
if ($this->isLaravel4()) { | ||
$this->package('ipunkt/laravel-analytics'); | ||
|
||
return; | ||
} | ||
|
||
$config = realpath(__DIR__ . '/../../config/analytics.php'); | ||
|
||
$this->mergeConfigFrom($config, 'analytics'); | ||
|
||
$this->publishes([ | ||
$config => config_path('analytics.php'), | ||
]); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$packageNamespace = $this->isLaravel4() ? 'laravel-analytics::' : ''; | ||
|
||
$this->app->bind('analytics', function () use ($packageNamespace) { | ||
|
||
// get analytics provider name | ||
$provider = Config::get($packageNamespace . 'analytics.provider'); | ||
|
||
// make it a class | ||
$providerClass = 'Ipunkt\LaravelAnalytics\Providers\\' . $provider; | ||
|
||
// getting the config | ||
$providerConfig = []; | ||
if (Config::has($packageNamespace . 'analytics.configurations.' . $provider)) { | ||
$providerConfig = Config::get($packageNamespace . 'analytics.configurations.' . $provider); | ||
} | ||
|
||
// return an instance | ||
return new $providerClass($providerConfig); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return array(); | ||
} | ||
|
||
/** | ||
* are we on laravel 4 | ||
* | ||
* @return bool | ||
*/ | ||
private function isLaravel4() | ||
{ | ||
return version_compare(\Illuminate\Foundation\Application::VERSION, '5', '<'); | ||
} | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
/** | ||
* Bootstrap the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
if ($this->isLaravel4()) { | ||
$this->package('ipunkt/laravel-analytics'); | ||
|
||
return; | ||
} | ||
|
||
$config = realpath(__DIR__ . '/../../config/analytics.php'); | ||
|
||
$this->mergeConfigFrom($config, 'analytics'); | ||
|
||
$this->publishes([ | ||
$config => config_path('analytics.php'), | ||
]); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$packageNamespace = $this->isLaravel4() ? 'laravel-analytics::' : ''; | ||
|
||
$this->app->bind('analytics', function () use ($packageNamespace) { | ||
|
||
// get analytics provider name | ||
$provider = Config::get($packageNamespace . 'analytics.provider'); | ||
|
||
// make it a class | ||
$providerClass = 'Ipunkt\LaravelAnalytics\Providers\\' . $provider; | ||
|
||
// getting the config | ||
$providerConfig = []; | ||
if (Config::has($packageNamespace . 'analytics.configurations.' . $provider)) { | ||
$providerConfig = Config::get($packageNamespace . 'analytics.configurations.' . $provider); | ||
} | ||
|
||
// return an instance | ||
return new $providerClass($providerConfig); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* are we on laravel 4 | ||
* | ||
* @return bool | ||
*/ | ||
private function isLaravel4() | ||
{ | ||
return version_compare(\Illuminate\Foundation\Application::VERSION, '5', '<'); | ||
} | ||
} |
Oops, something went wrong.