mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
refactor naming ReferralsAvailable => referralSuggestion
This commit is contained in:
parent
3f138dc152
commit
02ca9add52
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\Suggestion;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
final class ReferralAvailable implements ReferralAvailableInterface
|
||||
{
|
||||
protected UserRepository $userRepository;
|
||||
|
||||
public function __construct(UserRepository $userRepository)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
}
|
||||
|
||||
public function countReferralAvailable(AccompanyingPeriod $period, ?array $options = []): int
|
||||
{
|
||||
return $this->userRepository->countByActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $period
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findReferralAvailable(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array
|
||||
{
|
||||
return $this->userRepository->findByActive();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\AccompanyingPeriod\Suggestion;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
/**
|
||||
* Basic implementation: this suggestion does not return any suggestion
|
||||
*/
|
||||
final class ReferralsSuggestion implements ReferralsSuggestionInterface
|
||||
{
|
||||
public function countReferralSuggested(AccompanyingPeriod $period, ?array $options = []): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $period
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findReferralSuggested(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -8,13 +8,13 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
/**
|
||||
* Process the suggestion of referral for a given accompanying period
|
||||
*/
|
||||
interface ReferralAvailableInterface
|
||||
interface ReferralsSuggestionInterface
|
||||
{
|
||||
public function countReferralAvailable(AccompanyingPeriod $period, ?array $options = []): int;
|
||||
public function countReferralSuggested(AccompanyingPeriod $period, ?array $options = []): int;
|
||||
|
||||
/**
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findReferralAvailable(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array;
|
||||
public function findReferralSuggested(AccompanyingPeriod $period, int $limit = 50, int $start = 0): array;
|
||||
|
||||
}
|
@ -4,7 +4,7 @@ namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralAvailableInterface;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -34,13 +34,13 @@ class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
private Registry $registry;
|
||||
|
||||
private ReferralAvailableInterface $referralAvailable;
|
||||
private ReferralsSuggestionInterface $referralAvailable;
|
||||
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
ValidatorInterface $validator,
|
||||
Registry $registry,
|
||||
ReferralAvailableInterface $referralAvailable
|
||||
ReferralsSuggestionInterface $referralAvailable
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->validator = $validator;
|
||||
@ -209,11 +209,11 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $period);
|
||||
|
||||
$total = $this->referralAvailable->countReferralAvailable($period);
|
||||
$total = $this->referralAvailable->countReferralSuggested($period);
|
||||
$paginator = $this->getPaginatorFactory()->create($total);
|
||||
|
||||
if (0 < $total) {
|
||||
$users = $this->referralAvailable->findReferralAvailable($period, $paginator->getItemsPerPage(),
|
||||
$users = $this->referralAvailable->findReferralSuggested($period, $paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber());
|
||||
} else {
|
||||
$users = [];
|
||||
|
@ -14,9 +14,9 @@ services:
|
||||
lazy: true
|
||||
method: preUpdateAccompanyingPeriod
|
||||
|
||||
Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralAvailable:
|
||||
Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestion:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralAvailableInterface: '@Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralAvailable'
|
||||
Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface: '@Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestion'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user