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


PHP User::loadMultiple方法代码示例

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


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

示例1: getCheckedOutUsers

 public function getCheckedOutUsers()
 {
     $users = User::loadMultiple();
     $checked_in_users = $this->getCheckedInUsers();
     $result = array();
     // Unset checked in users.
     foreach ($checked_in_users as $user) {
         unset($users[$user['uid']]);
     }
     // Set up result array.
     foreach ($users as $key => $user) {
         $uid = $user->id();
         if (!in_array($uid, array(0, 1))) {
             $account = User::load($uid);
             // Exclude users with some statuses.
             // (vacation, sick, day_off, business_trip).
             if (!in_array($account->field_user_status->value, $this->getExcludedUserStatuses())) {
                 $result[$key]['uid'] = $uid;
                 $result[$key]['field_first_name'] = $account->field_first_name->value;
                 $result[$key]['field_last_name'] = $account->field_last_name->value;
                 $result[$key]['field_image'] = $account->user_picture->target_id ? file_create_url(File::load($account->user_picture->target_id)->uri->value) : NULL;
             }
         }
     }
     return $result;
 }
开发者ID:lokeoke,项目名称:d8intranet,代码行数:26,代码来源:IntranetHelperServicesApi.php

示例2: view

 public function view(Request $request)
 {
     $users = User::loadMultiple();
     var_dump($users);
     foreach ($users as &$user) {
         $user->status = ['day_off' => 0, 'sick' => 1, 'business_trip' => 0, 'remote_work' => 1, 'vacation' => 0];
     }
     return new JsonResponse(['users' => $users]);
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:9,代码来源:UsersStatusController.php

示例3: valueForm

 protected function valueForm(&$form, FormStateInterface $form_state)
 {
     $users = $this->value ? User::loadMultiple($this->value) : array();
     $default_value = EntityAutocomplete::getEntityLabels($users);
     $form['value'] = array('#type' => 'entity_autocomplete', '#title' => $this->t('Usernames'), '#description' => $this->t('Enter a comma separated list of user names.'), '#target_type' => 'user', '#tags' => TRUE, '#default_value' => $default_value, '#process_default_value' => FALSE);
     $user_input = $form_state->getUserInput();
     if ($form_state->get('exposed') && !isset($user_input[$this->options['expose']['identifier']])) {
         $user_input[$this->options['expose']['identifier']] = $default_value;
         $form_state->setUserInput($user_input);
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:Name.php

示例4: fetch

 public function fetch()
 {
     $query = $this->getQuery();
     $result = $query->execute();
     if ($this->entityType === 'user') {
         // ugly fix for custom fields on User
         return empty($result) ? array() : \Drupal\user\Entity\User::loadMultiple($result);
     } else {
         $store = \Drupal::entityManager()->getStorage($this->entityType);
         return empty($result) ? array() : $store->loadMultiple($result);
     }
 }
开发者ID:pjcarly,项目名称:drupal8-spectrum,代码行数:12,代码来源:Query.php

示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $header = array('username' => array('data' => t('Username'), 'field' => 'u.name'), 'status' => array('data' => t('Status'), 'field' => 'u.status'));
     $query = db_select('users_field_data', 'u');
     $query->condition('u.uid', 0, '<>');
     $query->condition('u.default_langcode', 1);
     $count_query = clone $query;
     $count_query->addExpression('COUNT(u.uid)');
     $query = $query->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')->extend('Drupal\\Core\\Database\\Query\\TableSortExtender');
     $query->fields('u', array('uid'))->limit(50)->orderByHeader($header)->setCountQuery($count_query);
     $uids = $query->execute()->fetchCol();
     $options = array();
     foreach (User::loadMultiple($uids) as $account) {
         $options[$account->id()] = array('title' => array('data' => array('#title' => $account->getUsername())), 'username' => $account->getUsername(), 'status' => $account->isActive() ? t('active') : t('blocked'));
     }
     $form['accounts'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => t('No people available.'));
     return $form;
 }
开发者ID:318io,项目名称:318-io,代码行数:21,代码来源:DatabaseTestForm.php

示例6: loadMultiple

 /**
  * {@inheritdoc}
  */
 public static function loadMultiple(array $ids = NULL)
 {
     return User::loadMultiple($ids);
 }
开发者ID:mosswoodcreative,项目名称:d8-api-test,代码行数:7,代码来源:TokenAuthUser.php

示例7: destroyTestUser

 /**
  * Destroy a user that matches a test user name.
  *
  * @param $role
  * @return $this
  */
 public function destroyTestUser($role)
 {
     $this->output->writeln("deleting test{$role}User...");
     $users = \Drupal::entityQuery('user')->condition("name", "test{$role}User")->execute();
     $users = User::loadMultiple($users);
     foreach ($users as $user) {
         $user->delete();
     }
     return $this;
 }
开发者ID:dustinleblanc,项目名称:codeception-drupal-8,代码行数:16,代码来源:Drupal8.php

示例8: processSummaryArguments

 /**
  * {@inheritdoc}
  */
 public function processSummaryArguments(&$args)
 {
     // If the validation says the input is an username, we should reverse the
     // argument so it works for example for generation summary urls.
     $uids_arg_keys = array_flip($args);
     if ($this->options['type'] == 'name') {
         $users = User::loadMultiple($args);
         foreach ($users as $uid => $account) {
             $args[$uids_arg_keys[$uid]] = $account->name;
         }
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:15,代码来源:CurrentUserOrPermission.php


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