コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function propertyToColumnName($propertyName, $className = null)
 {
     $defaultName = $this->defaultNamer->propertyToColumnName($propertyName, $className);
     /**
      * @var NamingStrategy $concurrentNamer
      */
     foreach ($this->concurrentNamers as $concurrentNamer) {
         if (($newProposal = $concurrentNamer->propertyToColumnName($propertyName, $className)) != $defaultName) {
             return $newProposal;
         }
     }
     return $defaultName;
 }
コード例 #2
0
 /**
  * Validates & completes the given field mapping.
  *
  * @param array $mapping  The field mapping to validated & complete.
  * @throws MappingException
  * @return array The validated and completed field mapping.
  */
 protected function _validateAndCompleteFieldMapping(array &$mapping)
 {
     // Check mandatory fields
     if (!isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
         throw MappingException::missingFieldName($this->name);
     }
     if (!isset($mapping['type'])) {
         // Default to string
         $mapping['type'] = 'string';
     }
     // Complete fieldName and columnName mapping
     if (!isset($mapping['columnName'])) {
         $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName']);
     }
     if ($mapping['columnName'][0] === '`') {
         $mapping['columnName'] = trim($mapping['columnName'], '`');
         $mapping['quoted'] = true;
     }
     $this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
     if (isset($this->fieldNames[$mapping['columnName']]) || $this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName']) {
         throw MappingException::duplicateColumnName($this->name, $mapping['columnName']);
     }
     $this->fieldNames[$mapping['columnName']] = $mapping['fieldName'];
     // Complete id mapping
     if (isset($mapping['id']) && $mapping['id'] === true) {
         if ($this->versionField == $mapping['fieldName']) {
             throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']);
         }
         if (!in_array($mapping['fieldName'], $this->identifier)) {
             $this->identifier[] = $mapping['fieldName'];
         }
         // Check for composite key
         if (!$this->isIdentifierComposite && count($this->identifier) > 1) {
             $this->isIdentifierComposite = true;
         }
     }
     if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) {
         if (isset($mapping['id']) && $mapping['id'] === true) {
             throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']);
         }
         $mapping['requireSQLConversion'] = true;
     }
 }
コード例 #3
0
 /**
  * @dataProvider dataPropertyToColumnName
  *
  * @param NamingStrategy $strategy
  * @param string $expected
  * @param string $propertyName
  */
 public function testPropertyToColumnName(NamingStrategy $strategy, $expected, $propertyName)
 {
     $this->assertEquals($expected, $strategy->propertyToColumnName($propertyName));
 }