Completed
Push — feature/middleware ( 8ea9d8...ecd47e )
by Derek Stephen
04:09
created

I18nPackage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 41
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addToContainer() 0 4 1
A getEntityPath() 0 4 1
A hasEntityPath() 0 4 1
A addRoutes() 0 9 1
1
<?php
2
3
namespace BoneMvc\Module\I18n;
4
5
use Bone\Mvc\Router\RouterConfigInterface;
6
use BoneMvc\Module\Dragon\Controller\DragonController;
7
use BoneMvc\Module\Dragon\Service\DragonService;
8
use Barnacle\RegistrationInterface;
9
use Doctrine\ORM\EntityManager;
10
use Barnacle\Container;
11
use League\Route\RouteGroup;
12
use League\Route\Router;
13
use League\Route\Strategy\JsonStrategy;
14
use Zend\Diactoros\ResponseFactory;
15
16
class I18nPackage implements RegistrationInterface, RouterConfigInterface
17
{
18
    /**
19
     * @param Container $c
20
     */
21
    public function addToContainer(Container $c)
22
    {
23
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function getEntityPath(): string
30
    {
31
        return '';
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function hasEntityPath(): bool
38
    {
39
        return false;
40
    }
41
42
    /**
43
     * @param Container $c
44
     * @param Router $router
45
     * @return Router
46
     */
47
    public function addRoutes(Container $c, Router $router): Router
48
    {
49
        $defaultLocale = $c->get('i18n')['default_locale'];
50
        $urlHelper = 'meh';
51
        $i18n= new InternationalisationMiddleware($urlHelper, $defaultLocale);
52
        $router->prependMiddleware($i18n);
53
54
        return $router;
55
    }
56
}
57