These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
4 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
5 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
6 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
7 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
8 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
9 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
10 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
11 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
12 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
14 | * |
||
15 | * This software consists of voluntary contributions made by many individuals |
||
16 | * and is licensed under the MIT license. For more information, see |
||
17 | * <http://www.doctrine-project.org>. |
||
18 | */ |
||
19 | |||
20 | namespace Doctrine\ORM\Persisters\Entity; |
||
21 | |||
22 | use Doctrine\ORM\Mapping\ClassMetadata; |
||
23 | use Doctrine\DBAL\Types\Type; |
||
24 | |||
25 | /** |
||
26 | * Base class for entity persisters that implement a certain inheritance mapping strategy. |
||
27 | * All these persisters are assumed to use a discriminator column to discriminate entity |
||
28 | * types in the hierarchy. |
||
29 | * |
||
30 | * @author Roman Borschel <[email protected]> |
||
31 | * @author Benjamin Eberlei <[email protected]> |
||
32 | * @since 2.0 |
||
33 | */ |
||
34 | abstract class AbstractEntityInheritancePersister extends BasicEntityPersister |
||
35 | { |
||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | 309 | protected function prepareInsertData($entity) |
|
40 | { |
||
41 | 309 | $data = parent::prepareInsertData($entity); |
|
42 | |||
43 | // Populate the discriminator column |
||
44 | 309 | $discColumn = $this->class->discriminatorColumn; |
|
45 | 309 | $this->columnTypes[$discColumn['name']] = $discColumn['type']; |
|
46 | 309 | $data[$this->getDiscriminatorColumnTableName()][$discColumn['name']] = $this->class->discriminatorValue; |
|
47 | |||
48 | 309 | return $data; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Gets the name of the table that contains the discriminator column. |
||
53 | * |
||
54 | * @return string The table name. |
||
55 | */ |
||
56 | abstract protected function getDiscriminatorColumnTableName(); |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | 79 | protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') |
|
62 | { |
||
63 | 79 | $tableAlias = $alias == 'r' ? '' : $alias; |
|
64 | 79 | $fieldMapping = $class->fieldMappings[$field]; |
|
65 | 79 | $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); |
|
66 | 79 | $sql = sprintf( |
|
67 | 79 | '%s.%s', |
|
68 | 79 | $this->getSQLTableAlias($class->name, $tableAlias), |
|
69 | 79 | $this->quoteStrategy->getColumnName($field, $class, $this->platform) |
|
70 | ); |
||
71 | |||
72 | 79 | $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); |
|
73 | |||
74 | 79 | if (isset($fieldMapping['requireSQLConversion'])) { |
|
75 | 1 | $type = Type::getType($fieldMapping['type']); |
|
76 | 1 | $sql = $type->convertToPHPValueSQL($sql, $this->platform); |
|
77 | } |
||
78 | |||
79 | 79 | return $sql . ' AS ' . $columnAlias; |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param string $tableAlias |
||
84 | * @param string $joinColumnName |
||
85 | * @param string $className |
||
86 | * @param string $type |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | 58 | protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className, $type) |
|
0 ignored issues
–
show
|
|||
91 | { |
||
92 | 58 | $columnAlias = $this->getSQLColumnAlias($joinColumnName); |
|
93 | |||
94 | 58 | $this->currentPersisterContext->rsm->addMetaResult('r', $columnAlias, $joinColumnName, false, $type); |
|
95 | |||
96 | 58 | return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias; |
|
97 | } |
||
98 | } |
||
99 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.