当前位置: 首页>>代码示例>>PHP>>正文


PHP RedBeanModel::getYiiValidatorsToRedBeanValidators方法代码示例

本文整理汇总了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';
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:82,代码来源:RedBeanModelMemberRulesToColumnAdapter.php


注:本文中的RedBeanModel::getYiiValidatorsToRedBeanValidators方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。