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

Expose the XSD validation in the DoctrineOrmMappingsPass #1679

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/DoctrineOrmMappingsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public function __construct($driver, array $namespaces, array $managerParameters
*
* @return self
*/
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [], bool $enableXsdValidation = false)
{
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']);
$driver = new Definition(XmlDriver::class, [$locator]);
$driver = new Definition(XmlDriver::class, [$locator, null, $enableXsdValidation]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous situation, we were omitting the second argument. I think as a result, XmlDriver::DEFAULT_FILE_EXTENSION was used: https://github.com/doctrine/orm/blob/55d477dc507a52675c5a61267a00d389c71182f4/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L50

Suggested change
$driver = new Definition(XmlDriver::class, [$locator, null, $enableXsdValidation]);
$driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]);

If I don't sound very sure about this, that's because its value is .dcm.xml, and I don't recall ever seeing that extension in Symfony projects. Also, on line 71, .orm.xml is mentioned so maybe it takes over somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension argument of the driver is ignored when passing a locator anyway. It is used only when passing a path.

And the locator we use uses the default extension of the simplified driver, which is not the same, so it would be confusing.


return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter, $aliasMap);
}
Expand Down