Repositories refactoring. TopUserDTO moved.

This commit is contained in:
Alexey Skobkin 2016-03-23 19:59:06 +03:00
parent 8f44a04989
commit 0f0700f87b
12 changed files with 18 additions and 13 deletions

View file

@ -3,7 +3,7 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Doctrine\ORM\EntityManager;
use Skobkin\Bundle\PointToolsBundle\Entity\TopUserDTO;
use Skobkin\Bundle\PointToolsBundle\DTO\TopUserDTO;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

View file

@ -1,6 +1,6 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
namespace Skobkin\Bundle\PointToolsBundle\DTO;
/**
* Data Transfer Object for top users list

View file

@ -14,7 +14,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* @ORM\Index(name="idx_post_created_at", columns={"created_at"}),
* @ORM\Index(name="idx_post_private", columns={"private"}),
* })
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostRepository")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository")
*/
class Post
{

View file

@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* @ORM\Table(name="posts.tags", schema="posts", indexes={
* @ORM\Index(name="idx_tag_text", columns={"text"})
* })
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\TagRepository")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\TagRepository")
*/
class Tag
{

View file

@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="subscriptions.subscriptions", schema="subscriptions", uniqueConstraints={
* @ORM\UniqueConstraint(name="subscription_unique", columns={"author_id", "subscriber_id"})}
* )
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionRepository")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository")
*/
class Subscription
{

View file

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Index(name="subscriber_idx", columns={"subscriber_id"}),
* @ORM\Index(name="date_idx", columns={"date"})
* })
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEventRepository")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository")
* @ORM\HasLifecycleCallbacks
*/
class SubscriptionEvent

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
* User
*
* @ORM\Table(name="users.users", schema="users")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Entity\UserRepository")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\UserRepository")
* @ORM\HasLifecycleCallbacks
*/
class User

View file

@ -1,6 +1,6 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
namespace Skobkin\Bundle\PointToolsBundle\Repository\Blogs;
use Doctrine\ORM\EntityRepository;

View file

@ -1,8 +1,9 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
namespace Skobkin\Bundle\PointToolsBundle\Repository\Blogs;
use Doctrine\ORM\EntityRepository;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag;
class TagRepository extends EntityRepository
{

View file

@ -1,9 +1,11 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
namespace Skobkin\Bundle\PointToolsBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadata;
use Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
class SubscriptionEventRepository extends EntityRepository
{

View file

@ -1,6 +1,6 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
namespace Skobkin\Bundle\PointToolsBundle\Repository;
use Doctrine\ORM\EntityRepository;

View file

@ -1,8 +1,10 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
namespace Skobkin\Bundle\PointToolsBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Skobkin\Bundle\PointToolsBundle\DTO\TopUserDTO;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
class UserRepository extends EntityRepository
{
@ -71,7 +73,7 @@ class UserRepository extends EntityRepository
$qb = $this->getEntityManager()->getRepository('SkobkinPointToolsBundle:Subscription')->createQueryBuilder('s');
return $qb
->select(['COUNT(s.subscriber) as cnt', 'NEW SkobkinPointToolsBundle:TopUserDTO(a.login, COUNT(s.subscriber))'])
->select(['COUNT(s.subscriber) as cnt', 'NEW Skobkin\Bundle\PointToolsBundle\DTO\TopUserDTO(a.login, COUNT(s.subscriber))'])
->innerJoin('s.author', 'a')
->orderBy('cnt', 'desc')
->groupBy('a.id')