Feature: allow to filter courses by user's job #export #acp

This commit is contained in:
2022-10-10 21:22:22 +02:00
parent 2f77deaa60
commit aba3b33fd0
5 changed files with 82 additions and 26 deletions

View File

@@ -14,9 +14,8 @@ namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\UserJob;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
class UserJobRepository implements ObjectRepository
class UserJobRepository implements UserJobRepositoryInterface
{
private EntityRepository $repository;
@@ -38,6 +37,11 @@ class UserJobRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findAllActive(): array
{
return $this->repository->findBy(['active' => true]);
}
/**
* @param mixed|null $limit
* @param mixed|null $offset
@@ -49,12 +53,12 @@ class UserJobRepository implements ObjectRepository
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria)
public function findOneBy(array $criteria): ?UserJob
{
return $this->repository->findOneBy($criteria);
}
public function getClassName()
public function getClassName(): string
{
return UserJob::class;
}

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\UserJob;
use Doctrine\Persistence\ObjectRepository;
interface UserJobRepositoryInterface extends ObjectRepository
{
public function find($id): ?UserJob;
/**
* @return array|UserJob[]
*/
public function findAll(): array;
/**
* @return array|UserJob[]
*/
public function findAllActive(): array;
/**
* @param mixed|null $limit
* @param mixed|null $offset
*
* @return array|object[]|UserJob[]
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null);
public function findOneBy(array $criteria): ?UserJob;
public function getClassName(): string;
}