Builder
9 months ago
Driver
9 months ago
Exception
9 months ago
Reflection
9 months ago
Annotation.php
9 months ago
AnsiQuoteStrategy.php
9 months ago
AssociationOverride.php
9 months ago
AssociationOverrides.php
9 months ago
AttributeOverride.php
9 months ago
AttributeOverrides.php
9 months ago
Cache.php
9 months ago
ChainTypedFieldMapper.php
9 months ago
ChangeTrackingPolicy.php
9 months ago
ClassMetadata.php
9 months ago
ClassMetadataFactory.php
9 months ago
ClassMetadataInfo.php
9 months ago
Column.php
9 months ago
ColumnResult.php
9 months ago
CustomIdGenerator.php
9 months ago
DefaultEntityListenerResolver.php
9 months ago
DefaultNamingStrategy.php
9 months ago
DefaultQuoteStrategy.php
9 months ago
DefaultTypedFieldMapper.php
9 months ago
DiscriminatorColumn.php
9 months ago
DiscriminatorMap.php
9 months ago
Embeddable.php
9 months ago
Embedded.php
9 months ago
Entity.php
9 months ago
EntityListenerResolver.php
9 months ago
EntityListeners.php
9 months ago
EntityResult.php
9 months ago
FieldResult.php
9 months ago
GeneratedValue.php
9 months ago
HasLifecycleCallbacks.php
9 months ago
Id.php
9 months ago
Index.php
9 months ago
InheritanceType.php
9 months ago
InverseJoinColumn.php
9 months ago
JoinColumn.php
9 months ago
JoinColumnProperties.php
9 months ago
JoinColumns.php
9 months ago
JoinTable.php
9 months ago
ManyToMany.php
9 months ago
ManyToOne.php
9 months ago
MappedSuperclass.php
9 months ago
MappingAttribute.php
9 months ago
MappingException.php
9 months ago
NamedNativeQueries.php
9 months ago
NamedNativeQuery.php
9 months ago
NamedQueries.php
9 months ago
NamedQuery.php
9 months ago
NamingStrategy.php
9 months ago
OneToMany.php
9 months ago
OneToOne.php
9 months ago
OrderBy.php
9 months ago
PostLoad.php
9 months ago
PostPersist.php
9 months ago
PostRemove.php
9 months ago
PostUpdate.php
9 months ago
PreFlush.php
9 months ago
PrePersist.php
9 months ago
PreRemove.php
9 months ago
PreUpdate.php
9 months ago
QuoteStrategy.php
9 months ago
ReflectionEmbeddedProperty.php
9 months ago
ReflectionEnumProperty.php
9 months ago
ReflectionReadonlyProperty.php
9 months ago
SequenceGenerator.php
9 months ago
SqlResultSetMapping.php
9 months ago
SqlResultSetMappings.php
9 months ago
Table.php
9 months ago
TypedFieldMapper.php
9 months ago
UnderscoreNamingStrategy.php
9 months ago
UniqueConstraint.php
9 months ago
Version.php
9 months ago
DefaultQuoteStrategy.php
88 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Mapping; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 6 | use MailPoetVendor\Doctrine\ORM\Internal\SQLResultCasing; |
| 7 | use function array_map; |
| 8 | use function array_merge; |
| 9 | use function is_numeric; |
| 10 | use function preg_replace; |
| 11 | use function substr; |
| 12 | class DefaultQuoteStrategy implements QuoteStrategy |
| 13 | { |
| 14 | use SQLResultCasing; |
| 15 | public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) |
| 16 | { |
| 17 | return isset($class->fieldMappings[$fieldName]['quoted']) ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName']) : $class->fieldMappings[$fieldName]['columnName']; |
| 18 | } |
| 19 | public function getTableName(ClassMetadata $class, AbstractPlatform $platform) |
| 20 | { |
| 21 | $tableName = $class->table['name']; |
| 22 | if (!empty($class->table['schema'])) { |
| 23 | $tableName = $class->table['schema'] . '.' . $class->table['name']; |
| 24 | // @phpstan-ignore method.deprecated |
| 25 | if (!$platform->supportsSchemas() && $platform->canEmulateSchemas()) { |
| 26 | $tableName = $class->table['schema'] . '__' . $class->table['name']; |
| 27 | } |
| 28 | } |
| 29 | return isset($class->table['quoted']) ? $platform->quoteIdentifier($tableName) : $tableName; |
| 30 | } |
| 31 | public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform) |
| 32 | { |
| 33 | return isset($definition['quoted']) ? $platform->quoteIdentifier($definition['sequenceName']) : $definition['sequenceName']; |
| 34 | } |
| 35 | public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) |
| 36 | { |
| 37 | return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) : $joinColumn['name']; |
| 38 | } |
| 39 | public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) |
| 40 | { |
| 41 | return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['referencedColumnName']) : $joinColumn['referencedColumnName']; |
| 42 | } |
| 43 | public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform) |
| 44 | { |
| 45 | $schema = ''; |
| 46 | if (isset($association['joinTable']['schema'])) { |
| 47 | $schema = $association['joinTable']['schema']; |
| 48 | // @phpstan-ignore method.deprecated |
| 49 | $schema .= !$platform->supportsSchemas() && $platform->canEmulateSchemas() ? '__' : '.'; |
| 50 | } |
| 51 | $tableName = $association['joinTable']['name']; |
| 52 | if (isset($association['joinTable']['quoted'])) { |
| 53 | $tableName = $platform->quoteIdentifier($tableName); |
| 54 | } |
| 55 | return $schema . $tableName; |
| 56 | } |
| 57 | public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) |
| 58 | { |
| 59 | $quotedColumnNames = []; |
| 60 | foreach ($class->identifier as $fieldName) { |
| 61 | if (isset($class->fieldMappings[$fieldName])) { |
| 62 | $quotedColumnNames[] = $this->getColumnName($fieldName, $class, $platform); |
| 63 | continue; |
| 64 | } |
| 65 | // Association defined as Id field |
| 66 | $joinColumns = $class->associationMappings[$fieldName]['joinColumns']; |
| 67 | $assocQuotedColumnNames = array_map(static function ($joinColumn) use($platform) { |
| 68 | return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) : $joinColumn['name']; |
| 69 | }, $joinColumns); |
| 70 | $quotedColumnNames = array_merge($quotedColumnNames, $assocQuotedColumnNames); |
| 71 | } |
| 72 | return $quotedColumnNames; |
| 73 | } |
| 74 | public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ?ClassMetadata $class = null) |
| 75 | { |
| 76 | // 1 ) Concatenate column name and counter |
| 77 | // 2 ) Trim the column alias to the maximum identifier length of the platform. |
| 78 | // If the alias is to long, characters are cut off from the beginning. |
| 79 | // 3 ) Strip non alphanumeric characters |
| 80 | // 4 ) Prefix with "_" if the result its numeric |
| 81 | $columnName .= '_' . $counter; |
| 82 | $columnName = substr($columnName, -$platform->getMaxIdentifierLength()); |
| 83 | $columnName = preg_replace('/[^A-Za-z0-9_]/', '', $columnName); |
| 84 | $columnName = is_numeric($columnName) ? '_' . $columnName : $columnName; |
| 85 | return $this->getSQLResultCasing($platform, $columnName); |
| 86 | } |
| 87 | } |
| 88 |