Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
anikeevda committed Sep 22, 2017
2 parents f71a0e1 + aff62ee commit 3252b13
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 3 deletions.
42 changes: 41 additions & 1 deletion Entity/BaseEmployeeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
}
}
42 changes: 41 additions & 1 deletion Entity/BasePartnerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
}
}
40 changes: 39 additions & 1 deletion Entity/BaseSpecialOfferRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
}
}
34 changes: 34 additions & 0 deletions Model/EmployeeProviderInterface.php
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);
}
34 changes: 34 additions & 0 deletions Model/PartnerProviderInterface.php
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);
}
34 changes: 34 additions & 0 deletions Model/SpecialOfferProviderInterface.php
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);
}

0 comments on commit 3252b13

Please sign in to comment.