Skip to content

Commit df66dad

Browse files
Support mapping import of simplified drivers
1 parent 068d670 commit df66dad

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Console/MappingImportCommand.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MappingImportCommand extends Command
1919
{mapping-type=xml : The mapping type to export the imported mapping information to}
2020
{dest-path? : Location the mapping files should be imported to}
2121
{--em=default : Info for a specific entity manager }
22-
{--filter= : A string pattern used to match entities that should be mapped}
22+
{--filter : A string pattern used to match entities that should be mapped}
2323
{--force= : Force to overwrite existing mapping files}
2424
{--namespace= : Namespace to use}';
2525

@@ -42,7 +42,18 @@ public function fire(ManagerRegistry $registry)
4242

4343
$destPath = base_path($this->argument('dest-path') ? $this->argument('dest-path') : 'app/Mappings');
4444

45-
$type = $this->argument('mapping-type');
45+
$simplified = false;
46+
$type = $this->argument('mapping-type');
47+
48+
if (starts_with($type, 'simplified')) {
49+
$simplified = true;
50+
51+
if (str_contains($type, 'xml')) {
52+
$type = 'xml';
53+
} elseif (str_contains($type, 'yaml')) {
54+
$type = 'yaml';
55+
}
56+
}
4657

4758
$cme = new ClassMetadataExporter();
4859
$exporter = $cme->getExporter($type);
@@ -77,6 +88,9 @@ public function fire(ManagerRegistry $registry)
7788
$className = $class->name;
7889
if ('annotation' === $type) {
7990
$path = $destPath . '/' . str_replace('\\', '.', $className) . '.php';
91+
} elseif ($simplified) {
92+
$element = explode('\\', $className);
93+
$path = $destPath . '/' . end($element) . '.orm.' . $type;
8094
} else {
8195
$path = $destPath . '/' . str_replace('\\', '.', $className) . '.dcm.' . $type;
8296
}

0 commit comments

Comments
 (0)