自从激活了enable_lazy_ghost_objects后找不到类

问题描述 投票:0回答:1

交响乐6.4 教义/规则 2.17

我看到了这个弃用

Since doctrine/doctrine-bundle 2.11: Not setting "enable_lazy_ghost_objects" to true is deprecated

在学说配置文件中,我添加了这一行:

    orm:
        enable_lazy_ghost_objects: true

自从我这样做以来,自从我的 crontab 以来运行命令时出现了很多错误 示例:

In LazyObjectRegistry.php line 70:
  [ErrorException]
  Warning: Class "arreteCompte" not found

Exception trace:
  at /var/www/html/vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php:70
 Symfony\Component\VarExporter\Internal\LazyObjectRegistry::getClassResetters() at /var/www/html/vendor/symfony/var-exporter/LazyGhostTrait.php:52
 Proxies\__CG__\App\Entity\Bail::createLazyGhost() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php:471
 Proxies\__CG__\App\Entity\Bail::Doctrine\ORM\Proxy\{closure}() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php:212
 Doctrine\ORM\Proxy\ProxyFactory->getProxy() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:3050
 Doctrine\ORM\UnitOfWork->createEntity() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:272
 Doctrine\ORM\Internal\Hydration\ObjectHydrator->getEntity() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:498
 Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:149
 Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateAllData() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:270
 Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:1225
 Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache() at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:1166

进入这个循环时出现错误:

$assuranceBaux = $this->assuranceBailRepository->findAssuranceBailNeeded();

foreach ($assuranceBaux as $assuranceBail) {
    ...
}

在存储库中,我有这样的东西: 公共函数 findAssuranceBailNeeded() { $qb = $this->createQueryBuilder('ab');

    return $qb->select('ab')
        ->join('ab.typeAssurance', 'at')
        ->join(
            'ab.bail',
            'b',
            Join::WITH,
            $qb->expr()->orX(
                ...
            )
        )
        ->getQuery()
        ->getResult();

保证保释实体:

class AssuranceBail
{
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'SEQUENCE')]
    #[ORM\Column(type: 'integer')]
    private $id;

    #[ORM\ManyToOne(targetEntity: Bail::class, inversedBy: 'assurances')]
    #[ORM\JoinColumn(nullable: false)]
    private $bail;

    ...

保释实体:

class Bail
{
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'SEQUENCE')]
    #[ORM\Column(type: 'integer')]
    private $id;

    #[ORM\OneToOne(mappedBy: 'bail', targetEntity: ArreteCompte::class, cascade: ['persist', 'remove'])]
    #[Groups(['detailRestitDg', 'listDg', 'detailRestitDg', 'informationsDg'])]
    private ?ArreteCompte $arreteCompte;

当我查看doctrine/orm/Proxies/__CG__AppEntityBail.php文件时,我有这个:

namespace Proxies\__CG__\App\Entity;

/**
 * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
 */
class Bail extends \App\Entity\Bail implements \Doctrine\ORM\Proxy\InternalProxy
{
    use \Symfony\Component\VarExporter\LazyGhostTrait {
        initializeLazyObject as __load;
        setLazyObjectAsInitialized as public __setInitialized;
        isLazyObjectInitialized as private;
        createLazyGhost as private;
        resetLazyObject as private;
    }

    private const LAZY_OBJECT_PROPERTY_SCOPES = [
        ...
        "\0".parent::class."\0".'arreteCompte' => [parent::class, 'arreteCompte', 'arreteCompte'],

即使我加入了存储库中的 ArreteCompte 表,我也会遇到同样的错误。 我不明白教义需要什么,你能帮助我吗?

symfony doctrine
1个回答
0
投票

我也遇到同样的问题。但是,当将 auto_generate_proxy_classes: true 更改为 false 时,问题似乎已解决。你这边是怎么配置的?

© www.soinside.com 2019 - 2024. All rights reserved.