Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ doctrine:
is_bundle: false
dir: '%kernel.project_dir%/../sources/AppBundle/Accounting/Entity'
prefix: 'AppBundle\Accounting\Entity'
alias: Accounting
Site:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/../sources/AppBundle/Site/Entity'
prefix: 'AppBundle\Site\Entity'

when@test:
doctrine:
Expand Down
10 changes: 5 additions & 5 deletions sources/Afup/Utils/Pays.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Afup\Site\Utils;

use AppBundle\Site\Model\Repository\CountryRepository;
use AppBundle\Site\Entity\Repository\CountryRepository;

/**
* Classe de gestion des pays
Expand All @@ -20,11 +20,11 @@ public function __construct(private readonly CountryRepository $countryRepositor
*
* @return array<string, string>
*/
public function obtenirPays()
public function obtenirPays(): array
{
$result = [];
foreach ($this->countryRepository->getAllCountries() as $country) {
$result[$country->getId()] = $country->getName();
foreach ($this->countryRepository->getAllSortedByName() as $country) {
$result[$country->id] = $country->name;
}

return $result;
Expand All @@ -35,6 +35,6 @@ public function obtenirPays()
*/
public function obtenirNom(string $id): string
{
return $this->countryRepository->getOneBy(['id' => $id])->getName();
return $this->countryRepository->find($id)->name;
}
}
19 changes: 19 additions & 0 deletions sources/AppBundle/Site/Entity/Country.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace AppBundle\Site\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'afup_pays')]
class Country
{
#[ORM\Id]
#[ORM\Column(length: 255, nullable: false)]
public string $id;

#[ORM\Column(name: 'nom', length: 2, nullable: false)]
public string $name;
}
31 changes: 31 additions & 0 deletions sources/AppBundle/Site/Entity/Repository/CountryRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace AppBundle\Site\Entity\Repository;

use AppBundle\Doctrine\EntityRepository;
use AppBundle\Site\Entity\Country;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends EntityRepository<Country>
*/
final class CountryRepository extends EntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Country::class);
}

/**
* @return array<Country>
*/
public function getAllSortedByName(): array
{
return $this->createQueryBuilder('c')
->orderBy('c.name', 'asc')
->getQuery()
->execute();
}
}
43 changes: 0 additions & 43 deletions sources/AppBundle/Site/Model/Country.php

This file was deleted.

61 changes: 0 additions & 61 deletions sources/AppBundle/Site/Model/Repository/CountryRepository.php

This file was deleted.

Loading