Code Duplication    Length = 30-33 lines in 2 locations

lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php 1 location

@@ 485-517 (lines=33) @@
482
        $columnList[] = $tableAlias . '.' . $discrColumn;
483
484
        // sub tables
485
        foreach ($this->class->subClasses as $subClassName) {
486
            $subClass   = $this->em->getClassMetadata($subClassName);
487
            $tableAlias = $this->getSQLTableAlias($subClassName);
488
489
            // Add subclass columns
490
            foreach ($subClass->fieldMappings as $fieldName => $mapping) {
491
                if (isset($mapping['inherited'])) {
492
                    continue;
493
                }
494
495
                $columnList[] = $this->getSelectColumnSQL($fieldName, $subClass);
496
            }
497
498
            // Add join columns (foreign keys)
499
            foreach ($subClass->associationMappings as $mapping) {
500
                if ( ! $mapping['isOwningSide']
501
                        || ! ($mapping['type'] & ClassMetadata::TO_ONE)
502
                        || isset($mapping['inherited'])) {
503
                    continue;
504
                }
505
506
                $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
507
508
                foreach ($mapping['joinColumns'] as $joinColumn) {
509
                    $columnList[] = $this->getSelectJoinColumnSQL(
510
                        $tableAlias,
511
                        $joinColumn['name'],
512
                        $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform),
513
                        PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em)
514
                    );
515
                }
516
            }
517
        }
518
519
        $this->currentPersisterContext->selectColumnListSql = implode(', ', $columnList);
520

lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php 1 location

@@ 72-101 (lines=30) @@
69
        $this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumn, false, $discrColumnType);
70
71
        // Append subclass columns
72
        foreach ($this->class->subClasses as $subClassName) {
73
            $subClass = $this->em->getClassMetadata($subClassName);
74
75
            // Regular columns
76
            foreach ($subClass->fieldMappings as $fieldName => $mapping) {
77
                if (isset($mapping['inherited'])) {
78
                    continue;
79
                }
80
81
                $columnList[] = $this->getSelectColumnSQL($fieldName, $subClass);
82
            }
83
84
            // Foreign key columns
85
            foreach ($subClass->associationMappings as $assoc) {
86
                if ( ! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE) || isset($assoc['inherited'])) {
87
                    continue;
88
                }
89
90
                $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
91
92
                foreach ($assoc['joinColumns'] as $joinColumn) {
93
                    $columnList[] = $this->getSelectJoinColumnSQL(
94
                        $tableAlias,
95
                        $joinColumn['name'],
96
                        $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform),
97
                        PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em)
98
                    );
99
                }
100
            }
101
        }
102
103
        $this->currentPersisterContext->selectColumnListSql = implode(', ', $columnList);
104