0

我仍在尝试使用来自 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']

我的学说 config.yml 看起来像:

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

我没有启用自动映射,我想我在 services.yml 中的论点应该是错误的,但我没有设法让它正确。

你可以帮帮我吗?

4

1 回答 1

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

于 2013-08-07T12:12:07.630 回答