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


PHP ArrayHelper::keyExists方法代码示例

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


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

示例1: initUserAttributes

 /**
  * @inheritdoc
  */
 protected function initUserAttributes()
 {
     $data = [];
     foreach (explode(" ", $this->scope) as $scope) {
         if (in_array($scope, $this->_userinfoscopes)) {
             $api = $this->api($scope, 'GET');
             if (ArrayHelper::getValue($api, 'status') !== "ok") {
                 Yii:
                 trace("Server error: " . print_r($api, true));
                 throw new InvalidResponseException($api, "error", print_r($api, true));
             }
             $apiData = ArrayHelper::getValue($api, 'data', []);
             if ($scope === "profile") {
                 if (ArrayHelper::getValue($apiData, 'blacklisted') !== false || ArrayHelper::getValue($apiData, 'quarantine') !== false || ArrayHelper::getValue($apiData, 'verified') !== true) {
                     Yii::trace("OAuth Failed. Provider V. Data: " . print_r($api, true), 'oauth');
                     throw new UserNotAllowedException("User is blacklisted, quarantined or not verified");
                 }
                 if (ArrayHelper::keyExists('enlid', $apiData)) {
                     if (ArrayHelper::getValue($apiData, 'enlid') === "null") {
                         Yii:
                         trace("enlid is null", 'oauth');
                         throw new UserNotAllowedException("Userprofile incomplete");
                     } else {
                         $data['id'] = ArrayHelper::getValue($data, 'enlid');
                     }
                 }
             }
             $data = array_merge($data, $apiData);
         }
     }
     return $data;
 }
开发者ID:aradiv,项目名称:yii2-authclient-v,代码行数:35,代码来源:VOAuth.php

示例2: getFilter

 /**
  * @param $name
  * @return Filter
  */
 public function getFilter($name)
 {
     if (!ArrayHelper::keyExists($name, $this->_filters)) {
         $this->addFilter($name);
     }
     return $this->_filters[$name];
 }
开发者ID:orb3b,项目名称:BI-Platform-v3,代码行数:11,代码来源:BaseDashboardController.php

示例3: __get

 /**
  * Check whether we have a plugin installed with that name previous firing up the call
  *
  * @param string $name
  *
  * @return mixed|void
  */
 public function __get($name)
 {
     if (ArrayHelper::keyExists($name, $this->getInstalledPlugins())) {
         return $this->getPlugin($name);
     }
     return parent::__get($name);
 }
开发者ID:bariew,项目名称:yii2-google-maps-library,代码行数:14,代码来源:PluginManager.php

示例4: getWidget

 /**
  * @param $name
  * @return VisioWidget
  */
 public function getWidget($name)
 {
     if (!ArrayHelper::keyExists($name, $this->_widgets)) {
         $this->addWidget($name);
     }
     return $this->_widgets[$name];
 }
开发者ID:Polymedia,项目名称:BI-Platform-v3,代码行数:11,代码来源:BaseDashboardController.php

示例5: addOriginalText

 /**
  * Add Original Text
  * @param string $text
  * @param int $yandexSiteID
  * @throws InvalidParamException
  * @return string|bool
  */
 public function addOriginalText($text, $yandexSiteID)
 {
     /** @var Cache $cache */
     $cache = \Yii::$app->get($this->cacheComponent);
     $cacheKey = "Yandex_OT_sent:" . $this->clientID . "_" . $this->clientSecret;
     $sent = $cache->get($cacheKey);
     if ($sent === false) {
         $sent = 0;
     }
     if ($sent >= self::YANDEX_OT_DAILY_LIMIT) {
         throw new InvalidParamException("Daily limit exceeded!");
     }
     $validator = new StringValidator(['min' => self::YANDEX_OT_MIN, 'max' => self::YANDEX_OT_MAX, 'enableClientValidation' => false]);
     if (!$validator->validate($text, $error)) {
         throw new InvalidParamException($error);
     }
     $text = urlencode(htmlspecialchars($text));
     $text = "<original-text><content>{$text}</content></original-text>";
     $response = $this->apiClient->rawApi("hosts/{$yandexSiteID}/original-texts/", "POST", $text);
     $success = ArrayHelper::keyExists('id', $response) && ArrayHelper::keyExists('link', $response);
     if ($success) {
         $sent++;
         $cache->set($cacheKey, $sent, 60 * 60 * 24);
     }
     return $success;
 }
开发者ID:euromd,项目名称:yii2-yandex-metrika,代码行数:33,代码来源:Client.php

示例6: getSelect2Type

 public function getSelect2Type()
 {
     if (ArrayHelper::keyExists('ajax', $this->pluginOptions) and $this->pluginOptions['ajax']) {
         return 'ajax';
     }
     return false;
 }
开发者ID:nagser,项目名称:base,代码行数:7,代码来源:Select2.php

示例7: init

 public function init()
 {
     parent::init();
     if (!ArrayHelper::keyExists('url', $this->clientOptions)) {
         throw \yii\base\InvalidConfigException('Url key is missing in clientOptions');
     }
 }
开发者ID:tecsin,项目名称:yii2-file-manager,代码行数:7,代码来源:ElFinderWidget.php

示例8: setDefault

 /**
  * 设置 summernote 配置默认值
  */
 public function setDefault()
 {
     $ary = ['lang' => SELF::LANG_DEFAULT, 'height' => SELF::HEIGHT_DEFAULT];
     foreach ($ary as $k => $v) {
         $this->clientOptions[$k] = ArrayHelper::keyExists($k, $this->clientOptions) ? $this->clientOptions[$k] : $v;
     }
 }
开发者ID:piaoyii,项目名称:yii2-summernote,代码行数:10,代码来源:Summernote.php

示例9: markAs

 /**
  * отметить как
  * @param $status
  */
 public function markAs($status)
 {
     if (!ArrayHelper::keyExists($status, self::statusNames())) {
         throw new \BadMethodCallException("{$status} not found in status_array");
     }
     $this->status = $status;
     $this->save();
 }
开发者ID:omeke,项目名称:yii2-papa,代码行数:12,代码来源:LeaveMessage.php

示例10: requiredCheck

 private function requiredCheck()
 {
     foreach ($this->_requiredOptions as $key) {
         if (!ArrayHelper::keyExists($key, $this->_playerOptions, false)) {
             throw new InvalidConfigException("JWPlayer Widget: player options missing '{$key}'");
         }
     }
 }
开发者ID:wadeshuler,项目名称:yii2-jwplayer,代码行数:8,代码来源:JWPlayer.php

示例11: getActiveUsers

 public static function getActiveUsers()
 {
     $array_ids = static::find()->select(['user_id'])->where('user_id > 0')->asArray()->all();
     $ids = \yii\helpers\ArrayHelper::getColumn($array_ids, 'user_id');
     $users = UserModels::find()->select(['id', 'username'])->where(['IN', 'id', $ids])->asArray()->all();
     if (!ArrayHelper::keyExists('0', $users, false)) {
         $users = [0 => ['id' => '0', 'username' => 'Ninguno']];
     }
     return $users;
 }
开发者ID:tecnologiaterabyte,项目名称:yii2-forum,代码行数:10,代码来源:UserOnline.php

示例12: jsonController

 /**
  * Возвращает ответ контроллера
  *
  * @param mixed $data возвращаемые данные
  *                    [
  *                    'status' => boolean
  *                    'data' => данные при положительном срабатывании или сообщение об ошибке
  *                    ]
  *
  * @return \yii\web\Response json
  */
 public function jsonController($data)
 {
     if ($data['status']) {
         if (ArrayHelper::keyExists('data', $data)) {
             return self::jsonSuccess($data['data']);
         } else {
             return self::jsonSuccess();
         }
     } else {
         return self::jsonError($data['data']);
     }
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:23,代码来源:BaseController.php

示例13: initSortable

 /**
  * Inits sortable behavior
  */
 protected function initSortable()
 {
     $route = ArrayHelper::getValue($this->sortable, 'url', false);
     if ($route) {
         $url = Url::toRoute($route);
         if (ArrayHelper::keyExists('class', $this->itemOptions)) {
             $this->itemOptions['class'] = sprintf('%s %s', $this->itemOptions['class'], self::SORTABLE_ITEM_CLASS);
         } else {
             $this->itemOptions['class'] = self::SORTABLE_ITEM_CLASS;
         }
         $options = json_encode(ArrayHelper::getValue($this->sortable, 'options', []));
         $view = $this->getView();
         $view->registerJs("jQuery('#{$this->id}').SortableListView('{$url}', {$options});");
         $view->registerJs("jQuery('#{$this->id}').on('sortableSuccess', function() {jQuery.pjax.reload(" . json_encode($this->clientOptions) . ")})", \yii\web\View::POS_END);
         ListViewSortableAsset::register($view);
     }
 }
开发者ID:ondiekijunior,项目名称:yii2-metronic,代码行数:20,代码来源:ListView.php

示例14: format

 /**
  * Formats response data in JSON format.
  * @link http://jsonapi.org/format/upcoming/#document-structure
  * @param Response $response
  */
 public function format($response)
 {
     $response->getHeaders()->set('Content-Type', 'application/vnd.api+json; charset=UTF-8');
     if ($response->data !== null) {
         $options = $this->encodeOptions;
         if ($this->prettyPrint) {
             $options |= JSON_PRETTY_PRINT;
         }
         if ($response->isClientError || $response->isServerError) {
             if (ArrayHelper::isAssociative($response->data)) {
                 $response->data = [$response->data];
             }
             $apiDocument = ['errors' => $response->data];
         } elseif (ArrayHelper::keyExists('data', $response->data)) {
             $apiDocument = $response->data;
         } else {
             $apiDocument = ['meta' => $response->data];
         }
         $response->content = Json::encode($apiDocument, $options);
     }
 }
开发者ID:tuyakhov,项目名称:yii2-json-api,代码行数:26,代码来源:JsonApiResponseFormatter.php

示例15: indexDataProvider

 public function indexDataProvider()
 {
     $params = \Yii::$app->request->queryParams;
     $model = new $this->modelClass();
     $modelAttr = $model->attributes;
     $order = isset($params['order']) ? ArrayHelper::keyExists($params['order'], $this->orderParams, false) ? $params['order'] : 'id' : 'id';
     $sort = isset($params['sort']) && ($params['sort'] = 'asc') ? 'ASC' : 'DESC';
     $search = [];
     if (!empty($params)) {
         foreach ($params as $key => $value) {
             if (!is_scalar($key) or !is_scalar($value)) {
                 throw new BadRequestHttpException('Bad Request');
             }
             if (!in_array(strtolower($key), $this->reservedParams) && ArrayHelper::keyExists($key, $modelAttr, false)) {
                 $search[$key] = $value;
             }
         }
     }
     //return $model->find()->where($search)->orderBy([$order => $sort])->limit(10)->all();
     return $model->find()->where($search)->orderBy($order . ' ' . $sort)->limit(20)->all();
 }
开发者ID:YGugnin,项目名称:Elb-v3,代码行数:21,代码来源:SingleController.php


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