Developer improvements, PhpCs, PhpUnit #42 (#43)

* improved dev fixtures with more diversity, more data, better testcases, user avatars #42
* added customer stats to dashboard, fixed column length for 3 widgets #42
* fixed empty alias - display empty message for new user #42
* unified-ui for "new" toolbar icon #42
* use kimai2_ as database prefix #42
* added customer stats to dashboard, fixed column length for 3 widgets #42
* fix long project/customer names in "currently active" navbar flyout" #42
* added services config for dev environment #42
* added command to run unit tests #42
* added command to run integration tests #42
* added command to run code sniffer #42
* added phpcs and phpunit to composer #42
* created tests directory #42
* fixed code sniffer warnings #42
* added function to switch result type from Pagerfanta to QueryBuilder #42
* dramatically reduced database calls by using custom joined query #42
* added command to install kimai dependencies #42
* added dev:reset command #42
This commit is contained in:
Kevin Papst
2018-01-07 15:11:03 +01:00
committed by GitHub
parent fa8e976e76
commit f8b390cbe2
63 changed files with 2424 additions and 302 deletions

View File

@@ -11,14 +11,12 @@
namespace AppBundle\Repository;
use AppBundle\Entity\User;
use TimesheetBundle\Entity\Activity;
use TimesheetBundle\Entity\Timesheet;
use AppBundle\Repository\Query\BaseQuery;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use TimesheetBundle\Model\ActivityStatistic;
/**
* Class AbstractRepository
@@ -27,6 +25,19 @@ use TimesheetBundle\Model\ActivityStatistic;
*/
abstract class AbstractRepository extends EntityRepository
{
/**
* @param QueryBuilder $qb
* @param BaseQuery $query
* @return QueryBuilder|Pagerfanta
*/
protected function getBaseQueryResult(QueryBuilder $qb, BaseQuery $query)
{
if ($query->getResultType() == BaseQuery::RESULT_TYPE_PAGER) {
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
}
return $qb;
}
/**
* @param Query $query

View File

@@ -22,6 +22,9 @@ class BaseQuery
const DEFAULT_PAGESIZE = 25;
const DEFAULT_PAGE = 1;
const RESULT_TYPE_PAGER = 'PagerFanta';
const RESULT_TYPE_QUERYBUILDER = 'QueryBuilder';
/**
* @var int
*/
@@ -38,6 +41,10 @@ class BaseQuery
* @var string
*/
protected $order = 'ASC';
/**
* @var string
*/
protected $resultType = self::RESULT_TYPE_PAGER;
/**
* @return int
@@ -116,4 +123,24 @@ class BaseQuery
}
return $this;
}
/**
* @return string
*/
public function getResultType()
{
return $this->resultType;
}
/**
* @param string $resultType
* @return BaseQuery
*/
public function setResultType($resultType)
{
if (in_array($resultType, [self::RESULT_TYPE_PAGER, self::RESULT_TYPE_QUERYBUILDER])) {
$this->resultType = $resultType;
}
return $this;
}
}