Completed
Push — fetcher_factories ( 10a56f...fd93ea )
by David
13:44
created

SplashMiddleware::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace Mouf\Mvc\Splash;
4
5
use Mouf\Mvc\Splash\Routers\RouterInterface;
6
use Mouf\Mvc\Splash\Controllers\Controller;
7
use Zend\Stratigility\MiddlewarePipe;
8
9
/**
10
 * The SplashMiddleware class is the root of the Splash framework.<br/>
11
 * It is in charge of binding an Url to a Controller.<br/>
12
 * There is one and only one instance of Splash per web application.<br/>
13
 * The name of the instance MUST be "splashMiddleware".<br/>
14
 * <br/>
15
 * The SplashMiddleware component has several ways to bind an URL to a Controller.<br/>
16
 * It can do so based on the @URL annotation, or based on the @Action annotation.<br/>
17
 * Check out the Splash documentation here:
18
 * <a href="https://github.com/thecodingmachine/mvc.splash/">https://github.com/thecodingmachine/mvc.splash/</a>.
19
 */
20
class SplashMiddleware extends MiddlewarePipe
21
{
22
    /**
23
     * @param RouterInterface[] $routers
24
     */
25
    public function __construct(array $routers)
26
    {
27
        parent::__construct();
28
        foreach ($routers as $router) {
29
            if ($router->isActive()) {
30
                $this->pipe($router->getPath(), $router->getMiddleware());
31
            }
32
        }
33
    }
34
}
35