replace more doctrine shortcuts by fqdn

This commit is contained in:
Julien Fastré 2022-04-30 00:35:11 +02:00
parent a0392b9216
commit 864e1eeabb
19 changed files with 39 additions and 33 deletions

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller; namespace Chill\ActivityBundle\Tests\Controller;
use Chill\ActivityBundle\Entity\ActivityType;
use RuntimeException; use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
@ -209,7 +210,7 @@ final class ActivityControllerTest extends WebTestCase
//get the social PermissionGroup, and remove CHILL_ACTIVITY_* //get the social PermissionGroup, and remove CHILL_ACTIVITY_*
$socialPermissionGroup = $em $socialPermissionGroup = $em
->getRepository('ChillMainBundle:PermissionsGroup') ->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
->findOneByName('social'); ->findOneByName('social');
$withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup()) $withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup())
->setName('social without activity'); ->setName('social without activity');
@ -323,7 +324,7 @@ final class ActivityControllerTest extends WebTestCase
{ {
$types = self::$kernel->getContainer() $types = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager') ->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityType') ->getRepository(ActivityType::class)
->findAll(); ->findAll();
return $types[array_rand($types)]; return $types[array_rand($types)];

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form\Type; namespace Chill\ActivityBundle\Tests\Form\Type;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType; use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\FormType;
@ -95,7 +96,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
protected function getRandomType($active = true) protected function getRandomType($active = true)
{ {
$types = $this->container->get('doctrine.orm.entity_manager') $types = $this->container->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityType') ->getRepository(ActivityType::class)
->findBy(['active' => $active]); ->findBy(['active' => $active]);
return $types[array_rand($types)]; return $types[array_rand($types)];

View File

@ -456,7 +456,7 @@ final class ParticipationControllerTest extends WebTestCase
$center = $this->em->getRepository(\Chill\MainBundle\Entity\Center::class) $center = $this->em->getRepository(\Chill\MainBundle\Entity\Center::class)
->findByName($centerName); ->findByName($centerName);
$circles = $this->em->getRepository('ChillMainBundle:Scope') $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(); ->findAll();
array_filter($circles, static function ($circle) use ($circleName) { array_filter($circles, static function ($circle) use ($circleName) {
return in_array($circleName, $circle->getName(), true); return in_array($circleName, $circle->getName(), true);

View File

@ -333,7 +333,7 @@ final class EventSearchTest extends WebTestCase
*/ */
protected function getCircle($name = 'social') protected function getCircle($name = 'social')
{ {
$circles = $this->entityManager->getRepository('ChillMainBundle:Scope') $circles = $this->entityManager->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(); ->findAll();
/** @var \Chill\MainBundle\Entity\Scope $circle */ /** @var \Chill\MainBundle\Entity\Scope $circle */

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Command; namespace Chill\MainBundle\Command;
use Chill\MainBundle\Entity\Language;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; 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 (!$excludeCode) {
if (!$langageDB) { if (!$langageDB) {

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Command; namespace Chill\MainBundle\Command;
use Chill\MainBundle\Entity\Country;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -87,7 +88,7 @@ class LoadCountriesCommand extends Command
$em = $this->entityManager; $em = $this->entityManager;
foreach ($countries as $country) { foreach ($countries as $country) {
$countryStored = $em->getRepository('ChillMainBundle:Country') $countryStored = $em->getRepository(Country::class)
->findOneBy(['countryCode' => $country->getCountryCode()]); ->findOneBy(['countryCode' => $country->getCountryCode()]);
if (null === $countryStored) { if (null === $countryStored) {

View File

@ -87,7 +87,7 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
if (!$permissionsGroup) { if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
@ -203,8 +203,8 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid); $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($pgid);
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid); $roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class)->find($rsid);
if (!$permissionsGroup) { if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
@ -269,7 +269,7 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
if (!$permissionsGroup) { if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
@ -319,7 +319,7 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $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', [ return $this->render('@ChillMain/PermissionsGroup/index.html.twig', [
'entities' => $entities, 'entities' => $entities,
@ -349,7 +349,7 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); $permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
if (!$permissionsGroup) { if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
@ -405,7 +405,7 @@ class PermissionsGroupController extends AbstractController
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$permissionsGroup = $em $permissionsGroup = $em
->getRepository('ChillMainBundle:PermissionsGroup') ->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
->find($id); ->find($id);
if (!$permissionsGroup) { if (!$permissionsGroup) {
@ -469,7 +469,7 @@ class PermissionsGroupController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$roleScope = $em->getRepository('ChillMainBundle:RoleScope') $roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class)
->findOneBy(['role' => $role, 'scope' => $scope]); ->findOneBy(['role' => $role, 'scope' => $scope]);
if (null === $roleScope) { if (null === $roleScope) {

View File

@ -54,7 +54,7 @@ class ScopeController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
if (!$scope) { if (!$scope) {
throw $this->createNotFoundException('Unable to find Scope entity.'); throw $this->createNotFoundException('Unable to find Scope entity.');
@ -75,7 +75,7 @@ class ScopeController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $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', [ return $this->render('@ChillMain/Scope/index.html.twig', [
'entities' => $entities, 'entities' => $entities,
@ -105,7 +105,7 @@ class ScopeController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
if (!$scope) { if (!$scope) {
throw $this->createNotFoundException('Unable to find Scope entity.'); throw $this->createNotFoundException('Unable to find Scope entity.');
@ -125,7 +125,7 @@ class ScopeController extends AbstractController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id); $scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
if (!$scope) { if (!$scope) {
throw $this->createNotFoundException('Unable to find Scope entity.'); throw $this->createNotFoundException('Unable to find Scope entity.');

View File

@ -124,7 +124,7 @@ class UserController extends CRUDController
throw $this->createNotFoundException('Unable to find User entity.'); throw $this->createNotFoundException('Unable to find User entity.');
} }
$groupCenter = $em->getRepository('ChillMainBundle:GroupCenter') $groupCenter = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class)
->find($gcid); ->find($gcid);
if (!$groupCenter) { if (!$groupCenter) {
@ -330,7 +330,7 @@ class UserController extends CRUDController
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$groupCenterManaged = $em->getRepository('ChillMainBundle:GroupCenter') $groupCenterManaged = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class)
->findOneBy([ ->findOneBy([
'center' => $groupCenter->getCenter(), 'center' => $groupCenter->getCenter(),
'permissionsGroup' => $groupCenter->getPermissionsGroup(), 'permissionsGroup' => $groupCenter->getPermissionsGroup(),

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Form\Type; namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\Country;
use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer; use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -50,13 +51,13 @@ class Select2CountryType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) 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); $builder->addModelTransformer($transformer);
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$countries = $this->em->getRepository('Chill\MainBundle\Entity\Country')->findAll(); $countries = $this->em->getRepository(Country::class)->findAll();
$choices = []; $choices = [];
$preferredCountries = $this->parameterBag->get('chill_main.available_countries'); $preferredCountries = $this->parameterBag->get('chill_main.available_countries');
$preferredChoices = []; $preferredChoices = [];

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Form\Type; namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\Language;
use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer; use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -50,13 +51,13 @@ class Select2LanguageType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) 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); $builder->addModelTransformer($transformer);
} }
public function configureOptions(OptionsResolver $resolver) 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'); $preferredLanguages = $this->parameterBag->get('chill_main.available_languages');
$choices = []; $choices = [];
$preferredChoices = []; $preferredChoices = [];

View File

@ -85,7 +85,7 @@ abstract class AbstractExportTest extends WebTestCase
$centers = $em->getRepository(\Chill\MainBundle\Entity\Center::class) $centers = $em->getRepository(\Chill\MainBundle\Entity\Center::class)
->findAll(); ->findAll();
$circles = $em->getRepository('ChillMainBundle:Scope') $circles = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(); ->findAll();
if (count($centers) === 0) { if (count($centers) === 0) {

View File

@ -173,7 +173,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface
case 'countryOfBirth': case 'countryOfBirth':
case 'nationality': case 'nationality':
$countryRepository = $this->entityManager $countryRepository = $this->entityManager
->getRepository('ChillMainBundle:Country'); ->getRepository(\Chill\MainBundle\Entity\Country::class);
// load all countries in a single query // load all countries in a single query
$countryRepository->findBy(['countryCode' => $values]); $countryRepository->findBy(['countryCode' => $values]);

View File

@ -70,7 +70,7 @@ final class PersonAddressControllerTest extends WebTestCase
$this->em = self::$kernel->getContainer() $this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager'); ->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]); ->findOneBy(['code' => 1000]);
$this->client = self::createClient([], [ $this->client = self::createClient([], [

View File

@ -192,7 +192,7 @@ final class PersonControllerUpdateTest extends WebTestCase
case 'nationality': case 'nationality':
case 'countryOfBirth': case 'countryOfBirth':
if (false === empty($value)) { if (false === empty($value)) {
$country = $this->em->getRepository('ChillMainBundle:Country') $country = $this->em->getRepository(\Chill\MainBundle\Entity\Country::class)
->findOneByCountryCode($value); ->findOneByCountryCode($value);
$transformedValue = $country->getId(); $transformedValue = $country->getId();
} else { } else {

View File

@ -126,7 +126,7 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
case 'nationality': case 'nationality':
case 'countryOfBirth': case 'countryOfBirth':
if (null !== $value) { if (null !== $value) {
$country = $this->em->getRepository('ChillMainBundle:Country') $country = $this->em->getRepository(\Chill\MainBundle\Entity\Country::class)
->findOneByCountryCode($value); ->findOneByCountryCode($value);
$transformedValue = $country->getId(); $transformedValue = $country->getId();
} else { } else {

View File

@ -246,7 +246,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
case 'person_countryOfBirth': case 'person_countryOfBirth':
case 'person_nationality': case 'person_nationality':
$countryRepository = $this->em $countryRepository = $this->em
->getRepository('ChillMainBundle:Country'); ->getRepository(\Chill\MainBundle\Entity\Country::class);
// load all countries in a single query // load all countries in a single query
$countryRepository->findBy(['countryCode' => $values]); $countryRepository->findBy(['countryCode' => $values]);

View File

@ -65,7 +65,7 @@ final class TimelineProviderTest extends WebTestCase
$scopesSocial = array_filter( $scopesSocial = array_filter(
self::$em self::$em
->getRepository('ChillMainBundle:Scope') ->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(), ->findAll(),
static function (Scope $scope) { return $scope->getName()['en'] === 'social'; } static function (Scope $scope) { return $scope->getName()['en'] === 'social'; }
); );

View File

@ -72,7 +72,7 @@ class Version20150622233319 extends AbstractMigration implements ContainerAwareI
//add a default scope //add a default scope
$scopes = $this->container->get('doctrine.orm.default_entity_manager') $scopes = $this->container->get('doctrine.orm.default_entity_manager')
->getRepository('ChillMainBundle:Scope') ->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll(); ->findAll();
if (count($scopes) > 0) { if (count($scopes) > 0) {