Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix paging on profile pages and order packages by name, fixes #222

  • Loading branch information...
commit f64dd402ef6887df725300b703f668e97007b96c 1 parent 8d879e9
@Seldaek Seldaek authored
View
4 app/Resources/FOSUserBundle/views/Profile/show.html.twig
@@ -18,8 +18,8 @@
{% endif %}
<h1>Your packages</h1>
- {% if user.packages|length %}
- {{ macros.listPackages(user.packages, null, true) }}
+ {% if packages|length %}
+ {{ macros.listPackages(packages, true, true) }}
{% else %}
<p>No packages found.</p>
{% endif %}
View
6 app/config/routing.yml
@@ -9,6 +9,12 @@ fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
+fos_user_profile_show:
+ pattern: /profile/
+ defaults: { _controller: PackagistWebBundle:User:myProfile }
+ requirements:
+ _method: GET
+
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
View
19 src/Packagist/WebBundle/Controller/UserController.php
@@ -19,6 +19,8 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;
+use FOS\UserBundle\Model\UserInterface;
+use Symfony\Component\Security\Core\Exception\AccessDeniedException;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
@@ -42,6 +44,20 @@ public function packagesAction(Request $req, $name)
return array('packages' => $this->getUserPackages($req, $user), 'user' => $user);
}
+ public function myProfileAction(Request $req)
+ {
+ $user = $this->container->get('security.context')->getToken()->getUser();
+ if (!is_object($user) || !$user instanceof UserInterface) {
+ throw new AccessDeniedException('This user does not have access to this section.');
+ }
+
+ return $this->container->get('templating')->renderResponse(
+ 'FOSUserBundle:Profile:show.html.'.$this->container->getParameter('fos_user.template.engine'),
+ array('user' => $user, 'packages' => $this->getUserPackages($req, $user))
+ );
+ }
+
+
/**
* @Template()
* @Route("/users/{name}/", name="user_profile")
@@ -63,7 +79,8 @@ protected function getUserPackages($req, $user)
{
$packages = $this->getDoctrine()
->getRepository('PackagistWebBundle:Package')
- ->getFilteredQueryBuilder(array('maintainer' => $user->getId()));
+ ->getFilteredQueryBuilder(array('maintainer' => $user->getId()))
+ ->orderBy('p.name');
$paginator = new Pagerfanta(new DoctrineORMAdapter($packages, true));
$paginator->setMaxPerPage(15);
View
2  src/Packagist/WebBundle/Resources/views/User/profile.html.twig
@@ -12,7 +12,7 @@
<p>Member since {{ user.createdAt|date('M d, Y') }}
<h2>Packages</h2>
{% if packages|length %}
- {{ macros.listPackages(packages) }}
+ {{ macros.listPackages(packages, true) }}
{% else %}
<p>No packages found.</p>
{% endif %}
Please sign in to comment.
Something went wrong with that request. Please try again.