Skip to content

Exception when using DoctrineOrmMappingsPass::createAttributeMappingDriver together with doctrine/orm > v3Β #1844

@uerka

Description

@uerka

Bug Report

Not sure if i should put it here or into doctrine/orm as it seems like compatibility problem.

Q A
doctrine\doctrine-bundle 2.13.1
doctrine\orm 3.3.0

Summary

We have a private bundle, that we're reusing on multiple projects. This bundle provides some entities with mapping. Within this bundle we're calling DoctrineOrmMappingsPass to register bundle's entities mapping:

$container->addCompilerPass(DoctrineOrmMappingsPass::createAttributeMappingDriver($namespaces, $directories));

Current behavior

Currently app crashes hard with \InvalidArgumentException

The $reportFieldsWhereDeclared argument is no longer supported, make sure to omit it when calling Doctrine\ORM\Mapping\Driver\AttributeDriver::__construct.

Expected behavior

It probably should not crash)
As soon as its going to be omitted by doctrine\orm we would like to avoid pass reportFieldsWhereDeclared from bundle.

How to reproduce

Its quite simple:

  1. doctrine/orm version > 3
  2. latest doctrine/doctrine-bundle
  3. call DoctrineOrmMappingsPass to add mapping by attributes - for example like following:
namespace My\CustomBundle;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class MyCustomBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        $namespaces = [
            'My\CustomBundle\Model',
        ];

        $directories = [
            __DIR__ . '/src/Model',
        ];
        
        $container->addCompilerPass(DoctrineOrmMappingsPass::createAttributeMappingDriver($namespaces, $directories));
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions