Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Routing\Middleware;
4
 
5
use Closure;
6
use Illuminate\Contracts\Routing\Registrar;
7
use Illuminate\Database\Eloquent\ModelNotFoundException;
8
 
9
class SubstituteBindings
10
{
11
    /**
12
     * The router instance.
13
     *
14
     * @var \Illuminate\Contracts\Routing\Registrar
15
     */
16
    protected $router;
17
 
18
    /**
19
     * Create a new bindings substitutor.
20
     *
21
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
22
     * @return void
23
     */
24
    public function __construct(Registrar $router)
25
    {
26
        $this->router = $router;
27
    }
28
 
29
    /**
30
     * Handle an incoming request.
31
     *
32
     * @param  \Illuminate\Http\Request  $request
33
     * @param  \Closure  $next
34
     * @return mixed
35
     */
36
    public function handle($request, Closure $next)
37
    {
38
        try {
39
            $this->router->substituteBindings($route = $request->route());
40
 
41
            $this->router->substituteImplicitBindings($route);
42
        } catch (ModelNotFoundException $exception) {
43
            if ($route->getMissing()) {
44
                return $route->getMissing()($request, $exception);
45
            }
46
 
47
            throw $exception;
48
        }
49
 
50
        return $next($request);
51
    }
52
}