1<?php
2
3/*
4 * This file is part of the Silex framework.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Silex\Provider;
13
14use Pimple\Container;
15use Pimple\ServiceProviderInterface;
16use Silex\Api\EventListenerProviderInterface;
17use Silex\Provider\Locale\LocaleListener;
18use Symfony\Component\EventDispatcher\EventDispatcherInterface;
19
20/**
21 * Locale Provider.
22 *
23 * @author Fabien Potencier <fabien@symfony.com>
24 */
25class LocaleServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
26{
27    public function register(Container $app)
28    {
29        $app['locale.listener'] = function ($app) {
30            return new LocaleListener($app, $app['locale'], $app['request_stack'], isset($app['request_context']) ? $app['request_context'] : null);
31        };
32
33        $app['locale'] = 'en';
34    }
35
36    public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
37    {
38        $dispatcher->addSubscriber($app['locale.listener']);
39    }
40}
41