Pagination of subscribers events on user page. KnpPaginatorBundle added.
This commit is contained in:
parent
dd0707c97a
commit
65cc08d91f
|
@ -21,6 +21,7 @@ class AppKernel extends Kernel
|
|||
new Misd\GuzzleBundle\MisdGuzzleBundle(),
|
||||
new Ob\HighchartsBundle\ObHighchartsBundle(),
|
||||
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
|
||||
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
|
||||
new Skobkin\Bundle\PointToolsBundle\SkobkinPointToolsBundle(),
|
||||
);
|
||||
|
||||
|
|
|
@ -86,3 +86,7 @@ swiftmailer:
|
|||
knp_markdown:
|
||||
parser:
|
||||
service: markdown.parser.point
|
||||
|
||||
knp_paginator:
|
||||
template:
|
||||
pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig
|
|
@ -23,7 +23,8 @@
|
|||
"ob/highcharts-bundle": "^1.2",
|
||||
"doctrine/doctrine-migrations-bundle": "^1.0",
|
||||
"jms/serializer-bundle": "^1.1",
|
||||
"knplabs/knp-markdown-bundle": "^1.4"
|
||||
"knplabs/knp-markdown-bundle": "^1.4",
|
||||
"knplabs/knp-paginator-bundle": "^2.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"sensio/generator-bundle": "~2.3",
|
||||
|
|
134
composer.lock
generated
134
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "15efa608e772ff5c6381daec33cf9114",
|
||||
"content-hash": "730ff4da78d65c53b95f3a273c73c89b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -1319,6 +1319,77 @@
|
|||
],
|
||||
"time": "2015-11-10T12:26:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "knplabs/knp-components",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/KnpLabs/knp-components.git",
|
||||
"reference": "f98bcc6d348fbe863a224b468e11fb5e91e28f2a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/KnpLabs/knp-components/zipball/f98bcc6d348fbe863a224b468e11fb5e91e28f2a",
|
||||
"reference": "f98bcc6d348fbe863a224b468e11fb5e91e28f2a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/mongodb-odm": "~1.0@beta",
|
||||
"doctrine/orm": "~2.4",
|
||||
"doctrine/phpcr-odm": "~1.2",
|
||||
"jackalope/jackalope-doctrine-dbal": "~1.2",
|
||||
"phpunit/phpunit": "~4.2",
|
||||
"ruflin/elastica": "~1.0",
|
||||
"symfony/event-dispatcher": "~2.5"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/common": "to allow usage pagination with Doctrine ArrayCollection",
|
||||
"doctrine/mongodb-odm": "to allow usage pagination with Doctrine ODM MongoDB",
|
||||
"doctrine/orm": "to allow usage pagination with Doctrine ORM",
|
||||
"doctrine/phpcr-odm": "to allow usage pagination with Doctrine ODM PHPCR",
|
||||
"propel/propel1": "to allow usage pagination with Propel ORM",
|
||||
"ruflin/Elastica": "to allow usage pagination with ElasticSearch Client",
|
||||
"solarium/solarium": "to allow usage pagination with Solarium Client"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Knp\\Component": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "KnpLabs Team",
|
||||
"homepage": "http://knplabs.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://github.com/KnpLabs/knp-components/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Knplabs component library",
|
||||
"homepage": "http://github.com/KnpLabs/knp-components",
|
||||
"keywords": [
|
||||
"components",
|
||||
"knp",
|
||||
"knplabs",
|
||||
"pager",
|
||||
"paginator"
|
||||
],
|
||||
"time": "2016-12-06T18:10:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "knplabs/knp-markdown-bundle",
|
||||
"version": "1.4.2",
|
||||
|
@ -1380,6 +1451,67 @@
|
|||
],
|
||||
"time": "2015-12-15T20:41:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "knplabs/knp-paginator-bundle",
|
||||
"version": "2.5.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/KnpLabs/KnpPaginatorBundle.git",
|
||||
"reference": "c988761005504007c6c87d6a557641281194a0e5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/KnpLabs/KnpPaginatorBundle/zipball/c988761005504007c6c87d6a557641281194a0e5",
|
||||
"reference": "c988761005504007c6c87d6a557641281194a0e5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"knplabs/knp-components": "~1.2",
|
||||
"php": ">=5.3.3",
|
||||
"symfony/framework-bundle": "~2.3|~3.0",
|
||||
"twig/twig": "~1.12|~2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/expression-language": "~2.4|~3.0"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Knp\\Bundle\\PaginatorBundle\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "KnpLabs Team",
|
||||
"homepage": "http://knplabs.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony2 Community",
|
||||
"homepage": "http://github.com/KnpLabs/KnpPaginatorBundle/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Paginator bundle for Symfony2 to automate pagination and simplify sorting and other features",
|
||||
"homepage": "http://github.com/KnpLabs/KnpPaginatorBundle",
|
||||
"keywords": [
|
||||
"Symfony2",
|
||||
"bundle",
|
||||
"knp",
|
||||
"knplabs",
|
||||
"pager",
|
||||
"pagination",
|
||||
"paginator"
|
||||
],
|
||||
"time": "2016-04-20T11:40:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "kriswallsmith/assetic",
|
||||
"version": "v1.3.0",
|
||||
|
|
|
@ -15,7 +15,7 @@ class UserController extends Controller
|
|||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function showAction($login)
|
||||
public function showAction(Request $request, $login)
|
||||
{
|
||||
/** @var EntityManager $em */
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
@ -27,12 +27,20 @@ class UserController extends Controller
|
|||
throw $this->createNotFoundException('User ' . $login . ' not found.');
|
||||
}
|
||||
|
||||
$paginator = $this->get('knp_paginator');
|
||||
|
||||
$subscriberEventsPagination = $paginator->paginate(
|
||||
$em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->createUserLastSubscribersEventsQuery($user),
|
||||
$request->query->getInt('page', 1),
|
||||
10
|
||||
);
|
||||
|
||||
$userApi = $this->container->get('skobkin_point_tools.api_user');
|
||||
|
||||
return $this->render('SkobkinPointToolsBundle:User:show.html.twig', [
|
||||
'user' => $user,
|
||||
'subscribers' => $em->getRepository('SkobkinPointToolsBundle:User')->findUserSubscribersById($user->getId()),
|
||||
'subscriptions_log' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getUserLastSubscribersEventsById($user, 10),
|
||||
'subscriptions_log' => $subscriberEventsPagination,
|
||||
'rename_log' => $em->getRepository('SkobkinPointToolsBundle:UserRenameEvent')->findBy(['user' => $user], ['date' => 'DESC'], 10),
|
||||
'avatar_url' => $userApi->getAvatarUrl($user, UserApi::AVATAR_SIZE_LARGE),
|
||||
]);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Skobkin\Bundle\PointToolsBundle\Repository;
|
|||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent;
|
||||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||
|
||||
|
@ -27,16 +28,14 @@ class SubscriptionEventRepository extends EntityRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates QueryBuilder object for pagination of user subscribers events
|
||||
*
|
||||
* @param User $user
|
||||
* @param integer $limit
|
||||
* @return SubscriptionEvent[]
|
||||
*
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function getUserLastSubscribersEventsById(User $user, $limit)
|
||||
public function createUserLastSubscribersEventsQuery(User $user)
|
||||
{
|
||||
if (!is_int($limit)) {
|
||||
throw new \InvalidArgumentException('$limit must be an integer');
|
||||
}
|
||||
|
||||
$qb = $this->createQueryBuilder('se');
|
||||
|
||||
return $qb
|
||||
|
@ -44,9 +43,7 @@ class SubscriptionEventRepository extends EntityRepository
|
|||
->join('se.subscriber', 's')
|
||||
->where('se.author = :author')
|
||||
->orderBy('se.date', 'desc')
|
||||
->setMaxResults($limit)
|
||||
->setParameter('author', $user)
|
||||
->getQuery()->getResult()
|
||||
->setParameter('author', $user->getId())
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
# Russian language for Point tools
|
||||
|
||||
# Шапка
|
||||
# Header
|
||||
Toggle navigation: Переключить навигацию
|
||||
Main: Главная
|
||||
Top: Топ
|
||||
Report a bug: Сообщить об ошибке
|
||||
Last: Последнее
|
||||
|
||||
# Подвал
|
||||
# Footer
|
||||
Source code: Исходный код
|
||||
|
||||
# Главная
|
||||
# Pagination
|
||||
Previous: Предыдущая
|
||||
Next: Следующая
|
||||
|
||||
# Index page
|
||||
All users: Всего пользователей
|
||||
Subscribed users: Подписчиков сервиса
|
||||
24 hours events: Событий за сутки
|
||||
|
@ -21,7 +25,7 @@ Last events: Последние события
|
|||
Username: Имя пользователя
|
||||
Search: Поиск
|
||||
|
||||
# Страница пользователя
|
||||
# User page
|
||||
Subscribers: Подписчики
|
||||
Subscriptions log: Лог подписок
|
||||
User: Пользователь
|
||||
|
@ -35,10 +39,10 @@ No subscribers data found: Информация о подписчиках отс
|
|||
No rename log data found: Лог переименований отсутствует
|
||||
No subscribers log data found: Лог подписчиков отсутствует
|
||||
|
||||
# Страница поста
|
||||
# Post page
|
||||
in response to: в ответ на
|
||||
|
||||
# Топ пользователей
|
||||
# Top page
|
||||
Top users: Популярные пользователи
|
||||
Subscribers count: Подписчиков
|
||||
amount: Количество
|
|
@ -79,18 +79,9 @@
|
|||
</div>
|
||||
|
||||
<div class="user-subscriptions-log">
|
||||
<h3>{{ 'Subscriptions log'|trans }}</h3>
|
||||
|
||||
{% if subscriptions_log|length > 0 %}
|
||||
<div class="panel-group" id="accordion-log">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" id="heading-subscriptions-log">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion-log" aria-expanded="true" href="#collapse-log">
|
||||
<span class="glyphicon glyphicon-collapse-down"></span> {{ 'Subscriptions log'|trans }}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse-log" class="panel-collapse collapse in" aria-labelledby="heading-subscriptions-log">
|
||||
<div class="panel-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -116,13 +107,13 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">{{ 'No subscribers log data found'|trans }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="navigation">
|
||||
{{ knp_pagination_render(subscriptions_log) }}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue