donglun1918 2017-08-04 10:05
浏览 51

Symfony 2:服务依赖性失败

Since yesterday, I can't understand why i have this error on my Symfony website. I have a service which depends on others. When i try to use and inject the Symfony doctrine entity manager i have errors. I can't find a way to do it :(

My config :

mycompany_jobs_bundle.processor.crm.product_matrix:
    class: %mycompany_jobs_bundle.processor.crm.product_matrix.class%
    parent: pim_base_connector.processor.product_to_flat_array
    arguments:
      - '@pim_catalog.repository.attribute'
      - '@pim_catalog.localization.factory.date'
      - '@doctrine.orm.default_entity_manager'

(I also tried 'doctrine.orm.entity_manager' instead of '@doctrine.orm.default_entity_manager' -> same results)

Then, in my service :

  • I add a "use Doctrine\ORM\EntityManager;" with the other "use" lines.
  • And this is my constructor :

enter image description here

... but i have this error :

Catchable Fatal Error: Argument 8 passed to Mycompany\Bundle\JobsBundle\Processor\Mycompany\ProductWordMatrixProcessor::__construct() must implement interface Pim\Component\Catalog\Repository\AttributeRepositoryInterface, instance of Doctrine\ORM\EntityManager given

Wherever i move my line "EntityManager $em" i have error with arguments position. What's wrong ? I can't understand ..

Thanks for your help

Edit : below the yml config of the parent service, pim_base_connector.processor.product_to_flat_array :

pim_base_connector.processor.product_to_flat_array:
   class: %pim_base_connector.processor.product_to_flat_array.class%
   arguments:
       - '@pim_serializer'
       - '@pim_catalog.manager.channel'
       - '@pim_catalog.builder.product'
       - ['pim_catalog_file', 'pim_catalog_image']
       - %pim_catalog.localization.decimal_separators%
       - %pim_catalog.localization.date_formats%
       - '@akeneo_storage_utils.doctrine.object_detacher'
  • 写回答

2条回答 默认 最新

  • dongmacuo1193 2017-08-04 10:14
    关注

    Try to move the EntityManaer as the last parameter of your constructor arguments like this:

    public function __construct()
    {
       //.. others
       AttributeRepositoryInterface $attributeRepository,
       EntityManager $em
    }
    

    You need to maintain the order of your dependencies declared inside the configuration

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?