Skip to content

Commit

Permalink
Merge pull request #90 from ARCANEDEV/revert-http_kernel_trait
Browse files Browse the repository at this point in the history
Revert the Kernel's Trait
  • Loading branch information
arcanedev-maroc authored Mar 22, 2017
2 parents bc0bfa9 + 7ab30f6 commit b3fff20
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
17 changes: 17 additions & 0 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ Once the package is installed, you can register the service provider in `config/

> No need to register the Localization facade, it's done automagically.
##### Now you need to update your Http Kernel to use the Localization Router.

```php
// app/Http/Kernel.php
<?php namespace App\Http;

//...

class Kernel extends HttpKernel
{
// Localization Trait
use \Arcanedev\Localization\Traits\LocalizationKernelTrait;

// Your middleware(s) here
}
```

### Artisan commands

To publish the config &amp; view files, run this command:
Expand Down
10 changes: 10 additions & 0 deletions _docs/2-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ return [
| localized-routes | Allows to register all translatable routes. |
| translation-redirect | Allows to translate the route attributes by using the translation event. |

## Ignored URI

```php
'ignored-uri' => [
//
],
```

You can set a list of uris to ignore from localization checks.

## Locales

```php
Expand Down
9 changes: 9 additions & 0 deletions config/localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
],
],

/* -----------------------------------------------------------------
| Ignored URI from localization
| -----------------------------------------------------------------
*/

'ignored-uri' => [
//
],

/* -----------------------------------------------------------------
| Locales
| -----------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/Middleware/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class Middleware extends BaseMiddleware
public function __construct(Localization $localization)
{
$this->localization = $localization;
$this->except = config('localization.ignored-uri', []);
}

/* -----------------------------------------------------------------
Expand Down
33 changes: 31 additions & 2 deletions src/Traits/LocalizationKernelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,38 @@
* @package Arcanedev\Localization\Traits
* @author ARCANEDEV <[email protected]>
*
* @deprecated since v1.0.3
* @property \Illuminate\Foundation\Application app
* @property \Arcanedev\Localization\Routing\Router router
* @property array middlewareGroups
* @property array routeMiddleware
*/
trait LocalizationKernelTrait
{
//
/**
* Get the route dispatcher callback.
*
* @return \Closure
*/
protected function dispatchToRouter()
{
$this->replaceRouter();

return parent::dispatchToRouter();
}

/**
* Replace the illuminate router with the localization router.
*/
protected function replaceRouter()
{
$this->router = $this->app->make('router');

foreach ($this->middlewareGroups as $key => $middleware) {
$this->router->middlewareGroup($key, $middleware);
}

foreach ($this->routeMiddleware as $key => $middleware) {
$this->router->aliasMiddleware($key, $middleware);
}
}
}

2 comments on commit b3fff20

@akhan-weltkind
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! after composer update i have message
[BadMethodCallException]
Method aliasMiddleware does not exist.

@akhan-weltkind
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should i do to fix it?

Please sign in to comment.