简体   繁体   English

更新 Doctrine 后,Symfony 中的“ObjectManager 和 EntityManagerInterface 之间的兼容性”是什么?

[英]what's the " compatibility between ObjectManager and EntityManagerInterface " in Symfony after update Doctrine?

I have an error after having tried an update ( composer update ) in my Symfony project.在我的 Symfony 项目中尝试更新( composer update )后出现错误。

I looked for a solution and I found it was necessary to modify the use and the type-hint in the entity and the constructor.. which I have done!我寻找了一个解决方案,我发现有必要修改实体和构造函数中的使用和类型提示..我已经完成了!

Then, I restarted an update but a different error occurred and the update was not fully completed.然后,我重新启动了更新,但发生了不同的错误并且更新未完全完成。

Result: my site is down and a compatibility error is displayed.结果:我的网站已关闭并显示兼容性错误。

watch this:看这个:

Compile Error: Declaration of App\\DataFixtures\\AppFixtures::load(Doctrine\\ORM\\EntityManagerInterface $manager) must be compatible with Doctrine\\Common\\DataFixtures\\FixtureInterface::load(Doctrine\\Common\\Persistence\\ObjectManager $manager) in AppFixtures.php line 8`编译错误:App\\DataFixtures\\AppFixtures::load(Doctrine\\ORM\\EntityManagerInterface $manager) 的声明必须与 AppFixtures 中的 Doctrine\\Common\\DataFixtures\\FixtureInterface::load(Doctrine\\Common\\Persistence\\ObjectManager $manager) 兼容。 php第8行`

I don't understand, what the compatibility is?我不明白,兼容性是什么?

I don't know how to post my code.. ( controllers, YAML, entity, .. ) but I got try.我不知道如何发布我的代码..(控制器、YAML、实体、..)但我尝试了。 my project is on GitHub before the bug, maybe it can be useful ( if you need..)我的项目在 bug 出现之前就在 GitHub 上,也许它会很有用(如果你需要……)

here my AppFixtures.php :这是我的 AppFixtures.php :

<?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\ORM\EntityManagerInterface;

class AppFixtures extends Fixture
{
    public function load(EntityManagerInterface $manager)
    {
        // $product = new Product();
        // $manager->persist($product);

        $manager->flush();
    }
}

我想现在要使用 symfony 4.3 更正 lhor kostrov,您需要使用来自Doctrine\\Persistence\\ObjectManager而不是来自Doctrine\\Common\\Persistence\\ObjectManager

In your base class Fixture $manager instance of Doctrine\\Common\\Persistence\\ObjectManager , so you need change EntityManagerInterface to ObjectManager .Doctrine\\Common\\Persistence\\ObjectManager的基类Fixture $manager 实例中,您需要将EntityManagerInterface更改为ObjectManager You cannot override typehint in children class.您不能在子类中覆盖 typehint。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Doctrine的Symfony Bundle回购怎么了? - What happened to Doctrine's Symfony Bundle repos? Symfony2表单事件侦听器和数据转换器错误无法实例化接口Doctrine \\…\\ ObjectManager - Symfony2 Form Events Listener and Data Transformer Error Cannot instantiate interface Doctrine\…\ObjectManager Symfony 4:无法自动装配参数 $manager of ... 它引用接口“Doctrine\\Common\\Persistence\\ObjectManager” - Symfony 4 : Cannot autowire argument $manager of ... it references interface "Doctrine\Common\Persistence\ObjectManager" symfony2学说坚持后如何更新OneToMany实体? - symfony2 doctrine how to update OneToMany entities after persist? Symfony Doctrine Listener - 在 preRemove 事件中删除实体之前更新实体 - Symfony Doctrine Listener - update entity before it's deleted in preRemove event Symfony2 / Doctrine中的Entity和Model之间有什么区别 - What is the difference between Entity and Model in Symfony2 / Doctrine Symfony4将EntityManagerInterface注入框架不可知类 - Symfony4 Inject EntityManagerInterface into framework agnostic class PHPStan没有为Doctrine看到正确的ObjectManager - PHPStan don't see proper ObjectManager for Doctrine 类 Doctrine\Common\Persistence\ObjectManager 不存在 - Class Doctrine\Common\Persistence\ObjectManager does not exist Symfony 4 更新具有关系的学说实体 - Symfony 4 update doctrine entity with relationships
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM