Author: Vojtěch Kohout
Esempio n. 1
0
 /**
  * @param Property $property
  * @param string $tableAlias
  * @param string $prefix
  * @return string
  * @throws InvalidArgumentException
  */
 public function formatColumn(Property $property, $tableAlias, $prefix = null)
 {
     isset($prefix) or $prefix = $tableAlias;
     if (($column = $property->getColumn()) === null) {
         throw new InvalidArgumentException("Missing low-level column for property {$property}.");
     }
     return $prefix . self::PREFIX_SEPARATOR . $column;
 }
Esempio n. 2
0
 private function replacePlaceholder(Property $property)
 {
     $type = $property->getType();
     if ($property->isBasicType()) {
         if (array_key_exists($type, self::$placeholders)) {
             return self::$placeholders[$type];
         } else {
             return self::$defaultPlaceholder;
         }
     } else {
         if ($type === 'DateTime' || is_subclass_of($type, 'DateTime')) {
             if ($property->hasCustomFlag(self::$typeFlagName) && preg_match('#^(DATE|Date|date)$#', $property->getCustomFlagValue(self::$typeFlagName))) {
                 return self::$placeholders['Date'];
             } else {
                 return self::$placeholders['DateTime'];
             }
         } else {
             return self::$defaultPlaceholder;
         }
     }
 }
Esempio n. 3
0
 private function getType(Property $property)
 {
     $type = NULL;
     if ($property->isBasicType()) {
         $type = $property->getType();
         if ($type == 'string') {
             if (!$property->hasCustomFlag('size')) {
                 $type = 'text';
             }
         }
         /* if ($property->containsEnumeration()) {
         	  $type = 'enum';
         	  } */
     } else {
         // Objects
         $class = new ReflectionClass($property->getType());
         $class = $class->newInstance();
         if ($class instanceof DateTime) {
             if ($property->hasCustomFlag('format')) {
                 $type = $property->getCustomFlagValue('format');
             } else {
                 $type = 'datetime';
             }
         }
     }
     return $type;
 }
Esempio n. 4
0
 /**
  * @param Property $property
  * @param string $mapperClass
  * @param Entity $entity
  * @throws InvalidValueException
  */
 private function checkConsistency(Property $property, $mapperClass, Entity $entity)
 {
     $type = $property->getType();
     if (!$entity instanceof $type) {
         throw new InvalidValueException("Inconsistency found: property '{$property->getName()}' in entity " . get_called_class() . " is supposed to contain an instance of '{$type}' (due to type hint), but mapper maps it to '{$mapperClass}'. Please fix getEntityClass method in mapper, property annotation or entities inheritance.");
     }
 }
 private function isIgnored(Property $property)
 {
     return $property->hasCustomFlag('baked') || $property->hasCustomFlag('ignore') || $property->hasCustomFlag('ignored');
 }