Skip to content

Commit 6e56884

Browse files
committed
Renommage de la classe de collection des antennes
En préparation pour déplacer les informations en base de données.
1 parent 026b13a commit 6e56884

22 files changed

Lines changed: 79 additions & 73 deletions

File tree

app/config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ services:
195195
arguments: ['@Psr\Http\Client\ClientInterface', null, "%google_maps_api_key%"]
196196

197197
AppBundle\Offices\OfficeFinder:
198+
autowire: true
198199
arguments: ['@geocoder']
199200

200201
AppBundle\Subscriber\SitemapXmlSubscriber:

sources/AppBundle/Antennes/AntennesCollection.php renamed to sources/AppBundle/Antennes/AntenneRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AppBundle\Antennes;
66

7-
final class AntennesCollection
7+
final class AntenneRepository
88
{
99
/** @var array<string, Antenne> */
1010
private array $antennes;

sources/AppBundle/Association/Form/CompanyPublicProfile.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AppBundle\Association\Form;
66

7-
use AppBundle\Antennes\AntennesCollection;
7+
use AppBundle\Antennes\AntenneRepository;
88
use Symfony\Component\Form\AbstractType;
99
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
1010
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -27,12 +27,14 @@ class CompanyPublicProfile extends AbstractType
2727
public const DESCRIPTION_MAX_LENGTH = 2000;
2828
public const MEMBERSHIP_REASON_MAX_LENGTH = 150;
2929

30+
public function __construct(
31+
private readonly AntenneRepository $antennesRepository,
32+
) {}
33+
3034
public function buildForm(FormBuilderInterface $builder, array $options): void
3135
{
32-
$antennesCollection = new AntennesCollection();
33-
3436
$antennesInfos = [];
35-
foreach ($antennesCollection->getAll() as $antenne) {
37+
foreach ($this->antennesRepository->getAll() as $antenne) {
3638
$antennesInfos[$antenne->label] = $antenne->code;
3739
}
3840

sources/AppBundle/Association/Form/ContactDetailsType.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace AppBundle\Association\Form;
66

77
use Afup\Site\Utils\Pays;
8-
use AppBundle\Antennes\AntennesCollection;
8+
use AppBundle\Antennes\AntenneRepository;
99
use AppBundle\Association\Model\User;
1010
use Symfony\Component\Form\AbstractType;
1111
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -23,15 +23,10 @@
2323

2424
class ContactDetailsType extends AbstractType
2525
{
26-
/**
27-
* @var Pays
28-
*/
29-
public $countryService;
30-
31-
public function __construct(Pays $countryService)
32-
{
33-
$this->countryService = $countryService;
34-
}
26+
public function __construct(
27+
private readonly Pays $countryService,
28+
private readonly AntenneRepository $antenneRepository,
29+
) {}
3530

3631
public function buildForm(FormBuilderInterface $builder, array $options): void
3732
{
@@ -111,9 +106,8 @@ public function configureOptions(OptionsResolver $resolver): void
111106
*/
112107
private function getOfficesList(): array
113108
{
114-
$antennesCollection = new AntennesCollection();
115109
$offices = ['' => '-Aucune-'];
116-
foreach ($antennesCollection->getAllSortedByLabels() as $antenne) {
110+
foreach ($this->antenneRepository->getAllSortedByLabels() as $antenne) {
117111
$offices[$antenne->label] = $antenne->code;
118112
}
119113
return $offices;

sources/AppBundle/Association/Form/NearestOfficeChoiceType.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44

55
namespace AppBundle\Association\Form;
66

7-
use AppBundle\Antennes\AntennesCollection;
7+
use AppBundle\Antennes\AntenneRepository;
88
use Symfony\Component\Form\AbstractType;
99
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
1010
use Symfony\Component\OptionsResolver\OptionsResolver;
1111

1212
class NearestOfficeChoiceType extends AbstractType
1313
{
14+
public function __construct(
15+
private readonly AntenneRepository $antennesRepository,
16+
) {}
17+
1418
public function configureOptions(OptionsResolver $resolver): void
1519
{
1620
parent::configureOptions($resolver);
1721

18-
$antennesCollection = new AntennesCollection();
1922
$offices = ['-Aucune-' => ''];
20-
foreach ($antennesCollection->getAllSortedByLabels() as $antenne) {
23+
foreach ($this->antennesRepository->getAllSortedByLabels() as $antenne) {
2124
$offices[$antenne->label] = $antenne->code;
2225
}
2326

sources/AppBundle/Association/Model/User.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AppBundle\Association\Model;
66

7-
use AppBundle\Antennes\AntennesCollection;
7+
use AppBundle\Antennes\AntenneRepository;
88
use AppBundle\Association\Model\Repository\UserRepository;
99
use AppBundle\Association\NotifiableInterface;
1010
use AppBundle\Validator\Constraints as AppAssert;
@@ -199,7 +199,7 @@ public function setNearestOffice($nearestOffice): self
199199
return $this;
200200
}
201201

202-
public function getNearestOfficeLabel()
202+
public function getNearestOfficeLabel(AntenneRepository $antenneRepository)
203203
{
204204
$code = $this->getNearestOffice();
205205

@@ -208,7 +208,7 @@ public function getNearestOfficeLabel()
208208
return null;
209209
}
210210

211-
return (new AntennesCollection())->findByCode($code)->label;
211+
return $antenneRepository->findByCode($code)->label;
212212
}
213213

214214
/**

sources/AppBundle/Command/IndexMeetupsCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
88
use Algolia\AlgoliaSearch\SearchClient;
9+
use AppBundle\Antennes\AntenneRepository;
910
use AppBundle\Event\Model\Repository\MeetupRepository;
1011
use AppBundle\Indexation\Meetups\Runner;
1112
use Symfony\Component\Console\Command\Command;
@@ -18,6 +19,7 @@ class IndexMeetupsCommand extends Command
1819
public function __construct(
1920
private readonly SearchClient $searchClient,
2021
private readonly MeetupRepository $meetupRepository,
22+
private readonly AntenneRepository $antenneRepository,
2123
) {
2224
parent::__construct();
2325
}
@@ -40,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4042
$this->runScraping($output);
4143
}
4244

43-
$runner = new Runner($this->searchClient, $this->meetupRepository);
45+
$runner = new Runner($this->searchClient, $this->meetupRepository, $this->antenneRepository);
4446
$runner->run();
4547

4648
return Command::SUCCESS;

sources/AppBundle/Controller/Admin/Antennes/AntenneListAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace AppBundle\Controller\Admin\Antennes;
66

77
use AppBundle\Antennes\Antenne;
8-
use AppBundle\Antennes\AntennesCollection;
8+
use AppBundle\Antennes\AntenneRepository;
99
use Symfony\Component\HttpFoundation\Request;
1010
use Symfony\Component\HttpFoundation\Response;
1111
use Twig\Environment;
1212

1313
final readonly class AntenneListAction
1414
{
1515
public function __construct(
16-
private AntennesCollection $antennesCollection,
16+
private AntenneRepository $antennesCollection,
1717
private Environment $twig,
1818
) {}
1919

sources/AppBundle/Controller/Admin/Members/UserListAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AppBundle\Controller\Admin\Members;
66

7-
use AppBundle\Antennes\AntennesCollection;
7+
use AppBundle\Antennes\AntenneRepository;
88
use AppBundle\Association\Model\Repository\UserRepository;
99
use Symfony\Component\HttpFoundation\Request;
1010
use Symfony\Component\HttpFoundation\Response;
@@ -14,7 +14,7 @@ class UserListAction
1414
{
1515
public function __construct(
1616
private readonly UserRepository $userRepository,
17-
private readonly AntennesCollection $antennesCollection,
17+
private readonly AntenneRepository $antenneRepository,
1818
private readonly Environment $twig,
1919
) {}
2020

@@ -28,7 +28,7 @@ public function __invoke(Request $request): Response
2828
$onlyDisplayActive = !$request->query->getBoolean('alsoDisplayInactive');
2929

3030
return new Response($this->twig->render('admin/members/user_list.html.twig', [
31-
'antennes' => $this->antennesCollection->getAll(),
31+
'antennes' => $this->antenneRepository->getAll(),
3232
'users' => $this->userRepository->search(
3333
$sort,
3434
$direction,

sources/AppBundle/Controller/Api/Antennes/GetOneAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
namespace AppBundle\Controller\Api\Antennes;
66

7-
use AppBundle\Antennes\AntennesCollection;
7+
use AppBundle\Antennes\AntenneRepository;
88
use AppBundle\Event\Model\Repository\MeetupRepository;
99
use Symfony\Component\HttpFoundation\JsonResponse;
1010
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1111

1212
final readonly class GetOneAction
1313
{
1414
public function __construct(
15-
private AntennesCollection $antennesCollection,
15+
private AntenneRepository $antennesCollection,
1616
private MeetupRepository $meetupRepository,
1717
) {}
1818

0 commit comments

Comments
 (0)