-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding transAny method to Router, fixing doc comments & other stuff
- Loading branch information
1 parent
c2a562d
commit cbeef75
Showing
6 changed files
with
187 additions
and
42 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
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php namespace Arcanedev\Localization\Tests\Stubs\Http; | ||
|
||
use Arcanedev\Localization\Routing\Router; | ||
|
||
/** | ||
* Class RouteRegistrar | ||
* | ||
* @package Arcanedev\Localization\Tests\Stubs\Http | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
class RouteRegistrar | ||
{ | ||
/** | ||
* @var Router | ||
*/ | ||
protected $router; | ||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
| Getters & Setters | ||
| ------------------------------------------------------------------------------------------------ | ||
*/ | ||
/** | ||
* Set the router. | ||
* | ||
* @param Router $router | ||
* | ||
* @return self | ||
*/ | ||
private function setRouter(Router $router) | ||
{ | ||
$this->router = $router; | ||
|
||
return $this; | ||
} | ||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
| Main Functions | ||
| ------------------------------------------------------------------------------------------------ | ||
*/ | ||
/** | ||
* Map the routes. | ||
* | ||
* @param Router $router | ||
*/ | ||
public function map(Router $router) | ||
{ | ||
$this->setRouter($router); | ||
|
||
$this->router->localizedGroup(function () { | ||
$this->router->get('/', [ | ||
'as' => 'index', | ||
function () { | ||
return app('translator')->get('localization::routes.hello'); | ||
} | ||
]); | ||
|
||
$this->router->get('test', [ | ||
'as' => 'test', | ||
function () { | ||
return app('translator')->get('localization::routes.test-text'); | ||
} | ||
]); | ||
|
||
$this->router->transGet('localization::routes.about', [ | ||
'as' => 'about', | ||
function () { | ||
return localization()->getLocalizedURL('es') ?: 'Not url available'; | ||
} | ||
]); | ||
|
||
$this->router->transGet('localization::routes.view', [ | ||
'as' => 'view', | ||
function () { | ||
return localization()->getLocalizedURL('es') ?: 'Not url available'; | ||
} | ||
]); | ||
|
||
$this->router->transGet('localization::routes.view-project', [ | ||
'as' => 'view-project', | ||
function () { | ||
return localization()->getLocalizedURL('es') ?: 'Not url available'; | ||
} | ||
]); | ||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
| Other method | ||
| ------------------------------------------------------------------------------------------------ | ||
*/ | ||
$this->router->transPost('localization::routes.methods.post', [ | ||
'as' => 'method.post', | ||
function () { | ||
return 'POST method'; | ||
} | ||
]); | ||
|
||
$this->router->transPut('localization::routes.methods.put', [ | ||
'as' => 'method.put', | ||
function () { | ||
return 'PUT method'; | ||
} | ||
]); | ||
|
||
$this->router->transPatch('localization::routes.methods.patch', [ | ||
'as' => 'method.patch', | ||
function () { | ||
return 'PATCH method'; | ||
} | ||
]); | ||
|
||
$this->router->transOptions('localization::routes.methods.options', [ | ||
'as' => 'method.options', | ||
function () { | ||
return 'OPTIONS method'; | ||
} | ||
]); | ||
|
||
$this->router->transDelete('localization::routes.methods.delete', [ | ||
'as' => 'method.delete', | ||
function () { | ||
return 'DELETE method'; | ||
} | ||
]); | ||
|
||
$this->router->transAny('localization::routes.methods.any', [ | ||
'as' => 'method.any', | ||
function () { | ||
return 'Any method'; | ||
} | ||
]); | ||
}); | ||
} | ||
} |
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
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
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
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