本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::getPrefs方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getPrefs方法的具体用法?PHP UserInterface::getPrefs怎么用?PHP UserInterface::getPrefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\User\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getPrefs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
/**
* @Route("/user/prefs/edit", name="editPrefsUser")
* @param UserInterface|User $user
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function editAction(UserInterface $user, Request $request)
{
$prefs = $user->getPrefs();
$form = $this->createForm(UserPrefsType::class, $prefs);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/* @var $translator \Symfony\Bundle\FrameworkBundle\Translation\Translator */
$translator = $this->get('translator');
$message = $translator->trans('prefs.saved', [], 'prefs');
$user->savePrefs($prefs);
$this->addFlash('success', $message);
return $this->redirectToRoute('viewPrefsUser');
}
return $this->render('@App/User/editPrefs.html.twig', array('form' => $form->createView()));
}
示例2: statsAction
/**
* @Route("{institutionCode}/{collectionCode}/stats/{page}", name="stats",defaults={ "page" = 1},
* requirements={"page": "\d+"})
* @param UserInterface|User $user
* @param string $institutionCode
* @param string $collectionCode
* @param int $page
* @return Response
*/
public function statsAction(UserInterface $user, $institutionCode, $collectionCode, $page = 1)
{
/** @var Prefs $prefs */
$prefs = $user->getPrefs();
$collection = $this->get('utility')->getCollection($institutionCode, $collectionCode, $user);
$statsManager = $this->get('statsmanager')->init($user, $collection);
list($statsBySimilarity, $catalogNumbers) = $statsManager->getStatsBySimilarity([], $prefs->getCsvDateFormat());
$sumStats = $statsManager->getSumStats();
$paginator = $this->get('knp_paginator');
/** @var AbstractPagination $pagination */
$pagination = $paginator->paginate($statsBySimilarity, $page, 100);
/* @var $exportManager \AppBundle\Manager\ExportManager */
$exportManager = $this->get('exportmanager')->init($user)->setCollection($collection);
$taxons = $exportManager->getDiffHandler()->getTaxons($catalogNumbers);
return $this->render('@App/Front/stats.html.twig', array('collection' => $collection, 'sumStats' => $sumStats, 'pagination' => $pagination, 'keyRecolnat' => AbstractDiff::KEY_RECOLNAT, 'keyInstitution' => AbstractDiff::KEY_INSTITUTION, 'taxons' => $taxons));
}