Skip to content

Commit

Permalink
Updating the base RouteServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Jan 17, 2016
1 parent 09e7b15 commit 8e2f81b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
9 changes: 9 additions & 0 deletions src/Exceptions/RouteNamespaceUndefinedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php namespace Arcanedev\Support\Exceptions;

/**
* Class RouteNamespaceUndefinedException
*
* @package Arcanedev\Support\Exceptions
* @author ARCANEDEV <[email protected]>
*/
class RouteNamespaceUndefinedException extends \Exception {}
42 changes: 15 additions & 27 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Arcanedev\Support\Providers;

use Exception;
use Arcanedev\Support\Exceptions\RouteNamespaceUndefinedException;
use Illuminate\Contracts\Routing\Registrar as Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use RecursiveDirectoryIterator;
Expand Down Expand Up @@ -46,13 +46,6 @@ abstract class RouteServiceProvider extends ServiceProvider
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Get the routes namespace.
*
* @return string
*/
abstract protected function getRouteNamespace();

/**
* Set the Router.
*
Expand All @@ -67,6 +60,20 @@ private function setRouter($router)
return $this;
}

/**
* Get the routes namespace.
*
* @return string
*
* @throws \Arcanedev\Support\Exceptions\RouteNamespaceUndefinedException
*/
protected function getRouteNamespace()
{
throw new RouteNamespaceUndefinedException(
'The routes namespace is undefined.'
);
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
Expand All @@ -87,7 +94,6 @@ abstract public function map(Router $router);
*/
protected function mapRoutes(Router $router, $directory, array $attributes = [])
{
$this->checkRouteNamespace();
$this->setRouter($router);
$this->registerRoutes($directory);

Expand Down Expand Up @@ -116,24 +122,6 @@ protected function registerRoutes($directory)
}
}

/* ------------------------------------------------------------------------------------------------
| Check Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Check the route namespace.
*
* @throws Exception
*/
private function checkRouteNamespace()
{
$namespace = $this->getRouteNamespace();

if (empty($namespace)) {
throw new Exception('The routes namespace is empty.');
}
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 8e2f81b

Please sign in to comment.