实体经理symfony 2

时间:2013-08-07 11:26:46

标签: symfony

我仍在尝试使用sylius的购物车套装,

我收到此错误

Catchable Fatal Error: Argument 1 passed to myproject\Cart\ItemResolver::__construct()         must be an instance of Doctrine\ORM\EntityManager, none given, called in     myproject\cache\dev\appDevDebugProjectContainer.php on line 3625 and defined in myproject\Cart\ItemResolver.php line 19
500 Internal Server Error - ContextErrorException

实际上我已经在调试堆栈跟踪中看到了这一点

at ItemResolver ->__construct ()

protected function getcompany_CartItemResolverService()
{
return $this->services['company_item_resolver'] = new \myproject\Cart\ItemResolver();
}

我想我的配置存在问题。

我的service.yml看起来像那样

company.cart_item_resolver:
class: myproject\Cart\ItemResolver
argument: ['@doctrine.orm.entity_manager']

和我的doctrine的config.yml看起来像:

orm:
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
  default:
      mappings:
          ApplicationSonataUserBundle: ~
          SonataUserBundle: ~
          FOSUserBundle: ~
          companyBundle: ~
          ApplicationSonataMediaBundle: ~
          SonataMediaBundle: ~
          SonataNotificationBundle: ~
          ApplicationSonataNotificationBundle: ~
          SyliusCartBundle: ~

我没有启用自动化,我想我在services.yml中的参数应该是假的,但我没有设法做到这一点。

你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

service.yml

中试用此代码
company.cart_item_resolver:
    class: myproject\Cart\ItemResolver
    arguments: ['@doctrine.orm.entity_manager']

它应该解决你的问题。有关注入服务的更多信息:http://symfony.com/doc/current/book/service_container.html#referencing-injecting-services