diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php b/src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php index 8ec85e64..0019eead 100644 --- a/src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php +++ b/src/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriber.php | |||
@@ -8,6 +8,9 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo; | |||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Puts a prefix to each table. | 10 | * Puts a prefix to each table. |
11 | * This way were used instead of using the built-in strategy from Doctrine, using `naming_strategy` | ||
12 | * Because it conflicts with the DefaultQuoteStrategy (that espace table name, like user for Postgres) | ||
13 | * see #1498 for more detail. | ||
11 | * | 14 | * |
12 | * Solution from : | 15 | * Solution from : |
13 | * - http://stackoverflow.com/a/23860613/569101 | 16 | * - http://stackoverflow.com/a/23860613/569101 |
@@ -30,17 +33,18 @@ class TablePrefixSubscriber implements EventSubscriber | |||
30 | public function loadClassMetadata(LoadClassMetadataEventArgs $args) | 33 | public function loadClassMetadata(LoadClassMetadataEventArgs $args) |
31 | { | 34 | { |
32 | $classMetadata = $args->getClassMetadata(); | 35 | $classMetadata = $args->getClassMetadata(); |
36 | |||
33 | // if we are in an inheritance hierarchy, only apply this once | 37 | // if we are in an inheritance hierarchy, only apply this once |
34 | if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { | 38 | if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { |
35 | return; | 39 | return; |
36 | } | 40 | } |
37 | 41 | ||
38 | $classMetadata->setTableName($this->prefix . $classMetadata->getTableName()); | 42 | $classMetadata->setTableName($this->prefix.$classMetadata->getTableName()); |
39 | 43 | ||
40 | foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { | 44 | foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { |
41 | if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { | 45 | if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { |
42 | $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; | 46 | $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; |
43 | $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName; | 47 | $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName; |
44 | } | 48 | } |
45 | } | 49 | } |
46 | } | 50 | } |