Skip to content

Commit

Permalink
Updating the service providers
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Feb 9, 2017
1 parent 9e6205c commit 5b179c3
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/Providers/AuthorizationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Arcanesoft\Tracker\Providers;

use Arcanedev\Support\ServiceProvider;
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;

/**
* Class AuthorizationServiceProvider
Expand Down
4 changes: 3 additions & 1 deletion src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ class CommandServiceProvider extends ServiceProvider
*
* @var array
*/
protected $commands = [];
protected $commands = [
//
];
}
104 changes: 28 additions & 76 deletions src/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?php namespace Arcanesoft\Tracker\Providers;

use Arcanedev\Support\ServiceProvider;
use Arcanesoft\Tracker\ViewComposers\Dashboard;
use Arcanedev\Support\Providers\ViewComposerServiceProvider as ServiceProvider;
use Arcanesoft\Tracker\ViewComposers\Dashboard\AuthenticatedVisitorsRatioComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\BrowsersRatioComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\CountriesListComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\DevicesRatioComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\LanguagesListComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\LatestThirtyDaysVisitsAndVisitorsComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\OperatingSystemRationComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\ReferersListComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\TotalPageViewsBoxComposer;
use Arcanesoft\Tracker\ViewComposers\Dashboard\TotalUniqueUsersBoxComposer;

/**
* Class ComposerServiceProvider
Expand All @@ -12,82 +21,25 @@
class ComposerServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* {@inheritdoc}
* Register the composer classes.
*
* @var array
*/
public function boot()
{
$this->registerDashboardComposers();
}

/**
* {@inheritdoc}
*/
public function register()
{
//
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Register all the dashboard view composers.
*/
private function registerDashboardComposers()
{
view()->composer(
Dashboard\TotalUniqueUsersBoxComposer::VIEW,
Dashboard\TotalUniqueUsersBoxComposer::class
);

view()->composer(
Dashboard\TotalPageViewsBoxComposer::VIEW,
Dashboard\TotalPageViewsBoxComposer::class
);

view()->composer(
Dashboard\LatestThirtyDaysVisitsAndVisitorsComposer::VIEW,
Dashboard\LatestThirtyDaysVisitsAndVisitorsComposer::class
);

view()->composer(
Dashboard\AuthenticatedVisitorsRatioComposer::VIEW,
Dashboard\AuthenticatedVisitorsRatioComposer::class
);

view()->composer(
Dashboard\DevicesRatioComposer::VIEW,
Dashboard\DevicesRatioComposer::class
);

view()->composer(
Dashboard\BrowsersRatioComposer::VIEW,
Dashboard\BrowsersRatioComposer::class
);

view()->composer(
Dashboard\OperatingSystemRationComposer::VIEW,
Dashboard\OperatingSystemRationComposer::class
);

view()->composer(
Dashboard\LanguagesListComposer::VIEW,
Dashboard\LanguagesListComposer::class
);

view()->composer(
Dashboard\CountriesListComposer::VIEW,
Dashboard\CountriesListComposer::class
);

view()->composer(
Dashboard\ReferersListComposer::VIEW,
Dashboard\ReferersListComposer::class
);
}
protected $composerClasses = [
// Dashboard view composers
TotalUniqueUsersBoxComposer::VIEW => TotalUniqueUsersBoxComposer::class,
TotalPageViewsBoxComposer::VIEW => TotalPageViewsBoxComposer::class,
LatestThirtyDaysVisitsAndVisitorsComposer::VIEW => LatestThirtyDaysVisitsAndVisitorsComposer::class,
AuthenticatedVisitorsRatioComposer::VIEW => AuthenticatedVisitorsRatioComposer::class,
DevicesRatioComposer::VIEW => DevicesRatioComposer::class,
BrowsersRatioComposer::VIEW => BrowsersRatioComposer::class,
OperatingSystemRationComposer::VIEW => OperatingSystemRationComposer::class,
LanguagesListComposer::VIEW => LanguagesListComposer::class,
CountriesListComposer::VIEW => CountriesListComposer::class,
ReferersListComposer::VIEW => ReferersListComposer::class,
];
}
21 changes: 14 additions & 7 deletions src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Arcanedev\LaravelTracker\LaravelTrackerServiceProvider;
use Arcanedev\Support\ServiceProvider;
use Illuminate\Support\Arr;

/**
* Class PackagesServiceProvider
Expand All @@ -20,6 +21,8 @@ class PackagesServiceProvider extends ServiceProvider
*/
public function register()
{
parent::register();

$this->registerLaravelTrackerPackage();
}

Expand All @@ -29,6 +32,8 @@ public function register()
public function boot()
{
parent::boot();

//
}

/**
Expand All @@ -38,7 +43,9 @@ public function boot()
*/
public function provides()
{
return parent::provides();
return [
//
];
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -52,12 +59,12 @@ private function registerLaravelTrackerPackage()
{
$this->registerProvider(LaravelTrackerServiceProvider::class);

/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $this->app['config'];
$config = $this->config();
$items = $config->get('arcanesoft.tracker');

$config->set('laravel-tracker.database', $config->get('arcanesoft.tracker.database'));
$config->set('laravel-tracker.models', $config->get('arcanesoft.tracker.models'));
$config->set('laravel-tracker.tracking', $config->get('arcanesoft.tracker.tracking'));
$config->set('laravel-tracker.routes', $config->get('arcanesoft.tracker.routes'));
$config->set('laravel-tracker.database', Arr::get($items, 'database'));
$config->set('laravel-tracker.models', Arr::get($items, 'models'));
$config->set('laravel-tracker.tracking', Arr::get($items, 'tracking'));
$config->set('laravel-tracker.routes', Arr::get($items, 'routes'));
}
}
15 changes: 5 additions & 10 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Arcanesoft\Core\Bases\RouteServiceProvider as ServiceProvider;
use Arcanesoft\Tracker\Http\Routes;
use Illuminate\Contracts\Routing\Registrar as Router;

/**
* Class RouteServiceProvider
Expand All @@ -18,12 +17,10 @@ class RouteServiceProvider extends ServiceProvider
*/
/**
* Define the routes for the application.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
public function map(Router $router)
public function map()
{
$this->mapAdminRoutes($router);
$this->mapAdminRoutes();
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -32,19 +29,17 @@ public function map(Router $router)
*/
/**
* Register the admin routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
private function mapAdminRoutes(Router $router)
private function mapAdminRoutes()
{
$attributes = $this->getAdminAttributes(
'tracker.',
'Arcanesoft\\Tracker\\Http\\Controllers\\Admin',
$this->config()->get('arcanesoft.tracker.route.prefix', 'tracker')
);

$router->group($attributes, function (Router $router) {
Routes\Admin\TrackerRoutes::register($router);
$this->group($attributes, function () {
Routes\Admin\TrackerRoutes::register();
});
}
}
14 changes: 5 additions & 9 deletions src/TrackerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Arcanesoft\Tracker;

use Arcanesoft\Core\Bases\PackageServiceProvider;
use Arcanesoft\Core\CoreServiceProvider;

/**
* Class TrackerServiceProvider
Expand Down Expand Up @@ -41,14 +40,15 @@ public function getBasePath()
| ------------------------------------------------------------------------------------------------
*/
/**
*
* Register the service provider.
*/
public function register()
{
parent::register();

$this->registerConfig();
$this->registerSidebarItems();
$this->registerProviders([
CoreServiceProvider::class,
Providers\PackagesServiceProvider::class,
Providers\AuthorizationServiceProvider::class,
Providers\ComposerServiceProvider::class,
Expand All @@ -57,11 +57,12 @@ public function register()
}

/**
*
* Boot the service provider.
*/
public function boot()
{
parent::boot();

$this->registerProvider(Providers\RouteServiceProvider::class);

// Publishes
Expand All @@ -82,9 +83,4 @@ public function provides()
//
];
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class TotalUniqueUsersBoxComposer extends AbstractViewComposer
| Constants
| ------------------------------------------------------------------------------------------------
*/

const VIEW = 'tracker::admin._composers.dashboard.total-unique-visitors-box';

/* ------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 5b179c3

Please sign in to comment.