Search from index page.
This commit is contained in:
parent
ce0b6e856f
commit
58f8db6c97
|
@ -9,6 +9,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\TopUserDTO;
|
|||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
@ -72,4 +73,17 @@ class UserController extends Controller
|
|||
'top_users' => $topUsers
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
public function searchUserAction(Request $request)
|
||||
{
|
||||
$login = $request->request->get('login');
|
||||
|
||||
if (!$login) {
|
||||
throw new \InvalidArgumentException('No login information present');
|
||||
}
|
||||
return $this->redirectToRoute('user_show', ['login' => $login]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@ index:
|
|||
path: /
|
||||
defaults: { _controller: SkobkinPointToolsBundle:Main:index }
|
||||
|
||||
user_search:
|
||||
path: /search
|
||||
defaults: { _controller: SkobkinPointToolsBundle:User:searchUser }
|
||||
methods: [POST]
|
||||
|
||||
user_show:
|
||||
path: /user/{login}
|
||||
defaults: { _controller: SkobkinPointToolsBundle:User:show }
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="well well-lg">
|
||||
<form class="form-inline">
|
||||
{# @todo rewrite to Symfony forms #}
|
||||
<form class="form-inline" method="post" action="{{ url('user_search') }}">
|
||||
<div class="form-group">
|
||||
<label class="sr-only" for="index-input-username">Username</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">@</div>
|
||||
<input type="text" class="form-control" id="index-input-username" placeholder="username">
|
||||
<input name="login" type="text" class="form-control" id="index-input-username" placeholder="username">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
|
|
Loading…
Reference in a new issue