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