Completed
Push — fix_travis_behat ( 3c7f1b...b1b900 )
by
unknown
54:25 queued 34:54
created

AuthenticatingDispatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A dispatch() 0 9 2
1
<?php
2
3
/**
4
 * File containing the authenticating dispatcher class.
5
 *
6
 * ATTENTION: This is a test setup for the REST server. DO NOT USE IT IN
7
 * PRODUCTION!
8
 *
9
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
10
 * @license For full copyright and license information view LICENSE file distributed with this source code.
11
 */
12
namespace eZ\Publish\Core\REST\Server;
13
14
use Qafoo\RMF;
15
use Exception;
16
17
/**
18
 * MVC dispatcher with integrated authentication.
19
 */
20
class AuthenticatingDispatcher extends RMF\Dispatcher\Simple
21
{
22
    /**
23
     * Authenticator.
24
     *
25
     * @var \eZ\Publish\Core\REST\Server\Authenticator
26
     */
27
    protected $authenticator;
28
29
    /**
30
     * Creates a new authenticating dispatcher.
31
     *
32
     * @param RMF\Router $router
33
     * @param RMF\View $view
34
     * @param \eZ\Publish\Core\REST\Server\Authenticator $authenticator
35
     */
36
    public function __construct(RMF\Router $router, RMF\View $view, Authenticator $authenticator)
37
    {
38
        parent::__construct($router, $view);
39
        $this->authenticator = $authenticator;
40
    }
41
42
    /**
43
     * Performs authentication and dispatches the request.
44
     *
45
     * @param RMF\Request $request
46
     */
47
    public function dispatch(RMF\Request $request)
48
    {
49
        try {
50
            $this->authenticator->authenticate($request);
51
        } catch (Exception $e) {
52
            $this->view->display($request, $e);
53
        }
54
        parent::dispatch($request);
55
    }
56
}
57