load doctrine extensions during kernel bootstrap #84 (#92)

This commit is contained in:
Kevin Papst
2018-01-16 21:35:23 +01:00
committed by GitHub
parent 3f221fcdb8
commit 0a65965187
11 changed files with 126 additions and 172 deletions

View File

@@ -25,9 +25,10 @@ use App\Entity\Project;
class TimesheetQuery extends BaseQuery
{
const STATE_ALL = 0;
const STATE_RUNNING = 1;
const STATE_STOPPED = 2;
const STATE_ALL = 1;
const STATE_RUNNING = 2;
const STATE_STOPPED = 3;
/**
* Overwritten for different default order
* @var string
@@ -153,9 +154,15 @@ class TimesheetQuery extends BaseQuery
*/
public function setState($state)
{
if (!is_int($state) && $state != (int) $state) {
return $this;
}
$state = (int) $state;
if (in_array($state, [self::STATE_ALL, self::STATE_RUNNING, self::STATE_STOPPED], true)) {
$this->state = $state;
}
return $this;
}
}

View File

@@ -14,13 +14,14 @@ namespace App\Repository;
use App\Entity\User;
use App\Model\UserStatistic;
use App\Repository\Query\UserQuery;
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
/**
* Class UserRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class UserRepository extends AbstractRepository
class UserRepository extends AbstractRepository implements UserLoaderInterface
{
/**
@@ -65,4 +66,20 @@ class UserRepository extends AbstractRepository
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
}
/**
* @param string $username
* @return mixed|null|\Symfony\Component\Security\Core\User\UserInterface
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function loadUserByUsername($username)
{
return $this->createQueryBuilder('u')
->where('u.username = :username')
->orWhere('u.email = :username')
->setParameter('username', $username)
->getQuery()
->getSingleResult();
}
}