當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。