From 864e1eeabb493534a865bdf5d871da4809f94261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 30 Apr 2022 00:35:11 +0200 Subject: [PATCH] replace more doctrine shortcuts by fqdn --- .../Tests/Controller/ActivityControllerTest.php | 5 +++-- .../Form/Type/TranslatableActivityTypeTest.php | 3 ++- .../Controller/ParticipationControllerTest.php | 2 +- .../Tests/Search/EventSearchTest.php | 2 +- .../Command/LoadAndUpdateLanguagesCommand.php | 3 ++- .../Command/LoadCountriesCommand.php | 3 ++- .../Controller/PermissionsGroupController.php | 16 ++++++++-------- .../Controller/ScopeController.php | 8 ++++---- .../Controller/UserController.php | 4 ++-- .../Form/Type/Select2CountryType.php | 5 +++-- .../Form/Type/Select2LanguageType.php | 5 +++-- .../Test/Export/AbstractExportTest.php | 2 +- .../Export/Export/ListPerson.php | 2 +- .../Controller/PersonAddressControllerTest.php | 2 +- .../Controller/PersonControllerUpdateTest.php | 2 +- ...ersonControllerUpdateWithHiddenFieldsTest.php | 2 +- .../Export/Export/ReportList.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../migrations/Version20150622233319.php | 2 +- 19 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index 55b2fb8c0..9fbbde980 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Controller; +use Chill\ActivityBundle\Entity\ActivityType; use RuntimeException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Role\Role; @@ -209,7 +210,7 @@ final class ActivityControllerTest extends WebTestCase //get the social PermissionGroup, and remove CHILL_ACTIVITY_* $socialPermissionGroup = $em - ->getRepository('ChillMainBundle:PermissionsGroup') + ->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class) ->findOneByName('social'); $withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup()) ->setName('social without activity'); @@ -323,7 +324,7 @@ final class ActivityControllerTest extends WebTestCase { $types = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') - ->getRepository('ChillActivityBundle:ActivityType') + ->getRepository(ActivityType::class) ->findAll(); return $types[array_rand($types)]; diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php index 68f206da2..7493bc5f4 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Form\Type; +use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Form\Type\TranslatableActivityType; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -95,7 +96,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase protected function getRandomType($active = true) { $types = $this->container->get('doctrine.orm.entity_manager') - ->getRepository('ChillActivityBundle:ActivityType') + ->getRepository(ActivityType::class) ->findBy(['active' => $active]); return $types[array_rand($types)]; diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index aa14cf748..87b3b0ebe 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -456,7 +456,7 @@ final class ParticipationControllerTest extends WebTestCase $center = $this->em->getRepository(\Chill\MainBundle\Entity\Center::class) ->findByName($centerName); - $circles = $this->em->getRepository('ChillMainBundle:Scope') + $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); array_filter($circles, static function ($circle) use ($circleName) { return in_array($circleName, $circle->getName(), true); diff --git a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php index 837fbcade..bb93196fa 100644 --- a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php @@ -333,7 +333,7 @@ final class EventSearchTest extends WebTestCase */ protected function getCircle($name = 'social') { - $circles = $this->entityManager->getRepository('ChillMainBundle:Scope') + $circles = $this->entityManager->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); /** @var \Chill\MainBundle\Entity\Scope $circle */ diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index dd751db01..a32fd5d97 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Command; +use Chill\MainBundle\Entity\Language; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -113,7 +114,7 @@ class LoadAndUpdateLanguagesCommand extends Command ) ); - $langageDB = $em->getRepository('ChillMainBundle:Language')->find($code); + $langageDB = $em->getRepository(Language::class)->find($code); if (!$excludeCode) { if (!$langageDB) { diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index b47146324..47bd93491 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Command; +use Chill\MainBundle\Entity\Country; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -87,7 +88,7 @@ class LoadCountriesCommand extends Command $em = $this->entityManager; foreach ($countries as $country) { - $countryStored = $em->getRepository('ChillMainBundle:Country') + $countryStored = $em->getRepository(Country::class) ->findOneBy(['countryCode' => $country->getCountryCode()]); if (null === $countryStored) { diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 59b97a57c..216ef1f5c 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -87,7 +87,7 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); + $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); @@ -203,8 +203,8 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid); - $roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid); + $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($pgid); + $roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class)->find($rsid); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); @@ -269,7 +269,7 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); + $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); @@ -319,7 +319,7 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository('ChillMainBundle:PermissionsGroup')->findAll(); + $entities = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->findAll(); return $this->render('@ChillMain/PermissionsGroup/index.html.twig', [ 'entities' => $entities, @@ -349,7 +349,7 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); + $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); @@ -405,7 +405,7 @@ class PermissionsGroupController extends AbstractController $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em - ->getRepository('ChillMainBundle:PermissionsGroup') + ->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class) ->find($id); if (!$permissionsGroup) { @@ -469,7 +469,7 @@ class PermissionsGroupController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $roleScope = $em->getRepository('ChillMainBundle:RoleScope') + $roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class) ->findOneBy(['role' => $role, 'scope' => $scope]); if (null === $roleScope) { diff --git a/src/Bundle/ChillMainBundle/Controller/ScopeController.php b/src/Bundle/ChillMainBundle/Controller/ScopeController.php index 07945c7fa..74ebc73a7 100644 --- a/src/Bundle/ChillMainBundle/Controller/ScopeController.php +++ b/src/Bundle/ChillMainBundle/Controller/ScopeController.php @@ -54,7 +54,7 @@ class ScopeController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $scope = $em->getRepository('ChillMainBundle:Scope')->find($id); + $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); @@ -75,7 +75,7 @@ class ScopeController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository('ChillMainBundle:Scope')->findAll(); + $entities = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->findAll(); return $this->render('@ChillMain/Scope/index.html.twig', [ 'entities' => $entities, @@ -105,7 +105,7 @@ class ScopeController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $scope = $em->getRepository('ChillMainBundle:Scope')->find($id); + $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); @@ -125,7 +125,7 @@ class ScopeController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $scope = $em->getRepository('ChillMainBundle:Scope')->find($id); + $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id); if (!$scope) { throw $this->createNotFoundException('Unable to find Scope entity.'); diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 01e7ece26..61895eaa9 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -124,7 +124,7 @@ class UserController extends CRUDController throw $this->createNotFoundException('Unable to find User entity.'); } - $groupCenter = $em->getRepository('ChillMainBundle:GroupCenter') + $groupCenter = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class) ->find($gcid); if (!$groupCenter) { @@ -330,7 +330,7 @@ class UserController extends CRUDController { $em = $this->getDoctrine()->getManager(); - $groupCenterManaged = $em->getRepository('ChillMainBundle:GroupCenter') + $groupCenterManaged = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class) ->findOneBy([ 'center' => $groupCenter->getCenter(), 'permissionsGroup' => $groupCenter->getPermissionsGroup(), diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index d3374e9de..73cdeb075 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Form\Type; +use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\Persistence\ObjectManager; @@ -50,13 +51,13 @@ class Select2CountryType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $transformer = new ObjectToIdTransformer($this->em, 'Chill\MainBundle\Entity\Country'); + $transformer = new ObjectToIdTransformer($this->em, Country::class); $builder->addModelTransformer($transformer); } public function configureOptions(OptionsResolver $resolver) { - $countries = $this->em->getRepository('Chill\MainBundle\Entity\Country')->findAll(); + $countries = $this->em->getRepository(Country::class)->findAll(); $choices = []; $preferredCountries = $this->parameterBag->get('chill_main.available_countries'); $preferredChoices = []; diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 4c8e11a49..8e46f4508 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Form\Type; +use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\Persistence\ObjectManager; @@ -50,13 +51,13 @@ class Select2LanguageType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $transformer = new MultipleObjectsToIdTransformer($this->em, 'Chill\MainBundle\Entity\Language'); + $transformer = new MultipleObjectsToIdTransformer($this->em, Language::class); $builder->addModelTransformer($transformer); } public function configureOptions(OptionsResolver $resolver) { - $languages = $this->em->getRepository('Chill\MainBundle\Entity\Language')->findAll(); + $languages = $this->em->getRepository(Language::class)->findAll(); $preferredLanguages = $this->parameterBag->get('chill_main.available_languages'); $choices = []; $preferredChoices = []; diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index b4264140b..d7da05aa7 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -85,7 +85,7 @@ abstract class AbstractExportTest extends WebTestCase $centers = $em->getRepository(\Chill\MainBundle\Entity\Center::class) ->findAll(); - $circles = $em->getRepository('ChillMainBundle:Scope') + $circles = $em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); if (count($centers) === 0) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 9f9c90da0..50b0f3d72 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -173,7 +173,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface case 'countryOfBirth': case 'nationality': $countryRepository = $this->entityManager - ->getRepository('ChillMainBundle:Country'); + ->getRepository(\Chill\MainBundle\Entity\Country::class); // load all countries in a single query $countryRepository->findBy(['countryCode' => $values]); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php index 7691e9b49..7b483d8cd 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php @@ -70,7 +70,7 @@ final class PersonAddressControllerTest extends WebTestCase $this->em = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager'); - $this->postalCode = $this->em->getRepository('ChillMainBundle:PostalCode') + $this->postalCode = $this->em->getRepository(\Chill\MainBundle\Entity\PostalCode::class) ->findOneBy(['code' => 1000]); $this->client = self::createClient([], [ diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index bb582232e..608a5bef5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -192,7 +192,7 @@ final class PersonControllerUpdateTest extends WebTestCase case 'nationality': case 'countryOfBirth': if (false === empty($value)) { - $country = $this->em->getRepository('ChillMainBundle:Country') + $country = $this->em->getRepository(\Chill\MainBundle\Entity\Country::class) ->findOneByCountryCode($value); $transformedValue = $country->getId(); } else { diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index 934eddc34..15ff6f116 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -126,7 +126,7 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase case 'nationality': case 'countryOfBirth': if (null !== $value) { - $country = $this->em->getRepository('ChillMainBundle:Country') + $country = $this->em->getRepository(\Chill\MainBundle\Entity\Country::class) ->findOneByCountryCode($value); $transformedValue = $country->getId(); } else { diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 61224bb39..b2b436485 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -246,7 +246,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface case 'person_countryOfBirth': case 'person_nationality': $countryRepository = $this->em - ->getRepository('ChillMainBundle:Country'); + ->getRepository(\Chill\MainBundle\Entity\Country::class); // load all countries in a single query $countryRepository->findBy(['countryCode' => $values]); diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index 1e6e5f946..45f009a4f 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -65,7 +65,7 @@ final class TimelineProviderTest extends WebTestCase $scopesSocial = array_filter( self::$em - ->getRepository('ChillMainBundle:Scope') + ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(), static function (Scope $scope) { return $scope->getName()['en'] === 'social'; } ); diff --git a/src/Bundle/ChillReportBundle/migrations/Version20150622233319.php b/src/Bundle/ChillReportBundle/migrations/Version20150622233319.php index 685906658..0bb50c9e1 100644 --- a/src/Bundle/ChillReportBundle/migrations/Version20150622233319.php +++ b/src/Bundle/ChillReportBundle/migrations/Version20150622233319.php @@ -72,7 +72,7 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI //add a default scope $scopes = $this->container->get('doctrine.orm.default_entity_manager') - ->getRepository('ChillMainBundle:Scope') + ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); if (count($scopes) > 0) {