Completed
Pull Request — develop (#53)
by Patrick
03:17
created

WebSite::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 9.6666
1
<?php
2
namespace Http;
3
4
use \Psr\Http\Message\ServerRequestInterface as Request;
5
use \Psr\Http\Message\ResponseInterface as Response;
6
7
require 'vendor/autoload.php';
8
9
class WebSite extends \Slim\App
10
{
11
    public function __construct()
12
    {
13
        $settings = array("settings"=>["determineRouteBeforeAppMiddleware"=>true]);
14
        parent::__construct($settings);
15
        $c = $this->getContainer();
16
        $c['errorHandler'] = function($c) { return new WebErrorHandler();};
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
        $this->add(new AuthMiddleware());
18
        $this->add(new ODataMiddleware());
19
    }
20
21
    public function registerPage($uri, $page)
22
    {
23
        $this->get($uri, array($page, 'handleRequest'));
24
    }
25
26
    public function registerAPI($uri, $api)
27
    {
28
        $group = $this->group($uri, function() use($api){$api->setup($this);});
29
        $group->add(new \Http\Rest\SerializationMiddleware());
30
        $group->add(new \Http\Rest\CORSMiddleware($this->getContainer()));
31
    }
32
}
33