@@ -396,9 +396,8 @@ First example:
396
396
namespace App\R epository;
397
397
398
398
use App\E ntity\B ook;
399
- use App\E ntity\U ser;
400
399
use Doctrine\B undle\D octrineBundle\R epository\S erviceEntityRepository;
401
- use Doctrine\O RM \E ntityManagerInterface ;
400
+ use Doctrine\C ommon \P ersistence \M anagerRegistry ;
402
401
use Symfony\C omponent\S ecurity\C ore\A uthentication\T oken\S torage\T okenStorageInterface;
403
402
use Doctrine\O RM\T ools\P agination\P aginator as DoctrinePaginator;
404
403
use ApiPlatform\C ore\B ridge\D octrine\O rm\P aginator;
@@ -407,21 +406,21 @@ use Doctrine\Common\Collections\Criteria;
407
406
class BookRepository extends ServiceEntityRepository
408
407
{
409
408
const ITEMS_PER_PAGE = 20;
410
-
409
+
411
410
private $tokenStorage;
412
-
411
+
413
412
public function __construct(
414
- RegistryInterface $registry,
413
+ ManagerRegistry $registry,
415
414
TokenStorageInterface $tokenStorage
416
415
) {
417
416
$this->tokenStorage = $tokenStorage;
418
417
parent::__construct($registry, Book::class);
419
418
}
420
-
419
+
421
420
public function getBooksByFavoriteAuthor(int $page = 1): Paginator
422
421
{
423
422
$firstResult = ($page -1) * self::ITEMS_PER_PAGE;
424
-
423
+
425
424
$user = $this->tokenStorage->getToken()->getUser();
426
425
$queryBuilder = $this->createQueryBuilder();
427
426
$queryBuilder->select('b')
@@ -482,11 +481,11 @@ namespace App\Repository;
482
481
class BookRepository extends ServiceEntityRepository
483
482
{
484
483
// constant, variables and constructor...
485
-
484
+
486
485
public function getBooksByFavoriteAuthor(int $page = 1): Paginator
487
486
{
488
487
$firstResult = ($page -1) * self::ITEMS_PER_PAGE;
489
-
488
+
490
489
$user = $this->tokenStorage->getToken()->getUser();
491
490
$queryBuilder = $this->createQueryBuilder();
492
491
$queryBuilder->select('b')
0 commit comments