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


PHP Arrays::associate方法代码示例

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


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

示例1: prepareRecipients

 /**
  * @param User $sender
  * @param array $usersByRestrictions
  * @return array
  */
 private function prepareRecipients(User $sender, array $usersByRestrictions)
 {
     if (empty($usersByRestrictions)) {
         return [];
     }
     unset($usersByRestrictions['suspendedUsers'][$sender->getId()], $usersByRestrictions['activeUsers'][$sender->getId()]);
     if (!$this->authorizator->isAllowed($sender, 'message', 'send_to_restricted_recipients')) {
         $recipients = array_diff_key($usersByRestrictions['activeUsers'], $usersByRestrictions['suspendedUsers'], $usersByRestrictions['usersBlockedByMe'], $usersByRestrictions['usersBlockingMe']);
     } else {
         $recipients = $usersByRestrictions['activeUsers'] + $usersByRestrictions['usersBlockedByMe'] + $usersByRestrictions['usersBlockingMe'];
     }
     return Arrays::associate($recipients, 'id=username');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:18,代码来源:RecipientsSelectBoxFactory.php

示例2: loadOptions

 /**
  * @return ArrayHash|null
  */
 public function loadOptions()
 {
     $options = $this->cache->load(Option::getCacheKey(), function () use(&$dependencies) {
         $options = $this->em->createQuery('SELECT o FROM ' . Option::class . ' o')->getArrayResult();
         if (empty($options)) {
             return null;
         }
         $options = ArrayHash::from(Arrays::associate($options, 'name=value'));
         $dependencies = [Cache::TAGS => Option::getCacheKey()];
         return $options;
     });
     return $options;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:16,代码来源:OptionFacade.php

示例3: generate

 public function generate($year, User $user, array $settings = [])
 {
     $listings = $this->listingsReader->getAnnualListingsForPDFGeneration($year, $user);
     $listings = Arrays::associate($listings, 'l_id');
     $items = $this->listingItemsReader->findListingsItems(array_keys($listings));
     $pdfFiles = [];
     $listingItemsCollection = [];
     /**
      * @var int $listingId
      * @var IListingPdfSource $pdfSource
      */
     foreach ($listings as $listingId => $listing) {
         foreach ($items as $key => $item) {
             if ($item->getListing()->getId() == $listingId) {
                 $listingItemsCollection[] = $item;
                 unset($items[$key]);
             }
         }
         $pdfFiles[] = $this->listingPdfGenerator->generate($listing, $listingItemsCollection, $settings);
         $listingItemsCollection = [];
     }
     $zipStorageFilePath = $this->storagePath . '/' . $user->getId() . '/' . $year . "/vycetky-{$year}.zip";
     return $this->zipFiles($pdfFiles, $zipStorageFilePath);
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:24,代码来源:AnnualPdfGenerator.php

示例4: fetchAssoc

 /**
  * @inheritDoc
  */
 public function fetchAssoc($path)
 {
     $rows = array_map('iterator_to_array', $this->fetchAll());
     return Nette\Utils\Arrays::associate($rows, $path);
 }
开发者ID:jave007,项目名称:test,代码行数:8,代码来源:Selection.php

示例5: fetchAssoc

 /**
  * @inheritDoc
  */
 public function fetchAssoc($path)
 {
     return Nette\Utils\Arrays::associate($this->fetchAll(), $path);
 }
开发者ID:nette,项目名称:database,代码行数:7,代码来源:ResultSet.php

示例6: findRestrictedUsers

 /**
  * Finds users that are blocked by or blocking given user
  *
  * @param User $user
  * @return array
  * @throws UserNotFoundException
  */
 public function findRestrictedUsers(User $user)
 {
     $result = $this->usersReader->getUserWithRestrictedRelationships($user);
     if (empty($result)) {
         return $result;
     }
     $resultArray = ['usersBlockedByMe' => Arrays::associate($result[0]['usersBlockedByMe'], 'id'), 'usersBlockingMe' => Arrays::associate($result[0]['usersBlockingMe'], 'id')];
     return $resultArray;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:16,代码来源:UsersFacade.php

示例7: getListingsYears

 /**
  * @param User|null $user
  * @return array
  */
 public function getListingsYears(User $user = null)
 {
     return Arrays::associate($this->listingsReader->getListingsYears($user), 'year');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:8,代码来源:ListingsFacade.php

示例8: render

 public function render()
 {
     $template = $this->getTemplate();
     $template->setFile(__DIR__ . '/template.latte');
     $paginator = $this['paginator']->getPaginator();
     if (empty($this->users)) {
         $usersResultSet = $this->usersFacade->fetchUsers($this->usersQuery);
         $usersResultSet->applyPaginator($paginator, 15);
         $this->users = Arrays::associate($usersResultSet->toArray(AbstractQuery::HYDRATE_ARRAY), 'id');
         unset($this->users[$this->userEntity->getId()]);
     }
     $template->users = $this->users;
     if (empty($this->alreadyBlockedUsers)) {
         $alreadyBlockedUsers = Arrays::associate($this->usersFacade->fetchUsers((new UsersOverviewQuery())->onlyWithFields(['id'])->findUsersBlockedBy($this->userEntity))->toArray(AbstractQuery::HYDRATE_ARRAY), 'id');
         $this->alreadyBlockedUsers = $alreadyBlockedUsers;
     }
     if ($this->userEntity->isInRole('admin') and empty($this->usersWithClosedAccount)) {
         $uwca = Arrays::associate($this->usersFacade->fetchUsers((new UsersOverviewQuery())->onlyWithFields(['id'])->findUsersWithClosedAccount())->toArray(AbstractQuery::HYDRATE_ARRAY), 'id');
         $this->usersWithClosedAccount = $uwca;
     }
     $template->areRelationshipsRestrictionsVisible = $this->areRelationshipsRestrictionsVisible;
     $template->isHintBoxVisible = $this->isHintBoxVisible;
     $template->render();
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:24,代码来源:UsersOverviewControl.php


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