Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typed_fields option to ORM configuration to configure TypedFieldMapper #1779

Open
wants to merge 1 commit into
base: 2.12.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/DependencyInjection/Configuration.php
Expand Up @@ -664,6 +664,9 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition
->arrayNode('schema_ignore_classes')
->prototype('scalar')->end()
->end()
->arrayNode('typed_fields')
->prototype('scalar')->end()
->end()
->booleanNode('report_fields_where_declared')
->defaultValue(! class_exists(AnnotationDriver::class))
->info('Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.16 and will be mandatory in ORM 3.0. See https://github.com/doctrine/orm/pull/10455.')
Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/DoctrineExtension.php
Expand Up @@ -22,6 +22,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Events;
use Doctrine\ORM\Id\AbstractIdGenerator;
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
use Doctrine\ORM\Proxy\Autoloader;
use Doctrine\ORM\Proxy\ProxyFactory;
Expand Down Expand Up @@ -721,6 +722,13 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $
$methods['setRepositoryFactory'] = new Reference($entityManager['repository_factory']);
}

if (isset($entityManager['typed_fields'])) {
$definition = new Definition(DefaultTypedFieldMapper::class);
$definition->addArgument($entityManager['typed_fields']);
$container->setDefinition(sprintf('doctrine.orm.%s_typed_field_mapper', $entityManager['name']), $definition);
$methods['setTypedFieldMapper'] = new Reference(sprintf('doctrine.orm.%s_typed_field_mapper', $entityManager['name']));
}

foreach ($methods as $method => $arg) {
$ormConfigDef->addMethodCall($method, [$arg]);
}
Expand Down