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 6afbe33 commit 49fc1cf
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 96 deletions.
6 changes: 3 additions & 3 deletions src/FoundationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Arcanesoft\Foundation;

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

/**
* Class FoundationServiceProvider
Expand Down Expand Up @@ -45,10 +44,11 @@ public function getBasePath()
*/
public function register()
{
parent::register();

$this->registerConfig();
$this->registerSidebarItems();
$this->registerProviders([
CoreServiceProvider::class,
Providers\PackagesServiceProvider::class,
Providers\AuthorizationServiceProvider::class,
]);
Expand All @@ -64,7 +64,7 @@ public function boot()
{
$this->registerProviders([
Providers\RouteServiceProvider::class,
Providers\ComposerServiceProvider::class,
Providers\ViewComposerServiceProvider::class,
]);

// Publishes
Expand Down
17 changes: 6 additions & 11 deletions src/Providers/AuthorizationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
use Arcanesoft\Contracts\Auth\Models\User;
use Arcanesoft\Foundation\Policies;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Support\Facades\Gate;

/**
* Class AuthorizationServiceProvider
Expand All @@ -19,30 +19,25 @@ class AuthorizationServiceProvider extends ServiceProvider
*/
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
*/
public function boot(GateContract $gate)
public function boot()
{
$this->registerPolicies($gate);
$this->registerPolicies();

/** @var \Illuminate\Auth\Access\Gate $gate */
$gate->before(function (User $user, $ability) {
Gate::before(function (User $user, $ability) {
return $user->isAdmin() ? true : null;
});

$this->registerLogViewerPolicies($gate);
$this->registerLogViewerPolicies();
}

/**
* Register LogViewer policies.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
*/
private function registerLogViewerPolicies(GateContract $gate)
private function registerLogViewerPolicies()
{
$this->defineMany(
$gate,
Policies\LogViewerPolicy::class,
Policies\LogViewerPolicy::getPolicies()
);
Expand Down
24 changes: 1 addition & 23 deletions src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Arcanesoft\Foundation\Providers;

use Arcanedev\Support\ServiceProvider;
use Arcanedev\Support\Providers\CommandServiceProvider as ServiceProvider;
use Arcanesoft\Foundation\Console;

/**
Expand All @@ -25,26 +25,4 @@ class CommandServiceProvider extends ServiceProvider
Console\SetupCommand::class,
Console\ClearCommand::class,
];

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the service provider.
*/
public function register()
{
$this->commands($this->commands);
}

/**
* Get the provided commands.
*
* @return array
*/
public function provides()
{
return $this->commands;
}
}
45 changes: 0 additions & 45 deletions src/Providers/ComposerServiceProvider.php

This file was deleted.

10 changes: 8 additions & 2 deletions src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Arcanedev\LogViewer\LogViewerServiceProvider;
use Arcanedev\RouteViewer\RouteViewerServiceProvider;
use Arcanedev\Support\ServiceProvider;
use Spatie\Backup\BackupServiceProvider;

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

$this->registerLogViewerPackage();
$this->registerRouteViewerPackage();
$this->registerBackupsPackage();
Expand All @@ -32,7 +35,7 @@ public function register()
*/
public function boot()
{
//
parent::boot();
}

/**
Expand Down Expand Up @@ -86,8 +89,11 @@ private function registerRouteViewerPackage()
$this->config()->set('route-viewer.route.enabled', false);
}

/**
* Register the Backup package.
*/
private function registerBackupsPackage()
{
$this->registerProvider(\Spatie\Backup\BackupServiceProvider::class);
$this->registerProvider(BackupServiceProvider::class);
}
}
19 changes: 7 additions & 12 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\Foundation\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,20 +29,18 @@ public function map(Router $router)
*/
/**
* Map the admin routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
private function mapAdminRoutes(Router $router)
private function mapAdminRoutes()
{
$attributes = $this->getAdminAttributes(
'foundation.',
'Arcanesoft\\Foundation\\Http\\Controllers\\Admin'
);

$router->group($attributes, function (Router $router) {
Routes\Admin\DashboardRoute::register($router);
Routes\Admin\SettingsRoutes::register($router);
Routes\Admin\SystemRoutes::register($router);
$this->group($attributes, function () {
Routes\Admin\DashboardRoute::register();
Routes\Admin\SettingsRoutes::register();
Routes\Admin\SystemRoutes::register();
});
}
}
30 changes: 30 additions & 0 deletions src/Providers/ViewComposerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php namespace Arcanesoft\Foundation\Providers;

use Arcanedev\Support\Providers\ViewComposerServiceProvider as ServiceProvider;
use Arcanesoft\Foundation\ViewComposers\SidebarComposer;
use Arcanesoft\Foundation\ViewComposers\System\FoldersPermissionsComposer;
use Arcanesoft\Foundation\ViewComposers\System\ServerRequirementsComposer;

/**
* Class ViewComposerServiceProvider
*
* @package Arcanesoft\Foundation\Providers
* @author ARCANEDEV <[email protected]>
*/
class ViewComposerServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the composer classes.
*
* @var array
*/
protected $composerClasses = [
SidebarComposer::VIEW_NAME => SidebarComposer::class,
ServerRequirementsComposer::VIEW_NAME => ServerRequirementsComposer::class,
FoldersPermissionsComposer::VIEW_NAME => FoldersPermissionsComposer::class,
];
}

0 comments on commit 49fc1cf

Please sign in to comment.