Пример #1
0
 protected function getType($name)
 {
     return DataMapper\Types::getInstance()->get($name);
 }
Пример #2
0
        $attribute = array_merge($defaults, self::factory($type)->normalizeAttribute($attribute));
        if ($attribute['allow_null']) {
            $attribute['default'] = null;
        }
        if ($attribute['primary_key']) {
            $attribute['allow_null'] = false;
            $attribute['refuse_update'] = true;
            $attribute['strict'] = true;
        }
        if ($attribute['protected'] && $attribute['strict'] === null) {
            $attribute['strict'] = true;
        }
        return $attribute;
    }
}
\Lysine\DataMapper\Types::getInstance()->register('common', '\\Lysine\\DataMapper\\Types\\Common')->register('datetime', '\\Lysine\\DataMapper\\Types\\DateTime')->register('integer', '\\Lysine\\DataMapper\\Types\\Integer')->register('json', '\\Lysine\\DataMapper\\Types\\Json')->register('number', '\\Lysine\\DataMapper\\Types\\Number')->register('pg_array', '\\Lysine\\DataMapper\\Types\\PgsqlArray')->register('pg_hstore', '\\Lysine\\DataMapper\\Types\\PgsqlHstore')->register('string', '\\Lysine\\DataMapper\\Types\\Text')->register('uuid', '\\Lysine\\DataMapper\\Types\\UUID');
namespace Lysine\DataMapper\Types;

/**
 * 默认数据类型
 */
class Common
{
    /**
     * 格式化属性定义
     *
     * @param array $attribute
     * @return array
     */
    public function normalizeAttribute(array $attribute)
    {