Symfony2:kernel.request,onKernelRequest没有加载

时间:2014-04-07 07:37:25

标签: php symfony

我主要在每个包中使用kernel.request,一切都在查找,但不在一个。

services.yml如下所示:

services:
    crm.addressbook.country_manager:
        class: CRM\AddressBookBundle\Country\CountryManager
        arguments: [ @doctrine.orm.dynamic_entity_manager ]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

和CountryManager:

namespace CRM\AddressBookBundle\Country;

use Doctrine\ORM\EntityManager;
use Symfony\Component\Security\Core\SecurityContext;

class CountryManager {

    protected $em;
    protected static $country;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public function onKernelRequest()
    {
        $this->loadCountry();
    }

    private function loadCountry()
    {
        $country = $this->em->getRepository('CRMAddressBookBundle:CountryLang')->findAll();

        foreach($country as $row)
        {
            self::$country[$row->getCountry()->getId()] = $row->getName();
        }
    }

}

有谁知道什么是错的?我没有收到任何错误。它只是没有启动代码...

0 个答案:

没有答案