我有一个捆绑包,它在私人Satis仓库中保存,因为其实体和存储库在多个应用程序之间共享。
消费该捆绑包的其他应用程序是Symfony 2.7和2.8应用程序。我正在开发一个新应用程序,并要求使用Symfony 3.3。
在Symfony 3.3应用程序中,我已经在我的services.yml中尝试了这个方法:
以上内容引发了以下异常:
无法自动装配服务“UvmsApiV1Bundle\Service\DealerService”:方法“__construct()”的参数“$repository”引用类“CbmLtd\UvmsBundle\Repository\DealerRepository”,但不存在这样的服务。它不能被自动注册,因为它来自不同的根命名空间。
好的,我猜我需要显式地将此存储库声明为服务。在Symfony 3.3文档中找不到有关将存储库声明为服务的任何信息,而2.8语法也不起作用。
我将以下内容添加到我的services.yml文件中:
但是我仍然会收到这个异常:
无法自动装配服务“UvmsApiV1Bundle\Service\DealerService”:方法“__construct()”的参数“$repository”引用类“CbmLtd\UvmsBundle\Repository\DealerRepository”,但不存在这样的服务。它不能被自动注册,因为它来自不同的根命名空间。
我不能对CbmLtd\UvmsBundle进行任何更改,因为它被多个应用程序使用。如果有帮助,将不胜感激。我已经花费了数小时在这上面,这非常令人沮丧。
消费该捆绑包的其他应用程序是Symfony 2.7和2.8应用程序。我正在开发一个新应用程序,并要求使用Symfony 3.3。
在Symfony 3.3应用程序中,我已经在我的services.yml中尝试了这个方法:
# Learn more about services, parameters and containers at
# http://symfony.com/doc/current/service_container.html
parameters:
#parameter_name: value
services:
# default configuration for services in *this* file
_defaults:
autowire: true
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
CbmLtd\UvmsBundle\:
resource: '../../vendor/cbmltd/uvms-bundle/*'
exclude: '../../vendor/cbmltd/uvms-bundle/{Entity,Repository}'
UvmsApiV1Bundle\:
resource: '../../src/UvmsApiV1Bundle/*'
exclude: '../../src/UvmsApiV1Bundle/{Entity,Repository}'
以上内容引发了以下异常:
无法自动装配服务“UvmsApiV1Bundle\Service\DealerService”:方法“__construct()”的参数“$repository”引用类“CbmLtd\UvmsBundle\Repository\DealerRepository”,但不存在这样的服务。它不能被自动注册,因为它来自不同的根命名空间。
好的,我猜我需要显式地将此存储库声明为服务。在Symfony 3.3文档中找不到有关将存储库声明为服务的任何信息,而2.8语法也不起作用。
我将以下内容添加到我的services.yml文件中:
services:
...
CbmLtd\UvmsBundle\DealerRepository:
class: CbmLtd\UvmsBundle\Entity\DealerRepository
factory_service: doctrine.orm.entity_manager
factory_method: getRepository
arguments:
- CbmLtd\UvmsBundle\Entity\Dealer
但是我仍然会收到这个异常:
无法自动装配服务“UvmsApiV1Bundle\Service\DealerService”:方法“__construct()”的参数“$repository”引用类“CbmLtd\UvmsBundle\Repository\DealerRepository”,但不存在这样的服务。它不能被自动注册,因为它来自不同的根命名空间。
我不能对CbmLtd\UvmsBundle进行任何更改,因为它被多个应用程序使用。如果有帮助,将不胜感激。我已经花费了数小时在这上面,这非常令人沮丧。