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


PHP helpers\ArrayHelper类代码示例

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


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

示例1: toArray

 public function toArray()
 {
     $response = [];
     $response['status'] = $this->status;
     $response['table'] = [];
     $response['chart'] = [];
     if ($response['status'] == static::STATUS_SUCCESS) {
         if ($this->caption) {
             $response['caption'] = $this->caption;
         }
         foreach ($this->data as $key => $row) {
             $tableRow = [];
             $chartRow = [];
             foreach ($this->dataSeries as $s) {
                 if ($s->value !== null) {
                     $value = call_user_func($s->value, $row, $key);
                 } else {
                     $value = ArrayHelper::getValue($row, $s->name);
                 }
                 $value = $s->encode ? Html::encode($value) : $value;
                 $tableRow[] = $value;
                 if ($s->isInChart) {
                     $chartRow[] = $value;
                 }
             }
             $response['table'][] = $tableRow;
             $response['chart'][] = $chartRow;
         }
     } else {
         $response['message'] = $this->message;
     }
     return $response;
 }
开发者ID:thrieu,项目名称:yii2-statreport,代码行数:33,代码来源:Response.php

示例2: fail

 /**
  * Returns fail response
  * @param integer $code
  * @param array $data
  * @return \yii\web\Response
  */
 public static function fail($code = 400, array $data = [])
 {
     $resp = \Yii::$app->response;
     $resp->setStatusCode($code);
     $resp->data = ArrayHelper::merge(['status' => 'error', 'message' => static::$httpStatuses[$code]], $data);
     return $resp;
 }
开发者ID:VictorGub,项目名称:yii2-swagger,代码行数:13,代码来源:Response.php

示例3: __construct

 public function __construct($config = array())
 {
     self::$plugins = array_diff(scandir(__DIR__ . '/plugins/'), array('..', '.'));
     $provider = ArrayHelper::getValue($config, 'config.provider');
     if (isset($provider)) {
         if (ArrayHelper::isIn($provider . '.php', self::$plugins)) {
             require __DIR__ . '/plugins/' . $provider . '.php';
             $format = ArrayHelper::getValue($config, 'config.return_formats');
             if (isset($format)) {
                 if (ArrayHelper::isIn($format, ArrayHelper::getValue($plugin, 'accepted_formats'))) {
                     self::$return_formats = $format;
                 } else {
                     self::$return_formats = ArrayHelper::getValue($plugin, 'default_accepted_format');
                 }
             }
             self::$provider = $plugin;
             self::$api_key = ArrayHelper::getValue($config, 'config.api_key', NULL);
         } else {
             throw new HttpException(404, 'The requested Item could not be found.');
         }
     } else {
         require __DIR__ . '/plugins/geoplugin.php';
         self::$provider = $plugin;
         self::$return_formats = $plugin['default_accepted_format'];
     }
     return parent::__construct($config);
 }
开发者ID:indicalabs,项目名称:yii2-geolocation,代码行数:27,代码来源:Geolocation.php

示例4: map

 public static function map($tipo)
 {
     //entrada ou saida
     $tipo = self::find()->where(['tipo' => $tipo])->asArray()->all();
     $tipoMap = ArrayHelper::map($tipo, 'id', 'descricao');
     return $tipoMap;
 }
开发者ID:alissoncti,项目名称:sgo,代码行数:7,代码来源:CaixaMovimentacaoTipo.php

示例5: renderButtonAdd

 protected function renderButtonAdd()
 {
     Html::addCssClass($this->buttonOptions, 'btn');
     $this->buttonOptions = ArrayHelper::merge($this->buttonOptions, ['role' => 'area.add', 'data-tmpl' => $this->options['id']]);
     $templateButtonAdding = strtr($this->templateButtonAdding, ['{button}' => Html::button('+', $this->buttonOptions), '{label}' => Html::tag('label', $this->label)]);
     echo Html::tag('div', $templateButtonAdding, ['class' => 'form-group']);
 }
开发者ID:sanchezzzhak,项目名称:kak-area,代码行数:7,代码来源:Area.php

示例6: FetchProducts

 public static function FetchProducts()
 {
     $sql = 'SELECT * FROM easyii_catalog_items where category_id=2';
     $allProducts = Item::findBySql($sql)->all();
     $listData = ArrayHelper::map($allProducts, 'item_code', 'title');
     return $listData;
 }
开发者ID:engmohamedamer,项目名称:testone,代码行数:7,代码来源:Products.php

示例7: run

 public function run()
 {
     $rr = new RequestResponse();
     $pk = \Yii::$app->request->post($this->controller->requestPkParamName);
     $modelClass = $this->controller->modelClassName;
     $this->models = $modelClass::find()->where([$this->controller->modelPkAttribute => $pk])->all();
     if (!$this->models) {
         $rr->success = false;
         $rr->message = \Yii::t('app', "No records found");
         return (array) $rr;
     }
     $data = [];
     foreach ($this->models as $model) {
         $raw = [];
         if ($this->eachExecute($model)) {
             $data['success'] = ArrayHelper::getValue($data, 'success', 0) + 1;
         } else {
             $data['errors'] = ArrayHelper::getValue($data, 'errors', 0) + 1;
         }
     }
     $rr->success = true;
     $rr->message = \Yii::t('app', "Mission complete");
     $rr->data = $data;
     return (array) $rr;
 }
开发者ID:Liv1020,项目名称:cms,代码行数:25,代码来源:AdminMultiModelEditAction.php

示例8: registerKCFinder

 /**
  * Registers KCFinder
  */
 protected function registerKCFinder()
 {
     $register = KCFinderAsset::register($this->view);
     $kcfinderUrl = $register->baseUrl;
     $browseOptions = ['filebrowserBrowseUrl' => $kcfinderUrl . '/browse.php?opener=ckeditor&type=files', 'filebrowserUploadUrl' => $kcfinderUrl . '/upload.php?opener=ckeditor&type=files'];
     $this->clientOptions = ArrayHelper::merge($browseOptions, $this->clientOptions);
 }
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:10,代码来源:CKEditor.php

示例9: getDropdownList

 /**
  * Get all authors for dropdownlist widget
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function getDropdownList()
 {
     $authors = self::find()->all();
     $authors = \yii\helpers\ArrayHelper::map($authors, 'id', 'fullName');
     array_unshift($authors, '');
     return $authors;
 }
开发者ID:sedpro,项目名称:yii2-test-app,代码行数:11,代码来源:Author.php

示例10: renderItems

 /**
  * Recursively renders the menu items (without the container tag).
  * @param array $items the menu items to be rendered recursively
  * @return string the rendering result
  */
 protected function renderItems($items)
 {
     $n = count($items);
     $lines = [];
     foreach ($items as $i => $item) {
         $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
         $tag = ArrayHelper::remove($options, 'tag', 'li');
         $class = [];
         if ($item['active']) {
             $class[] = $this->activeCssClass;
         }
         if ($i === 0 && $this->firstItemCssClass !== null) {
             $class[] = $this->firstItemCssClass;
         }
         if ($i === $n - 1 && $this->lastItemCssClass !== null) {
             $class[] = $this->lastItemCssClass;
         }
         if (!empty($class)) {
             if (empty($options['class'])) {
                 $options['class'] = implode(' ', $class);
             } else {
                 $options['class'] .= ' ' . implode(' ', $class);
             }
         }
         $menu = $this->renderItem($item);
         if (!empty($item['items'])) {
             $menu .= strtr($this->submenuTemplate, ['{show}' => $item['active'] ? "style='display: block'" : '', '{items}' => $this->renderItems($item['items'])]);
         }
         $lines[] = Html::tag($tag, $menu, $options);
     }
     return implode("\n", $lines);
 }
开发者ID:WittayaSi,项目名称:yii2-tak,代码行数:37,代码来源:Menu.php

示例11: actionStock

 public function actionStock()
 {
     $debug = '';
     $model = new DynamicModel(['vins', 'diller']);
     $model->addRule('vins', 'string')->addRule('diller', 'integer')->addRule(['diller', 'vins'], 'required');
     $list = ArrayHelper::map(Mod\cats\Stock::find()->all(), 'id', 'name');
     $prompt = Yii::t('app', 'Select stock');
     $arrError = [];
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $arrvin = explode("\n", $model->vins);
         foreach ($arrvin as $vin) {
             if ($car = Mod\Car::findOne(['vin' => trim($vin)])) {
                 $status = Mod\CarStatus::findOne(['car_id' => $car->id]);
                 $status->stock_id = $model->diller;
                 $status->save();
             } else {
                 $arrError[] = $vin . ' не найден VIN';
             }
         }
         //			$debug = print_r($arrError, true);
         $debug = implode('<br>', $arrError);
         return $this->render('finish', ['debug' => $debug]);
     }
     $arrVars = ['model' => $model, 'list' => $list, 'prompt' => $prompt, 'selLabel' => 'Склад', 'title' => 'Пакетное перемещение'];
     return $this->render('index', $arrVars);
 }
开发者ID:Ent-ch,项目名称:stock_auto,代码行数:26,代码来源:PaketController.php

示例12: instance

 /**
  * @param Tree $model
  * @param array $data
  * @return static
  */
 public static function instance($model, $data = [])
 {
     if ($package = ArrayHelper::getValue(static::$instances, $model->id)) {
         return $package;
     }
     return new static($model, $data);
 }
开发者ID:Liv1020,项目名称:cms,代码行数:12,代码来源:CmsTreeHelper.php

示例13: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $sort = $dataProvider->getSort();
     $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Имя офиса'];
     $dataProvider->setSort($sort);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         $query->joinWith(['questionlist_office']);
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     if ($this->roleName) {
         $this->profile_office_role = $this->roleName;
     }
     $query->andFilterWhere(['like', 'profile_id', $this->profile_id])->andFilterWhere(['like', 'profile_office_role', $this->profile_office_role]);
     if ($this->scenario == 'managerSearch') {
         $userRoles = Users::findAll(['profile_id' => Yii::$app->user->identity->username, 'profile_office_role' => 'commercial_director']);
         $userRegions = array_values(ArrayHelper::map($userRoles, 'region_id', 'region_id'));
         $query->andFilterWhere(['like', 'profile_office_role', 'manager']);
         $query->andFilterWhere(['in', 'questionlist_users_offices.region_id', $userRegions]);
     }
     $query->joinWith(['office' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]);
     }]);
     $query->joinWith(['region' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_region.name', $this->regionName]);
     }]);
     return $dataProvider;
 }
开发者ID:igribov,项目名称:question-list,代码行数:40,代码来源:UsersSearch.php

示例14: setThumbnailSettings

 public function setThumbnailSettings(array $config)
 {
     $params = ['width', 'height', 'mode'];
     foreach ($params as $param) {
         $this->_thumbnailSettings[$param] = ArrayHelper::getValue($config, $param, null);
     }
 }
开发者ID:secondsano,项目名称:mebel,代码行数:7,代码来源:ImageFilter.php

示例15: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     /**
      * @var Module $m
      */
     $m = Yii::$app->getModule('user');
     if (!$m->getRegistrationSetting('randomUsernames', $this->userType)) {
         $this->attributes['username'] = ['type' => Form::INPUT_TEXT, 'options' => ['autocomplete' => 'new-username']];
     }
     if (!$m->getRegistrationSetting('randomPasswords', $this->userType)) {
         $password = ['type' => Form::INPUT_PASSWORD];
         if (in_array(Module::SCN_REGISTER, $m->passwordSettings['strengthMeter'])) {
             $password = ['type' => Form::INPUT_WIDGET, 'widgetClass' => PasswordInput::classname(), 'options' => ['options' => ['placeholder' => Yii::t('user', 'Password'), 'autocomplete' => 'off']]];
         }
         $this->attributes['password'] = $password;
     }
     $this->attributes['email'] = ['type' => Form::INPUT_TEXT];
     $captcha = ArrayHelper::getValue($m->registrationSettings, 'captcha', false);
     if ($captcha !== false && is_array($captcha)) {
         $this->attributes['captcha'] = ['type' => Form::INPUT_WIDGET, 'widgetClass' => Captcha::classname(), 'options' => $captcha['widget']];
     }
     parent::init();
     unset($this->attributes['rememberMe']);
     $this->leftFooter = $m->button(Module::BTN_HOME) . $m->button(Module::BTN_ALREADY_REGISTERED);
     $this->rightFooter = $m->button(Module::BTN_RESET_FORM) . ' ' . $m->button(Module::BTN_REGISTER);
 }
开发者ID:communityii,项目名称:yii2-user,代码行数:29,代码来源:RegistrationForm.php


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