Example #1
0
 private static function parseMapping($mapping, $modelName, $propertyName, TypeConverter $typeConverter)
 {
     $me = new MappingElement();
     if (preg_match('/^(\\w+):(\\w+)$/', $mapping, $match)) {
         // две строки через двоеточие — relationProp:foreignProp, прокси-поле
         $me->relationLocalProperty = $match[1];
         $me->relationForeignProperty = $match[2];
     } elseif (strtoupper($mapping[0]) == $mapping[0]) {
         // начинается с прописной буквы — модель, т.е. внешний ключ
         $me->foreignKeyTable = $mapping;
     } elseif ($mapping) {
         // не начинается с прописной буквы — тип данных, локальное поле
         if (!$typeConverter->hasType($mapping)) {
             throw new ConfigLoadException("Incorrect type \"{$mapping}\" for {$modelName}.{$propertyName}");
         }
         $me->localPropertyType = $mapping;
     } else {
         throw new ConfigLoadException("Cannot parse mapping \"{$mapping}\" for {$modelName}.{$propertyName}");
     }
     return $me;
 }