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

I18nPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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