|
4 | 4 |
|
5 | 5 | namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler; |
6 | 6 |
|
| 7 | +use Doctrine\Deprecations\Deprecation; |
7 | 8 | use Doctrine\ORM\Mapping\Driver\AttributeDriver; |
8 | 9 | use Doctrine\ORM\Mapping\Driver\XmlDriver; |
9 | 10 | use Doctrine\Persistence\Mapping\Driver\PHPDriver; |
|
12 | 13 | use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass; |
13 | 14 | use Symfony\Component\DependencyInjection\Definition; |
14 | 15 | use Symfony\Component\DependencyInjection\Reference; |
| 16 | +use TypeError; |
| 17 | + |
| 18 | +use function func_get_arg; |
| 19 | +use function func_num_args; |
| 20 | +use function gettype; |
| 21 | +use function is_array; |
| 22 | +use function is_bool; |
| 23 | +use function sprintf; |
15 | 24 |
|
16 | 25 | /** |
17 | 26 | * Class for Symfony bundles to configure mappings for model classes not in the |
@@ -47,17 +56,39 @@ public function __construct(Definition|Reference $driver, array $namespaces, arr |
47 | 56 | } |
48 | 57 |
|
49 | 58 | /** |
50 | | - * @param string[] $namespaces Hashmap of directory path to namespace. |
51 | | - * @param string[] $managerParameters List of parameters that could which object manager name |
52 | | - * your bundle uses. This compiler pass will automatically |
53 | | - * append the parameter name for the default entity manager |
54 | | - * to this list. |
55 | | - * @param string|false $enabledParameter Service container parameter that must be present to |
56 | | - * enable the mapping. Set to false to not do any check, |
57 | | - * optional. |
| 59 | + * @param string[] $namespaces Hashmap of directory path to namespace. |
| 60 | + * @param string[] $managerParameters List of parameters that could which object manager name |
| 61 | + * your bundle uses. This compiler pass will automatically |
| 62 | + * append the parameter name for the default entity manager |
| 63 | + * to this list. |
| 64 | + * @param string|false $enabledParameter Service container parameter that must be present to |
| 65 | + * enable the mapping. Set to false to not do any check, |
| 66 | + * optional. |
| 67 | + * @param bool $enableXsdValidation |
| 68 | + * |
| 69 | + * @phpstan-ignore missingType.iterableValue |
58 | 70 | */ |
59 | | - public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, bool $enableXsdValidation = false): self |
| 71 | + public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], string|false $enabledParameter = false, bool|array $enableXsdValidation = false): self |
60 | 72 | { |
| 73 | + if (is_array($enableXsdValidation)) { |
| 74 | + Deprecation::trigger( |
| 75 | + 'doctrine/doctrine-bundle', |
| 76 | + 'https://github.com/doctrine/DoctrineBundle/pull/2190', |
| 77 | + 'Providing a $aliasMap argument to %s is deprecated and has no effect.', |
| 78 | + __METHOD__, |
| 79 | + ); |
| 80 | + $enableXsdValidation = false; |
| 81 | + |
| 82 | + if (func_num_args() === 5) { |
| 83 | + $enableXsdValidationArg = func_get_arg(4); |
| 84 | + if (! is_bool($enableXsdValidationArg)) { |
| 85 | + throw new TypeError(sprintf('$enableXsdValidation is expected to be boolean, %s provided', gettype($enableXsdValidationArg))); |
| 86 | + } |
| 87 | + |
| 88 | + $enableXsdValidation = $enableXsdValidationArg; |
| 89 | + } |
| 90 | + } |
| 91 | + |
61 | 92 | $locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']); |
62 | 93 | $driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]); |
63 | 94 |
|
|
0 commit comments