【发布时间】:2013-11-23 10:36:44
【问题描述】:
好的,我不想做一些非常简单的事情,我只想从 app/config/config.yml 中获取这个值
框架: default_locale: nl
我想在 EventListener 中获取这个值。有人可以帮忙吗?
编辑1:(对吗)?但我不在这里使用 DependencyInjection 类..我很困惑..
服务: core_locale.locale_listener: 类: Eyee\CoreBundle\EventListener\LocaleListenerDefault 参数:["%kernel.default_locale%"]
<?php
namespace Eyee\CoreBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* use this class if no database Languages available..
*/
class LocaleListenerDefault implements EventSubscriberInterface
{
private $defaultLocale;
public function __construct($default_locale = 'en')
{
$this->defaultLocale = $default_locale;
}`enter code here`
【问题讨论】:
标签: symfony locale config event-listener