本文整理汇总了PHP中RedBeanModel::getYiiValidatorsToRedBeanValidators方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::getYiiValidatorsToRedBeanValidators方法的具体用法?PHP RedBeanModel::getYiiValidatorsToRedBeanValidators怎么用?PHP RedBeanModel::getYiiValidatorsToRedBeanValidators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::getYiiValidatorsToRedBeanValidators方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveColumnTypeAndLengthFromRules
protected static function resolveColumnTypeAndLengthFromRules($modelClassName, $member, array $rules, &$type, &$length, &$notNull, &$default, &$messageLogger)
{
$suitableModelClassName = static::findSuitableModelClassName($modelClassName);
if (!$suitableModelClassName) {
$messageLogger->addErrorMessage(Zurmo::t('Core', 'Unable to find a suitable non-abstract class for' . ' validators against {{model}}', array('{{model}}' => $modelClassName)));
return;
}
$model = $suitableModelClassName::model();
$yiiValidators = CValidator::$builtInValidators;
$yiiValidatorsToRedBeanValidators = RedBeanModel::getYiiValidatorsToRedBeanValidators();
foreach ($rules as $validatorMetadata) {
assert('isset($validatorMetadata[0])');
assert('isset($validatorMetadata[1])');
$validatorName = $validatorMetadata[1];
$validatorParameters = array_slice($validatorMetadata, 2);
if (isset($yiiValidators[$validatorName])) {
$validatorName = $yiiValidators[$validatorName];
}
if (isset($yiiValidatorsToRedBeanValidators[$validatorName])) {
$validatorName = $yiiValidatorsToRedBeanValidators[$validatorName];
}
if (!@class_exists($validatorName)) {
continue;
}
$validator = CValidator::createValidator($validatorName, $model, $member, $validatorParameters);
switch ($validatorName) {
case 'RedBeanModelTypeValidator':
case 'TypeValidator':
case 'CTypeValidator':
if (in_array($validator->type, array('blob', 'boolean', 'date', 'datetime', 'longblob', 'string', 'float', 'integer', 'time', 'text', 'longtext'))) {
if (!isset($type) || $validator->type == 'float') {
$type = $validator->type;
}
}
break;
case 'CBooleanValidator':
$type = 'boolean';
break;
case 'CStringValidator':
if (!isset($type) || $type == 'string') {
static::resolveStringTypeAndLengthByMaxLength($type, $length, $validator->max);
}
break;
case 'CUrlValidator':
$type = 'string';
if (!isset($length)) {
$length = 255;
}
break;
case 'CEmailValidator':
$type = 'string';
if (!isset($length)) {
$length = 255;
}
break;
case 'RedBeanModelNumberValidator':
case 'CNumberValidator':
if ((!isset($type) || $type == 'integer') && !isset($validator->precision)) {
static::resolveIntegerTypeByMinAndMaxValue($type, $validator->min, $validator->max);
}
break;
case 'RedBeanModelDefaultValueValidator':
case 'CDefaultValueValidator':
// Left here for future use if we want to set defaults on db level too.
//$default = 'DEFAULT ' . $validator->value;
break;
case 'RedBeanModelRequiredValidator':
case 'CRequiredValidator':
//$notNull = 'NOT NULL'; // Not Coding Standard
// Left here for future use if we want to set required on db level too.
break;
case 'RedBeanModelUniqueValidator':
case 'CUniqueValidator':
static::registerUniqueIndexByMemberName($member, $modelClassName);
break;
}
}
// we have a string and we don't know anything else about it, better to set it as text.
if ($type == 'string' && !isset($length)) {
$type = 'text';
}
}