-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
223 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,29 @@ | |
|
||
use Doctrine\ORM\EntityRepository; | ||
use Domstor\TemplateBundle\Model\BlockContentProviderInterface; | ||
use Domstor\TemplateBundle\Model\EmployeeProviderInterface; | ||
use Knp\Bundle\PaginatorBundle\Definition\PaginatorAwareInterface; | ||
use Knp\Component\Pager\Paginator; | ||
use PDO; | ||
|
||
/** | ||
* Description of BaseEmployeeRepository | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
abstract class BaseEmployeeRepository extends EntityRepository implements BlockContentProviderInterface | ||
abstract class BaseEmployeeRepository extends EntityRepository implements BlockContentProviderInterface, EmployeeProviderInterface, PaginatorAwareInterface | ||
{ | ||
/** | ||
* | ||
* @var Paginator | ||
*/ | ||
protected $paginator; | ||
|
||
public function setPaginator(Paginator $paginator) | ||
{ | ||
$this->paginator = $paginator; | ||
} | ||
|
||
public function findForHomePage($options) | ||
{ | ||
$qb = $this->createQueryBuilder('emp'); | ||
|
@@ -29,4 +44,29 @@ public function findForHomePage($options) | |
; | ||
return $qb->getQuery()->getResult(); | ||
} | ||
|
||
public function findForListPage($page, $limit) | ||
{ | ||
$qb = $this->createQueryBuilder('e'); | ||
$qb | ||
->addSelect('image') | ||
->leftJoin('e.image', 'image') | ||
->orderBy('e.sorting', 'asc') | ||
; | ||
|
||
$query = $qb->getQuery(); | ||
return $this->paginator->paginate($query, $page, $limit); | ||
} | ||
|
||
public function findForShowPage($id) | ||
{ | ||
$qb = $this->createQueryBuilder('e'); | ||
$qb | ||
->addSelect('image') | ||
->leftJoin('e.image', 'image') | ||
->where($qb->expr()->eq('e.id', ':id')) | ||
->setParameter('id', $id, PDO::PARAM_INT) | ||
; | ||
return $qb->getQuery()->getOneOrNullResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,29 @@ | |
|
||
use Doctrine\ORM\EntityRepository; | ||
use Domstor\TemplateBundle\Model\BlockContentProviderInterface; | ||
use Domstor\TemplateBundle\Model\PartnerProviderInterface; | ||
use Knp\Bundle\PaginatorBundle\Definition\PaginatorAwareInterface; | ||
use Knp\Component\Pager\Paginator; | ||
use PDO; | ||
|
||
/** | ||
* Description of BasePartnerRepository | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
abstract class BasePartnerRepository extends EntityRepository implements BlockContentProviderInterface | ||
abstract class BasePartnerRepository extends EntityRepository implements BlockContentProviderInterface, PaginatorAwareInterface, PartnerProviderInterface | ||
{ | ||
/** | ||
* | ||
* @var Paginator | ||
*/ | ||
protected $paginator; | ||
|
||
public function setPaginator(Paginator $paginator) | ||
{ | ||
$this->paginator = $paginator; | ||
} | ||
|
||
public function findForHomePage($options) | ||
{ | ||
$qb = $this->createQueryBuilder('p'); | ||
|
@@ -29,4 +44,29 @@ public function findForHomePage($options) | |
; | ||
return $qb->getQuery()->getResult(); | ||
} | ||
|
||
public function findForListPage($page, $limit) | ||
{ | ||
$qb = $this->createQueryBuilder('p'); | ||
$qb | ||
->addSelect('image') | ||
->leftJoin('p.image', 'image') | ||
->orderBy('p.sorting', 'asc') | ||
; | ||
|
||
$query = $qb->getQuery(); | ||
return $this->paginator->paginate($query, $page, $limit); | ||
} | ||
|
||
public function findForShowPage($id) | ||
{ | ||
$qb = $this->createQueryBuilder('p'); | ||
$qb | ||
->addSelect('image') | ||
->leftJoin('p.image', 'image') | ||
->where($qb->expr()->eq('e.id', ':id')) | ||
->setParameter('id', $id, PDO::PARAM_INT) | ||
; | ||
return $qb->getQuery()->getOneOrNullResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,29 @@ | |
|
||
use Doctrine\ORM\EntityRepository; | ||
use Domstor\TemplateBundle\Model\BlockContentProviderInterface; | ||
use Domstor\TemplateBundle\Model\SpecialOfferProviderInterface; | ||
use Knp\Bundle\PaginatorBundle\Definition\PaginatorAwareInterface; | ||
use Knp\Component\Pager\Paginator; | ||
use PDO; | ||
|
||
/** | ||
* Description of BaseSpecialOfferRepository | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
abstract class BaseSpecialOfferRepository extends EntityRepository implements BlockContentProviderInterface | ||
abstract class BaseSpecialOfferRepository extends EntityRepository implements BlockContentProviderInterface, SpecialOfferProviderInterface, PaginatorAwareInterface | ||
{ | ||
/** | ||
* | ||
* @var Paginator | ||
*/ | ||
protected $paginator; | ||
|
||
public function setPaginator(Paginator $paginator) | ||
{ | ||
$this->paginator = $paginator; | ||
} | ||
|
||
public function findForHomePage($options) | ||
{ | ||
$qb = $this->createQueryBuilder('s'); | ||
|
@@ -29,4 +44,27 @@ public function findForHomePage($options) | |
; | ||
return $qb->getQuery()->getResult(); | ||
} | ||
|
||
public function findForListPage($page, $limit) | ||
{ | ||
$qb = $this->createQueryBuilder('s'); | ||
$qb | ||
->addSelect('image') | ||
->leftJoin('s.image', 'image') | ||
->orderBy('s.sorting', 'asc') | ||
; | ||
$query = $qb->getQuery(); | ||
return $this->paginator->paginate($query, $page, $limit); | ||
} | ||
|
||
public function findForShowPage($id) | ||
{ | ||
$qb = $this->createQueryBuilder('s'); | ||
$qb | ||
->where($qb->expr()->eq('s.id', ':id')) | ||
->setParameter('id', $id, PDO::PARAM_INT) | ||
; | ||
|
||
return $qb->getQuery()->getOneOrNullResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
namespace Domstor\TemplateBundle\Model; | ||
|
||
use Domstor\TemplateBundle\Model\EmployeeInterface; | ||
use Knp\Component\Pager\Pagination\AbstractPagination; | ||
|
||
/** | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
interface EmployeeProviderInterface | ||
{ | ||
/** | ||
* | ||
* @param int $page | ||
* @param int $limit | ||
* @return AbstractPagination | ||
*/ | ||
public function findForListPage($page, $limit); | ||
|
||
/** | ||
* | ||
* @param int $id | ||
* @return EmployeeInterface|null Description | ||
*/ | ||
public function findForShowPage($id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
namespace Domstor\TemplateBundle\Model; | ||
|
||
use Domstor\TemplateBundle\Model\PartnerInterface; | ||
use Knp\Component\Pager\Pagination\AbstractPagination; | ||
|
||
/** | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
interface PartnerProviderInterface | ||
{ | ||
/** | ||
* | ||
* @param int $page | ||
* @param int $limit | ||
* @return AbstractPagination | ||
*/ | ||
public function findForListPage($page, $limit); | ||
|
||
/** | ||
* | ||
* @param int $id | ||
* @return PartnerInterface|null Description | ||
*/ | ||
public function findForShowPage($id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
namespace Domstor\TemplateBundle\Model; | ||
|
||
use Domstor\TemplateBundle\Model\SpecialOfferInterface; | ||
use Knp\Component\Pager\Pagination\AbstractPagination; | ||
|
||
/** | ||
* | ||
* @author Dmitry Anikeev <[email protected]> | ||
*/ | ||
interface SpecialOfferProviderInterface | ||
{ | ||
/** | ||
* | ||
* @param int $page | ||
* @param int $limit | ||
* @return AbstractPagination | ||
*/ | ||
public function findForListPage($page, $limit); | ||
|
||
/** | ||
* | ||
* @param int $id | ||
* @return SpecialOfferInterface|null Description | ||
*/ | ||
public function findForShowPage($id); | ||
} |