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


PHP Model::hasMethod方法代码示例

本文整理汇总了PHP中yii\base\Model::hasMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::hasMethod方法的具体用法?PHP Model::hasMethod怎么用?PHP Model::hasMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Model的用法示例。


在下文中一共展示了Model::hasMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createValidator

 /**
  * Creates a validator object.
  * @param mixed $type the validator type. This can be a built-in validator name,
  * a method name of the model class, an anonymous function, or a validator class name.
  * @param \yii\base\Model $object the data object to be validated.
  * @param array|string $attributes list of attributes to be validated. This can be either an array of
  * the attribute names or a string of comma-separated attribute names.
  * @param array $params initial values to be applied to the validator properties
  * @return Validator the validator
  */
 public static function createValidator($type, $object, $attributes, $params = [])
 {
     $params['attributes'] = $attributes;
     if ($type instanceof \Closure || $object->hasMethod($type)) {
         // method-based validator
         $params['class'] = __NAMESPACE__ . '\\InlineValidator';
         $params['method'] = $type;
     } else {
         if (isset(static::$builtInValidators[$type])) {
             $type = static::$builtInValidators[$type];
         }
         if (is_array($type)) {
             foreach ($type as $name => $value) {
                 $params[$name] = $value;
             }
         } else {
             if (!class_exists($type)) {
                 throw new InvalidConfigException("Unknown validator: '{$type}'.");
             }
             $params['class'] = $type;
         }
     }
     return Yii::createObject($params);
 }
开发者ID:pathman,项目名称:yii2comm,代码行数:34,代码来源:Validator.php

示例2: createValidator

 /**
  * Creates a validator object.
  * @param string|\Closure $type the validator type. This can be either:
  *  * a built-in validator name listed in [[builtInValidators]];
  *  * a method name of the model class;
  *  * an anonymous function;
  *  * a validator class name.
  * @param \yii\base\Model $model the data model to be validated.
  * @param array|string $attributes list of attributes to be validated. This can be either an array of
  * the attribute names or a string of comma-separated attribute names.
  * @param array $params initial values to be applied to the validator properties.
  * @return Validator the validator
  */
 public static function createValidator($type, $model, $attributes, $params = [])
 {
     $params['attributes'] = $attributes;
     if ($type instanceof \Closure || $model->hasMethod($type)) {
         // method-based validator
         $params['class'] = __NAMESPACE__ . '\\InlineValidator';
         $params['method'] = $type;
     } else {
         if (isset(static::$builtInValidators[$type])) {
             $type = static::$builtInValidators[$type];
         }
         if (is_array($type)) {
             $params = array_merge($type, $params);
         } else {
             $params['class'] = $type;
         }
     }
     return Yii::createObject($params);
 }
开发者ID:nanodesu88,项目名称:yii2,代码行数:32,代码来源:Validator.php

示例3: providersSupplied

 /**
  * @param MonsterProvidersTrait|yii\base\Model $model
  * @param string                $postKey
  */
 protected function providersSupplied(&$model, $postKey)
 {
     if ($this->action() === self::ACTION_DEFAULT) {
         // skip on default action
         return;
     }
     $providers = ArrayHelper::getValue($this->visualBuilderProvided(), "{$postKey}.providers", null);
     if (is_array($providers) === false) {
         // no providers supplied
         return;
     }
     //! @todo add check for proper class names and properties here
     $model->setEntityDataProviders($providers);
     if ($this->action() === self::ACTION_SAVE) {
         $result = $model->hasMethod('saveMonsterContent') ? $model->saveMonsterContent() : $model->saveProviders();
         if ($result === false) {
             throw new \Exception(var_export($model->errors, true));
         }
     }
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:24,代码来源:MainEntity.php


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