本文整理汇总了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');
}
示例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;
}
示例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);
}
示例4: fetchAssoc
/**
* @inheritDoc
*/
public function fetchAssoc($path)
{
$rows = array_map('iterator_to_array', $this->fetchAll());
return Nette\Utils\Arrays::associate($rows, $path);
}
示例5: fetchAssoc
/**
* @inheritDoc
*/
public function fetchAssoc($path)
{
return Nette\Utils\Arrays::associate($this->fetchAll(), $path);
}
示例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;
}
示例7: getListingsYears
/**
* @param User|null $user
* @return array
*/
public function getListingsYears(User $user = null)
{
return Arrays::associate($this->listingsReader->getListingsYears($user), 'year');
}
示例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();
}