Skip to content

Commit 6e28315

Browse files
committed
Merge pull request #9 from maartenJacobs/profile-routes-with-numeric-usernames
Fix for #8: removing the generic find-method
2 parents d2b9c57 + b4aa242 commit 6e28315

5 files changed

Lines changed: 11 additions & 34 deletions

File tree

Component/Dashboard/DashboardIntegrator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public function build(BuilderInterface $builder)
8383
->end()
8484
->end()
8585
->addLinks()
86-
->addLink('ccdn_user_profile_show')
86+
->addLink('ccdn_user_profile_show_by_id')
8787
->setAuthRole('ROLE_USER')
88-
->setRoute('ccdn_user_profile_show')
88+
->setRoute('ccdn_user_profile_show_by_id')
8989
->setIcon('/bundles/ccdncomponentcommon/images/icons/Black/32x32/32x32_user.png')
9090
->setLabel('dashboard.links.show_profile', array(), 'CCDNUserProfileBundle')
9191
->end()

Controller/ProfileController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function showOverviewAction($userId)
4747
$userId = $this->getUser()->getId();
4848
}
4949

50-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
50+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
5151

5252
return $this->renderResponse('CCDNUserProfileBundle:User:Profile/show_overview.html.', array(
5353
'crumbs' => $this->getCrumbs()->addProfileOverviewShow($user),
@@ -73,7 +73,7 @@ public function showBioAction($userId)
7373
$userId = $this->getUser()->getId();
7474
}
7575

76-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
76+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
7777

7878
return $this->renderResponse('CCDNUserProfileBundle:User:Profile/show_bio.html.', array(
7979
'crumbs' => $this->getCrumbs()->addProfileBioShow($user),
@@ -96,7 +96,7 @@ public function editPersonalAction($userId)
9696
$userId = $this->getUser()->getId();
9797
}
9898

99-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
99+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
100100

101101
// Does the requested $user match our session user id? Or, are we an admin?
102102
if ($user->getId() != $this->getUser()->getId()) {
@@ -135,7 +135,7 @@ public function editInfoAction($userId)
135135
$userId = $this->getUser()->getId();
136136
}
137137

138-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
138+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
139139

140140
// Does the requested $user match our session user id? Or, are we an admin?
141141
if ($user->getId() != $this->getUser()->getId()) {
@@ -174,7 +174,7 @@ public function editContactAction($userId)
174174
$userId = $this->getUser()->getId();
175175
}
176176

177-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
177+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
178178

179179
// Does the requested $user match our session user id? Or, are we an admin?
180180
if ($user->getId() != $this->getUser()->getId()) {
@@ -213,7 +213,7 @@ public function editAvatarAction($userId)
213213
$userId = $this->getUser()->getId();
214214
}
215215

216-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
216+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
217217

218218
// Does the requested $user match our session user id? Or, are we an admin?
219219
if ($user->getId() != $this->getUser()->getId()) {
@@ -252,7 +252,7 @@ public function editBioAction($userId)
252252
$userId = $this->getUser()->getId();
253253
}
254254

255-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
255+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
256256

257257
// Does the requested $user match our session user id? Or, are we an admin?
258258
if ($user->getId() != $this->getUser()->getId()) {
@@ -291,7 +291,7 @@ public function editSignatureAction($userId)
291291
$userId = $this->getUser()->getId();
292292
}
293293

294-
$user = $this->getUserModel()->findOneUserWithProfile($userId);
294+
$user = $this->getUserModel()->findOneUserWithProfileById($userId);
295295

296296
// Does the requested $user match our session user id? Or, are we an admin?
297297
if ($user->getId() != $this->getUser()->getId()) {

Model/FrontModel/UserModel.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,6 @@ public function findAllUsersWithProfileFilteredAtoZPaginated($alpha, $page = 1,
6969
return $pager;
7070
}
7171

72-
/**
73-
*
74-
* @access public
75-
* @param int $userId
76-
* @return \Symfony\Component\Security\Core\User\UserInterface
77-
*/
78-
public function findOneUserWithProfile($userId)
79-
{
80-
if (is_numeric($userId)) {
81-
$user = $this->findOneUserWithProfileById($userId);
82-
} else {
83-
$user = $this->findOneUserWithProfileByUsername($userId);
84-
}
85-
86-
return $user;
87-
}
88-
8972
/**
9073
*
9174
* @access public

Resources/config/routing/user-profile.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#
22
# Profile.
33
#
4-
ccdn_user_profile_show:
5-
pattern: /
6-
defaults: { _controller: CCDNUserProfileBundle:Profile:showOverview, userId: 0, _locale: en }
7-
8-
94
ccdn_user_profile_show_by_id:
105
pattern: /{userId}
116
defaults: { _controller: CCDNUserProfileBundle:Profile:showOverview, userId: 0, _locale: en }

Resources/views/Common/Layout/Sidebar/profile_sidebar.html.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
<ul class="nav nav-pills nav-stacked">
55

6-
{%- if route == 'ccdn_user_profile_show'
7-
or route == 'ccdn_user_profile_show_by_id'
6+
{%- if route == 'ccdn_user_profile_show_by_id'
87
or route == 'ccdn_user_profile_personal_edit'
98
or route == 'ccdn_user_profile_info_edit'
109
or route == 'ccdn_user_profile_contact_edit'

0 commit comments

Comments
 (0)