SchemaTrait::overrideSchemaDiff()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Tools;
4
5
trait SchemaTrait
6
{
7
    /**
8
     * Unfortunately due a poor design of the Doctrine\ORM\Tools\SchemaTool::getSchemaFromMetadata
9
     * we have to use "class_alias" to replace "Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets"
10
     * with "RDV\Bundle\EntityExtendBundle\Tools\ExtendSchemaUpdateRemoveNamespacedAssets".
11
     */
12
    public function overrideRemoveNamespacedAssets()
13
    {
14
        if (!class_exists('Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets', false)) {
15
            class_alias(
16
                'RDV\Bundle\EntityExtendBundle\Tools\ExtendSchemaUpdateRemoveNamespacedAssets',
17
                'Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets'
18
            );
19
        }
20
    }
21
22
    /**
23
     * to disable automatic rename of autogenerated indices
24
     * we have to use "class_alias" to replace "Doctrine\DBAL\Schema\SchemaDiff"
25
     * with "RDV\Bundle\MigrationBundle\Migration\Schema\SchemaDiff"
26
     */
27
    public function overrideSchemaDiff()
28
    {
29
        if (!class_exists('Doctrine\DBAL\Schema\SchemaDiff', false)) {
30
            class_alias(
31
                'RDV\Bundle\MigrationBundle\Migration\Schema\SchemaDiff',
32
                'Doctrine\DBAL\Schema\SchemaDiff'
33
            );
34
        }
35
    }
36
}
37