本文整理汇总了PHP中UserRepository::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::findAll方法的具体用法?PHP UserRepository::findAll怎么用?PHP UserRepository::findAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository::findAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleSave
public function handleSave(Form $form)
{
$values = $form->values;
if ($values['file']->isOk()) {
if ($values['cleanout']) {
foreach ($this->userRepository->findAll() as $user) {
$this->userRepository->delete($user);
}
}
/** @var FileUpload $file */
$file = $values['file'];
$data = file_get_contents($file->getTemporaryFile());
foreach (explode("\n", $data) as $row) {
if (!$row) {
continue;
}
$items = explode(',', $row);
if (!count($items)) {
continue;
}
try {
$user = new UserEntity(trim($items[0]));
} catch (InvalidArgumentException $e) {
$form->addError($e->getMessage());
}
$this->userRepository->save($user);
}
}
}
示例2: handleExport
public function handleExport()
{
$ret = array();
foreach ($this->repository->findAll() as $user) {
$ret[] = array($user->email, $user->userKey);
}
$out = "";
foreach ($ret as $arr) {
$out .= implode(',', $arr) . "\n";
}
header('Content-Type: application/csv, utf-8');
header('Content-Disposition: attachment;filename="users.csv"');
header('Cache-Control: max-age=0');
$this->presenter->sendResponse(new TextResponse($out));
}
示例3: sendNewsletter
/**
* @param MessageEntity $messageEntity
* @return int
*/
public function sendNewsletter(MessageEntity $messageEntity)
{
$newsletter = $messageEntity->newsletter;
/** @var NewsletterPresenter $presenter */
$presenter = $this->application->getPresenterFactory()->createPresenter('Vranovsko:Pages:Newsletter:Newsletter');
$presenter->autoCanonicalize = FALSE;
/** @var Message $message */
$message = $this->mailFactory->invoke();
$message->setSubject($newsletter->getSubject());
$x = 0;
foreach ($messageEntity->getAllUsers() ? $this->userRepository->findAll() : $messageEntity->users as $user) {
$presenter->setMessageUser($user);
$request = new \Nette\Application\Request('Vranovsko:Pages:Newsletter:Newsletter', 'GET', array('routeId' => $newsletter->route->id));
$response = $presenter->run($request);
$html = (string) $response->getSource();
$userMessage = clone $message;
$userMessage->addTo($user->email);
$userMessage->setHtmlBody($html, FALSE);
$userMessage->send();
$x++;
}
return $x;
}
示例4: getUsers
/**
* @return array
*/
public function getUsers()
{
return $this->repository->findAll();
}