mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-27 17:28:39 +00:00
Add filter to users management page
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
e1d64050ad
commit
c37515f880
17 changed files with 170 additions and 28 deletions
|
@ -10,6 +10,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\UserBundle\Form\SearchUserType;
|
||||
|
||||
/**
|
||||
* User controller.
|
||||
|
@ -146,4 +147,45 @@ class ManageController extends Controller
|
|||
->getForm()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param int $page
|
||||
*
|
||||
* @Route("/search/{page}", name="user-search", defaults={"page" = 1})
|
||||
*
|
||||
* Default parameter for page is hardcoded (in duplication of the defaults from the Route)
|
||||
* because this controller is also called inside the layout template without any page as argument
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function searchFormAction(Request $request, $page = 1, $currentRoute = null)
|
||||
{
|
||||
// fallback to retrieve currentRoute from query parameter instead of injected one (when using inside a template)
|
||||
if (null === $currentRoute && $request->query->has('currentRoute')) {
|
||||
$currentRoute = $request->query->get('currentRoute');
|
||||
}
|
||||
|
||||
$form = $this->createForm(SearchUserType::class);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->get('logger')->info('searching users');
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : '');
|
||||
|
||||
$users = $em->getRepository('WallabagUserBundle:User')->getUsersForSearch($searchTerm);
|
||||
|
||||
return $this->render('WallabagUserBundle:Manage:index.html.twig', array(
|
||||
'users' => $users,
|
||||
));
|
||||
}
|
||||
|
||||
return $this->render('WallabagUserBundle:Manage:search_form.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'currentRoute' => $currentRoute,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue