From 8e3322f578a9fc6f81df29ccac79c07e813cd469 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Apr 2024 10:56:49 +0200 Subject: [PATCH] rector rules for upgrade to php 8.2 and symfony 5.4 applied + php cs fixer --- rector.php | 8 +- src/Bundle/ChillEventBundle/Entity/Event.php | 2 +- .../src/ApiHelper/ApiWrapper.php | 59 ++- .../ApiHelper/PartenaireRomeAppellation.php | 65 ++-- .../src/ApiHelper/ProcessRequestTrait.php | 61 ++-- .../src/ChillFranceTravailApiBundle.php | 13 +- .../src/Controller/RomeController.php | 13 +- .../ChillFranceTravailApiExtension.php | 14 +- .../src/DependencyInjection/Configuration.php | 12 +- .../PartenaireRomeAppellationTest.php | 46 ++- .../Tests/Controller/RomeControllerTest.php | 15 +- .../ChillJobBundle/src/ChillJobBundle.php | 13 +- .../src/Controller/CSCrudReportController.php | 70 ++-- .../src/Controller/CSPersonController.php | 97 ++--- .../src/Controller/CSReportController.php | 29 +- .../DependencyInjection/ChillJobExtension.php | 16 +- .../src/DependencyInjection/Configuration.php | 12 +- .../ChillJobBundle/src/Entity/CSPerson.php | 343 +++++++----------- src/Bundle/ChillJobBundle/src/Entity/CV.php | 119 +++--- .../src/Entity/CV/Experience.php | 98 ++--- .../src/Entity/CV/Formation.php | 98 ++--- .../ChillJobBundle/src/Entity/Frein.php | 96 +++-- .../ChillJobBundle/src/Entity/Immersion.php | 247 ++++++------- .../src/Entity/ProjetProfessionnel.php | 151 +++----- .../src/Entity/Rome/Appellation.php | 62 ++-- .../ChillJobBundle/src/Entity/Rome/Metier.php | 57 ++- .../src/Export/ListCSPerson.php | 294 +++++++-------- .../ChillJobBundle/src/Export/ListCV.php | 162 +++++---- .../ChillJobBundle/src/Export/ListFrein.php | 181 +++++---- .../src/Export/ListProjetProfessionnel.php | 233 ++++++------ .../src/Form/CSPersonDispositifsType.php | 83 ++--- .../Form/CSPersonPersonalSituationType.php | 137 ++++--- .../src/Form/CV/ExperienceType.php | 46 ++- .../src/Form/CV/FormationType.php | 52 ++- src/Bundle/ChillJobBundle/src/Form/CVType.php | 51 ++- .../RomeAppellationChoiceLoader.php | 43 +-- .../ChillJobBundle/src/Form/FreinType.php | 42 +-- .../ChillJobBundle/src/Form/ImmersionType.php | 151 ++++---- .../src/Form/ProjetProfessionnelType.php | 61 ++-- .../src/Form/Type/PickRomeAppellationType.php | 47 +-- .../ChillJobBundle/src/Menu/MenuBuilder.php | 56 +-- .../src/Repository/CSPersonRepository.php | 15 +- .../Repository/CV/ExperienceRepository.php | 15 +- .../src/Repository/CV/FormationRepository.php | 15 +- .../src/Repository/CVRepository.php | 15 +- .../src/Repository/FreinRepository.php | 15 +- .../src/Repository/ImmersionRepository.php | 15 +- .../ProjetProfessionnelRepository.php | 15 +- .../Repository/Rome/AppellationRepository.php | 15 +- .../src/Repository/Rome/MetierRepository.php | 15 +- .../Authorization/CSConnectesVoter.php | 32 +- .../Security/Authorization/ExportsVoter.php | 43 ++- .../Controller/CSPersonControllerTest.php | 18 +- .../Controller/CSReportControllerTest.php | 18 +- .../src/ThirdParty/EntrepriseType.php | 10 +- .../src/ThirdParty/PrescripteurType.php | 10 +- .../src/migrations/Version20191119172511.php | 22 +- .../src/migrations/Version20191129112321.php | 25 +- .../src/migrations/Version20200113104411.php | 21 +- .../src/migrations/Version20200113142525.php | 19 +- .../src/migrations/Version20200114081435.php | 19 +- .../src/migrations/Version20200124130244.php | 22 +- .../src/migrations/Version20200124132321.php | 21 +- .../src/migrations/Version20200127132932.php | 22 +- .../src/migrations/Version20200205132532.php | 47 +-- .../src/migrations/Version20200207224152.php | 21 +- .../src/migrations/Version20200210105342.php | 28 +- .../src/migrations/Version20200313124323.php | 19 +- .../src/migrations/Version20200403114520.php | 23 +- .../src/migrations/Version20200403123148.php | 21 +- 70 files changed, 2026 insertions(+), 2025 deletions(-) diff --git a/rector.php b/rector.php index 7604667ea..6a6bf88ce 100644 --- a/rector.php +++ b/rector.php @@ -36,12 +36,8 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - \Rector\Symfony\Set\SymfonySetList::SYMFONY_50, - \Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES, - \Rector\Symfony\Set\SymfonySetList::SYMFONY_51, - \Rector\Symfony\Set\SymfonySetList::SYMFONY_52, - \Rector\Symfony\Set\SymfonySetList::SYMFONY_53, - \Rector\Symfony\Set\SymfonySetList::SYMFONY_54, + \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82, + \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_54, \Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, \Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, ]); diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 6f7ee7ef0..2f323d11a 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -47,7 +47,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter private ?Scope $circle = null; #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] - private ?\DateTime $date; + private ?\DateTime $date = null; #[ORM\Id] #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php index 15e51c1f2..7fe43bae1 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php @@ -1,31 +1,27 @@ clientId = $clientId; - $this->clientSecret = $clientSecret; - $this->redis = $redis; $this->client = new Client([ - 'base_uri' => 'https://entreprise.pole-emploi.fr/connexion/oauth2/access_token' + 'base_uri' => 'https://entreprise.pole-emploi.fr/connexion/oauth2/access_token', ]); } @@ -61,28 +54,29 @@ class ApiWrapper $response = $this->client->post('', [ 'query' => ['realm' => '/partenaire'], 'headers' => [ - 'Content-Type' => 'application/x-www-form-urlencoded' + 'Content-Type' => 'application/x-www-form-urlencoded', ], - //'body' => 'grant_type=client_credentials&client_id=PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9&client_secret=4e626fa3123bcf4d299591c09731fa3242a7e75bbc003955f903aebc33cdd022&scope=api_romev1%20nomenclatureRome%20application_PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9' + // 'body' => 'grant_type=client_credentials&client_id=PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9&client_secret=4e626fa3123bcf4d299591c09731fa3242a7e75bbc003955f903aebc33cdd022&scope=api_romev1%20nomenclatureRome%20application_PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9' 'form_params' => [ 'grant_type' => 'client_credentials', 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, - 'scope' => \implode(' ', \array_merge($scopes, [ 'application_'.$this->clientId ])), - ] - //]); - ]); - // - } - catch (ClientException $e) { + 'scope' => \implode(' ', \array_merge($scopes, ['application_'.$this->clientId])), + ], + // ]); + ]); + } catch (ClientException $e) { dump(Psr7\str($e->getRequest())); - dump( Psr7\str($e->getResponse())); + dump(Psr7\str($e->getResponse())); } $data = \json_decode((string) $response->getBody()); // set the key with an expiry time - $this->redis->setEx($cacheKey, $data->expires_in - 2, - \serialize($data)); + $this->redis->setEx( + $cacheKey, + $data->expires_in - 2, + \serialize($data) + ); return $data->access_token; } @@ -91,5 +85,4 @@ class ApiWrapper { return self::UNPERSONAL_BEARER.implode('', $scopes); } - } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index 9f05834d6..27679a61d 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -1,41 +1,41 @@ wrapper = $wrapper; $this->logger = $logger; $this->client = new Client([ - 'base_uri' => 'https://api.emploi-store.fr/partenaire/rome/v1/' + 'base_uri' => 'https://api.emploi-store.fr/partenaire/rome/v1/', ]); } @@ -52,11 +52,10 @@ class PartenaireRomeAppellation return $this->wrapper->getPublicBearer([ 'api_romev1', 'nomenclatureRome', - ]); + ]); } /** - * * @param string $search */ public function getListeAppellation($search) @@ -65,16 +64,20 @@ class PartenaireRomeAppellation $request = new Request('GET', 'appellation'); $parameters = [ - 'query' => [ - 'q' => $search, - 'qf' => 'libelle' - ], - 'headers' => [ - 'Authorization' => 'Bearer '.$bearer - ] - ]; - $response = $this->handleRequest($request, $parameters, $this->client, - $this->logger); + 'query' => [ + 'q' => $search, + 'qf' => 'libelle', + ], + 'headers' => [ + 'Authorization' => 'Bearer '.$bearer, + ], + ]; + $response = $this->handleRequest( + $request, + $parameters, + $this->client, + $this->logger + ); return \GuzzleHttp\json_decode((string) $response->getBody()); } @@ -86,15 +89,19 @@ class PartenaireRomeAppellation $request = new Request('GET', sprintf('appellation/%s', $code)); $parameters = [ 'headers' => [ - 'Authorization' => 'Bearer '.$bearer + 'Authorization' => 'Bearer '.$bearer, ], 'query' => [ - 'champs' => 'code,libelle,metier(code,libelle)' - ] + 'champs' => 'code,libelle,metier(code,libelle)', + ], ]; - $response = $this->handleRequest($request, $parameters, $this->client, - $this->logger); + $response = $this->handleRequest( + $request, + $parameters, + $this->client, + $this->logger + ); return \GuzzleHttp\json_decode((string) $response->getBody()); } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ProcessRequestTrait.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ProcessRequestTrait.php index 7561c3b40..6284f5fe6 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ProcessRequestTrait.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ProcessRequestTrait.php @@ -1,6 +1,14 @@ handleRequestRecursive($request, $parameters, - $client, $logger); + return $this->handleRequestRecursive( + $request, + $parameters, + $client, + $logger + ); } /** - * internal method to handle recursive requests + * internal method to handle recursive requests. * - * @param Request $request - * @param array $parameters - * @param Client $client - * @param LoggerInterface $logger * @param type $counter + * * @return type + * * @throws BadResponseException */ private function handleRequestRecursive( @@ -54,21 +62,17 @@ trait ProcessRequestTrait LoggerInterface $logger, $counter = 0 ) { - try { + try { return $client->send($request, $parameters); - } catch (BadResponseException $e) { if ( // get 429 exceptions $e instanceof ClientException - && - $e->getResponse()->getStatusCode() === 429 - && - count($e->getResponse()->getHeader('Retry-After')) > 0) { - + && 429 === $e->getResponse()->getStatusCode() + && count($e->getResponse()->getHeader('Retry-After')) > 0) { if ($counter > 5) { - $logger->error("too much 429 response", [ - 'request' => Psr7\str($e->getRequest()) + $logger->error('too much 429 response', [ + 'request' => Psr7\str($e->getRequest()), ]); throw $e; @@ -79,12 +83,17 @@ trait ProcessRequestTrait sleep($delay); - return $this->handleRequestRecursive($request, $parameters, - $client, $logger, $counter + 1); + return $this->handleRequestRecursive( + $request, + $parameters, + $client, + $logger, + $counter + 1 + ); } // handling other errors - $logger->error("Error while querying ROME api", [ + $logger->error('Error while querying ROME api', [ 'status_code' => $e->getResponse()->getStatusCode(), 'part' => 'appellation', 'request' => Psr7\str($e->getRequest()), diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ChillFranceTravailApiBundle.php b/src/Bundle/ChillFranceTravailApiBundle/src/ChillFranceTravailApiBundle.php index 9f428c6a2..6ebf66d2a 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ChillFranceTravailApiBundle.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ChillFranceTravailApiBundle.php @@ -1,9 +1,16 @@ query->has('q') === FALSE) { + if (false === $request->query->has('q')) { return new JsonResponse([]); } @@ -50,5 +58,4 @@ class RomeController extends Controller return new JsonResponse($computed); } - } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/DependencyInjection/ChillFranceTravailApiExtension.php b/src/Bundle/ChillFranceTravailApiBundle/src/DependencyInjection/ChillFranceTravailApiExtension.php index 15bbf3d30..1e7f3f45d 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/DependencyInjection/ChillFranceTravailApiExtension.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/DependencyInjection/ChillFranceTravailApiExtension.php @@ -1,5 +1,14 @@ + * + * @internal + * + * @coversNothing */ class PartenaireRomeAppellationTest extends KernelTestCase { @@ -25,7 +36,7 @@ class PartenaireRomeAppellationTest extends KernelTestCase $appellations = self::$kernel ->getContainer() ->get(PartenaireRomeAppellation::class) - ; + ; $data = $appellations->getListeAppellation('arb'); @@ -40,7 +51,7 @@ class PartenaireRomeAppellationTest extends KernelTestCase $appellations = self::$kernel ->getContainer() ->get(PartenaireRomeAppellation::class) - ; + ; $appellations->getListeAppellation('arb'); $appellations->getListeAppellation('ing'); @@ -48,8 +59,10 @@ class PartenaireRomeAppellationTest extends KernelTestCase $appellations->getListeAppellation('chori'); $data = $appellations->getListeAppellation('camion'); - $this->assertTrue($data[0] instanceof \stdClass, - 'assert that first index of data is an instance of stdClass'); + $this->assertTrue( + $data[0] instanceof \stdClass, + 'assert that first index of data is an instance of stdClass' + ); } public function testGetAppellation() @@ -58,18 +71,23 @@ class PartenaireRomeAppellationTest extends KernelTestCase $appellations = self::$kernel ->getContainer() ->get(PartenaireRomeAppellation::class) - ; + ; $a = $appellations->getListeAppellation('arb'); $full = $appellations->getAppellation($a[0]->code); - $this->assertNotNull($full->libelle, - 'assert that libelle is not null'); - $this->assertTrue($full->metier instanceof \stdClass, - 'assert that metier is returned'); - $this->assertNotNull($full->metier->libelle, - 'assert that metier->libelle is not null'); - + $this->assertNotNull( + $full->libelle, + 'assert that libelle is not null' + ); + $this->assertTrue( + $full->metier instanceof \stdClass, + 'assert that metier is returned' + ); + $this->assertNotNull( + $full->metier->libelle, + 'assert that metier->libelle is not null' + ); } } diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/Tests/Controller/RomeControllerTest.php b/src/Bundle/ChillFranceTravailApiBundle/src/Tests/Controller/RomeControllerTest.php index b0127a85d..a64ce5ae5 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/Tests/Controller/RomeControllerTest.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/Tests/Controller/RomeControllerTest.php @@ -1,9 +1,23 @@ request('GET', '/{_locale}/pole-emploi/appellation/search'); } - } diff --git a/src/Bundle/ChillJobBundle/src/ChillJobBundle.php b/src/Bundle/ChillJobBundle/src/ChillJobBundle.php index 5120f4a79..e583a271b 100644 --- a/src/Bundle/ChillJobBundle/src/ChillJobBundle.php +++ b/src/Bundle/ChillJobBundle/src/ChillJobBundle.php @@ -1,9 +1,16 @@ request->get("submit", "save-and-close"); + $next = $request->request->get('submit', 'save-and-close'); - switch ($next) { - case "save-and-close": - case "delete-and-close": - return $this->redirectToRoute('chill_csconnectes_csreport_index', [ - 'person' => $entity->getPerson()->getId() - ]); - default: - return parent::onBeforeRedirectAfterSubmission($action, $entity, $form, $request); - } + return match ($next) { + 'save-and-close', 'delete-and-close' => $this->redirectToRoute('chill_csconnectes_csreport_index', [ + 'person' => $entity->getPerson()->getId(), + ]), + default => parent::onBeforeRedirectAfterSubmission($action, $entity, $form, $request), + }; } protected function duplicateEntity(string $action, Request $request) { - - if ($this->getCrudName() === 'cscv') { + if ('cscv' === $this->getCrudName()) { $id = $request->query->get('duplicate_id', 0); /** @var \Chill\ChillJobBundle\Entity\CV $cv */ $cv = $this->getEntity($action, $id, $request); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->detach($cv); - foreach($cv->getExperiences() as $experience) { + foreach ($cv->getExperiences() as $experience) { $cv->removeExperience($experience); $em->detach($experience); $cv->addExperience($experience); } - foreach($cv->getFormations() as $formation) { + foreach ($cv->getFormations() as $formation) { $cv->removeFormation($formation); $em->detach($formation); $cv->addFormation($formation); } return $cv; - } elseif ($this->getCrudName() === 'projet_prof') { + } + if ('projet_prof' === $this->getCrudName()) { $id = $request->query->get('duplicate_id', 0); /** @var \Chill\ChillJobBundle\Entity\ProjetProfessionnel $original */ $original = $this->getEntity($action, $id, $request); @@ -72,23 +78,24 @@ class CSCrudReportController extends EntityPersonCRUDController return parent::duplicateEntity($action, $request); } - protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface + protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface { if ($entity instanceof Immersion) { if ('edit' === $action || 'new' === $action) { return parent::createFormFor($action, $entity, $formClass, [ - 'center' => $entity->getPerson()->getCenter() + 'center' => $entity->getPerson()->getCenter(), ]); - } elseif ('bilan' === $action) { + } + if ('bilan' === $action) { return parent::createFormFor($action, $entity, $formClass, [ 'center' => $entity->getPerson()->getCenter(), - 'step' => 'bilan' + 'step' => 'bilan', ]); - } elseif ($action === 'delete') { - return parent::createFormFor($action, $entity, $formClass, $formOptions); - } else { - throw new \LogicException("this step $action is not supported"); } + if ('delete' === $action) { + return parent::createFormFor($action, $entity, $formClass, $formOptions); + } + throw new \LogicException("this step {$action} is not supported"); } return parent::createFormFor($action, $entity, $formClass, $formOptions); @@ -105,20 +112,13 @@ class CSCrudReportController extends EntityPersonCRUDController parent::onPreFlush($action, $entity, $form, $request); } - /** - * Edit immersion bilan + * Edit immersion bilan. * - * @param Request $request * @param type $id - * @return \Symfony\Component\HttpFoundation\Response */ public function editBilan(Request $request, $id): \Symfony\Component\HttpFoundation\Response { return $this->formEditAction('bilan', $request, $id); } - - - - } diff --git a/src/Bundle/ChillJobBundle/src/Controller/CSPersonController.php b/src/Bundle/ChillJobBundle/src/Controller/CSPersonController.php index fb1ed69a9..102817702 100644 --- a/src/Bundle/ChillJobBundle/src/Controller/CSPersonController.php +++ b/src/Bundle/ChillJobBundle/src/Controller/CSPersonController.php @@ -1,15 +1,22 @@ denyAccessUnlessGranted(PersonVoter::UPDATE, - $entity->getPerson()); - break; - case 'ps_situation_view': - case 'dispositifs_view': - $this->denyAccessUnlessGranted(PersonVoter::SEE, - $entity->getPerson()); - break; - default: - parent::checkACL($action, $entity); - } + match ($action) { + 'ps_situation_edit', 'dispositifs_edit' => $this->denyAccessUnlessGranted( + PersonVoter::UPDATE, + $entity->getPerson() + ), + 'ps_situation_view', 'dispositifs_view' => $this->denyAccessUnlessGranted( + PersonVoter::SEE, + $entity->getPerson() + ), + default => parent::checkACL($action, $entity), + }; } protected function onBeforeRedirectAfterSubmission(string $action, $entity, FormInterface $form, Request $request) { - switch($action) { - case 'ps_situation_edit': - return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_personal_situation_view', - ['id' => $entity->getId()]); - - case 'dispositifs_edit': - return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_dispositifs_view', - ['id' => $entity->getId()]); - - default: - return null; - } + return match ($action) { + 'ps_situation_edit' => $this->redirectToRoute( + 'chill_crud_'.$this->getCrudName().'_personal_situation_view', + ['id' => $entity->getId()] + ), + 'dispositifs_edit' => $this->redirectToRoute( + 'chill_crud_'.$this->getCrudName().'_dispositifs_view', + ['id' => $entity->getId()] + ), + default => null, + }; } protected function getTemplateFor($action, $entity, Request $request) @@ -110,22 +113,26 @@ class CSPersonController extends OneToOneEntityPersonCRUDController } } - protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface + protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface { switch ($action) { case 'dispositifs_edit': - $form = $this->createForm($formClass, $entity, \array_merge( - $formOptions, [ 'center' => $entity->getPerson()->getCenter() ])); - $this->customizeForm($action, $form); + $form = $this->createForm($formClass, $entity, \array_merge( + $formOptions, + ['center' => $entity->getPerson()->getCenter()] + )); + $this->customizeForm($action, $form); - return $form; + return $form; case 'ps_situation_edit': - $form = $this->createForm($formClass, $entity, \array_merge( - $formOptions, [ 'center' => $entity->getPerson()->getCenter() ])); - $this->customizeForm($action, $form); + $form = $this->createForm($formClass, $entity, \array_merge( + $formOptions, + ['center' => $entity->getPerson()->getCenter()] + )); + $this->customizeForm($action, $form); - return $form; + return $form; default: return parent::createFormFor($action, $entity, $formClass, $formOptions); @@ -134,18 +141,16 @@ class CSPersonController extends OneToOneEntityPersonCRUDController protected function generateLabelForButton($action, $formName, $form) { - switch($action): + switch ($action) { case 'ps_situation_edit': case 'dispositifs_edit': - if ($formName === 'submit') { + if ('submit' === $formName) { return 'Enregistrer'; - } else { - throw new \LogicException("this formName is not supported: $formName"); } + throw new \LogicException("this formName is not supported: {$formName}"); break; default: return parent::generateLabelForButton($action, $formName, $form); - endswitch; + } } - } diff --git a/src/Bundle/ChillJobBundle/src/Controller/CSReportController.php b/src/Bundle/ChillJobBundle/src/Controller/CSReportController.php index 353474be8..6d4d61fc2 100644 --- a/src/Bundle/ChillJobBundle/src/Controller/CSReportController.php +++ b/src/Bundle/ChillJobBundle/src/Controller/CSReportController.php @@ -1,5 +1,14 @@ denyAccessUnlessGranted(PersonVoter::SEE, $person, "The access to " - . "person is denied"); + $this->denyAccessUnlessGranted(PersonVoter::SEE, $person, 'The access to ' + .'person is denied'); $reports = $this->getReports($person); return $this->render('@CSConnectesSP/Report/index.html.twig', \array_merge([ 'person' => $person, - ], $reports)); + ], $reports)); } protected function getReports(Person $person) @@ -54,14 +61,10 @@ class CSReportController extends Controller } foreach ($kinds as $key => $className) { - switch ($key) { - case 'immersions': - $ordering = [ 'debutDate' => 'DESC' ]; - break; - default: - $ordering = [ 'reportDate' => 'DESC' ]; - break; - } + $ordering = match ($key) { + 'immersions' => ['debutDate' => 'DESC'], + default => ['reportDate' => 'DESC'], + }; $results[$key] = $this->getDoctrine()->getManager() ->getRepository($className) ->findByPerson($person, $ordering); diff --git a/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php b/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php index 9284b1af0..de01124bf 100644 --- a/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php +++ b/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php @@ -1,5 +1,14 @@ load('services.yml'); // exports: list_CSperson override list_person - $container->setAlias('chill.person.export.list_person','Chill\ChillJobBundle\Export\ListCSPerson'); + $container->setAlias('chill.person.export.list_person', \Chill\ChillJobBundle\Export\ListCSPerson::class); } } diff --git a/src/Bundle/ChillJobBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillJobBundle/src/DependencyInjection/Configuration.php index b20154466..b11c109fc 100644 --- a/src/Bundle/ChillJobBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillJobBundle/src/DependencyInjection/Configuration.php @@ -1,5 +1,14 @@ 'DESC', 'endDate' => 'DESC'])] + private Collection $formations; /** - * - * @var Collection - * @ORM\OneToMany( - * targetEntity="Chill\ChillJobBundle\Entity\CV\Experience", - * mappedBy="CV", - * cascade={"persist", "remove", "detach"}, - * orphanRemoval=true - * ) - * @ORM\OrderBy({"startDate"= "DESC", "endDate"="DESC"}) * @Assert\Valid(traverse=true) */ - private $experiences; + #[ORM\OneToMany(targetEntity: CV\Experience::class, mappedBy: 'CV', cascade: ['persist', 'remove', 'detach'], orphanRemoval: true)] + #[ORM\OrderBy(['startDate' => 'DESC', 'endDate' => 'DESC'])] + private Collection $experiences; - /** - * - * @var \Chill\PersonBundle\Entity\Person - * @ORM\ManyToOne( - * targetEntity="Chill\PersonBundle\Entity\Person" - * ) - */ - private $person; + #[ORM\ManyToOne(targetEntity: Person::class)] + private ?Person $person = null; public function __construct() { @@ -122,7 +93,7 @@ class CV $this->reportDate = new \DateTime('now'); } - /** + /** * Get id. * * @return int @@ -265,7 +236,7 @@ class CV public function setFormations(Collection $formations) { foreach ($formations as $formation) { - /** @var CV\Formation $formation */ + /* @var CV\Formation $formation */ $formation->setCV($this); } $this->formations = $formations; @@ -287,7 +258,7 @@ class CV public function removeFormation(CV\Formation $formation) { - if (FALSE === $this->formations->contains($formation)) { + if (false === $this->formations->contains($formation)) { return $this; } @@ -300,7 +271,7 @@ class CV public function setExperiences(Collection $experiences) { foreach ($experiences as $experience) { - /** @var CV\Experience $experience */ + /* @var CV\Experience $experience */ $experience->setCV($this); } @@ -323,7 +294,7 @@ class CV public function removeExperience(CV\Experience $experience) { - if (FALSE === $this->experiences->contains($experience)) { + if (false === $this->experiences->contains($experience)) { return $this; } @@ -341,13 +312,13 @@ class CV public function setPerson(Person $person) { $this->person = $person; + return $this; } - public function __toString() + public function __toString(): string { return 'CV de '.$this->getPerson().' daté du '. $this->getReportDate()->format('d-m-Y'); } - } diff --git a/src/Bundle/ChillJobBundle/src/Entity/CV/Experience.php b/src/Bundle/ChillJobBundle/src/Entity/CV/Experience.php index aed41e9da..86e1c0fb9 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/CV/Experience.php +++ b/src/Bundle/ChillJobBundle/src/Entity/CV/Experience.php @@ -1,5 +1,14 @@ reportDate = new \DateTime('today'); } - /** + /** * Get id. * * @return int @@ -159,11 +153,9 @@ class Frein implements HasPerson /** * Set notesPerso. * - * @param string $notesPerso - * * @return Frein */ - public function setNotesPerso(string $notesPerso = null) + public function setNotesPerso(?string $notesPerso = null) { $this->notesPerso = (string) $notesPerso; @@ -207,11 +199,9 @@ class Frein implements HasPerson /** * Set notesEmploi. * - * @param string $notesEmploi - * * @return Frein */ - public function setNotesEmploi(string $notesEmploi = null) + public function setNotesEmploi(?string $notesEmploi = null) { $this->notesEmploi = (string) $notesEmploi; @@ -233,7 +223,7 @@ class Frein implements HasPerson return $this->person; } - public function setPerson(\Chill\PersonBundle\Entity\Person $person = null): HasPerson + public function setPerson(?\Chill\PersonBundle\Entity\Person $person = null): HasPerson { $this->person = $person; @@ -241,19 +231,19 @@ class Frein implements HasPerson } /** - * Vérifie qu'au moins un frein a été coché parmi les freins perso + emploi + * Vérifie qu'au moins un frein a été coché parmi les freins perso + emploi. * - * @param ExecutionContextInterface $context * @param array $payload + * * @Assert\Callback() */ public function validateFreinsCount(ExecutionContextInterface $context, $payload) { $nb = count($this->getFreinsEmploi()) + count($this->getFreinsPerso()); - if ($nb === 0) { - $msg = "Indiquez au moins un frein parmi les freins " - . "liés à l'emploi et les freins liés à la situation personnelle."; + if (0 === $nb) { + $msg = 'Indiquez au moins un frein parmi les freins ' + ."liés à l'emploi et les freins liés à la situation personnelle."; $context->buildViolation($msg) ->atPath('freinsEmploi') ->addViolation(); @@ -264,7 +254,7 @@ class Frein implements HasPerson } } - public function __toString() + public function __toString(): string { return 'Rapport "frein" de '.$this->getPerson().' daté du '. $this->getReportDate()->format('d-m-Y'); diff --git a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php index 69bf513ad..cbaac80f7 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php @@ -12,13 +12,12 @@ use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint; /** * Immersion - * - * @ORM\Table(name="chill_csconnectes.immersion") - * @ORM\Entity(repositoryClass="Chill\ChillJobBundle\Repository\ImmersionRepository") */ -class Immersion +#[ORM\Table(name: 'chill_csconnectes.immersion')] +#[ORM\Entity(repositoryClass: \Chill\ChillJobBundle\Repository\ImmersionRepository::class)] +class Immersion implements \Stringable { - const YES_NO_NSP = [ + public const YES_NO_NSP = [ 'oui', 'non', 'nsp' @@ -26,12 +25,11 @@ class Immersion /** * @var int - * - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + #[ORM\Column(name: 'id', type: 'integer')] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'AUTO')] + private ?int $id = null; /** * @@ -47,144 +45,134 @@ class Immersion /** * @var ThirdParty|null * - * @ORM\ManyToOne( - * targetEntity="\Chill\ThirdPartyBundle\Entity\ThirdParty" - * ) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $entreprise; + #[ORM\ManyToOne(targetEntity: \\Chill\ThirdPartyBundle\Entity\ThirdParty::class)] + private ?\Chill\ThirdPartyBundle\Entity\ThirdParty $entreprise = null; /** * @var User|null - * - * @ORM\ManyToOne( - * targetEntity="\Chill\MainBundle\Entity\User" - * ) */ - private $referent; + #[ORM\ManyToOne(targetEntity: \\Chill\MainBundle\Entity\User::class)] + private ?\Chill\MainBundle\Entity\User $referent = null; /** * @var string|null * - * @ORM\Column(name="domaineActivite", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $domaineActivite; + #[ORM\Column(name: 'domaineActivite', type: 'text', nullable: true)] + private ?string $domaineActivite = null; /** * @var string|null * - * @ORM\Column(name="tuteurName", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $tuteurName; + #[ORM\Column(name: 'tuteurName', type: 'text', nullable: true)] + private ?string $tuteurName = null; /** * @var string|null * - * @ORM\Column(name="tuteurFonction", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $tuteurFonction; + #[ORM\Column(name: 'tuteurFonction', type: 'text', nullable: true)] + private ?string $tuteurFonction = null; /** * @var string|null * - * @ORM\Column(name="tuteurPhoneNumber", type="text", nullable=true) * @Assert\NotNull() * @Assert\NotBlank() - * @PhonenumberConstraint(type="any") */ - private $tuteurPhoneNumber; + #[ORM\Column(name: 'tuteurPhoneNumber', type: 'text', nullable: true)] + #[PhonenumberConstraint(type: 'any')] + private ?string $tuteurPhoneNumber = null; /** * @var string|null - * - * @ORM\Column(name="structureAccName", type="text", nullable=true) */ - private $structureAccName; + #[ORM\Column(name: 'structureAccName', type: 'text', nullable: true)] + private ?string $structureAccName = null; /** * @var string - * - * @ORM\Column(name="structureAccPhonenumber", type="text", nullable=true) - * @PhonenumberConstraint(type="any") */ - private $structureAccPhonenumber; + #[ORM\Column(name: 'structureAccPhonenumber', type: 'text', nullable: true)] + #[PhonenumberConstraint(type: 'any')] + private ?string $structureAccPhonenumber = null; /** * @var string - * - * @ORM\Column(name="structureAccEmail", type="text", nullable=true) */ - private $structureAccEmail; + #[ORM\Column(name: 'structureAccEmail', type: 'text', nullable: true)] + private ?string $structureAccEmail = null; /** * * @var Address|null - * @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address", - * cascade={"persist", "remove"}) */ - private $structureAccAddress; + #[ORM\ManyToOne(targetEntity: \\Chill\MainBundle\Entity\Address::class, cascade: ['persist', 'remove'])] + private ?\Chill\MainBundle\Entity\Address $structureAccAddress = null; + + /** + * @var string|null + */ + #[ORM\Column(name: 'posteDescriptif', type: 'text', nullable: true)] + private ?string $posteDescriptif = null; /** * @var string|null * - * @ORM\Column(name="posteDescriptif", type="text", nullable=true) - */ - private $posteDescriptif; - - /** - * @var string|null - * - * @ORM\Column(name="posteTitle", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $posteTitle; + #[ORM\Column(name: 'posteTitle', type: 'text', nullable: true)] + private ?string $posteTitle = null; /** * @var string|null * - * @ORM\Column(name="posteLieu", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $posteLieu; + #[ORM\Column(name: 'posteLieu', type: 'text', nullable: true)] + private ?string $posteLieu = null; /** - * @var \DateTime|null + * @var \DateTimeInterface|null * - * @ORM\Column(name="debutDate", type="date", nullable=true) * @Assert\NotNull() */ - private $debutDate; + #[ORM\Column(name: 'debutDate', type: 'date', nullable: true)] + private ?\DateTimeInterface $debutDate = null; /** * @var string|null * - * @ORM\Column(name="duration", type="dateinterval", nullable=true) * @Assert\NotNull() */ + #[ORM\Column(name: 'duration', type: 'dateinterval', nullable: true)] private $duration; /** * @var string|null * - * @ORM\Column(name="horaire", type="text", nullable=true) * @Assert\NotNull() * @Assert\Length(min=2) */ - private $horaire; + #[ORM\Column(name: 'horaire', type: 'text', nullable: true)] + private ?string $horaire = null; - const OBJECTIFS = [ + public const OBJECTIFS = [ 'decouvrir_metier', 'confirmer_projet_prof', 'acquerir_experience', @@ -195,26 +183,25 @@ class Immersion /** * @var array|null - * - * @ORM\Column(name="objectifs", type="json", nullable=true) */ + #[ORM\Column(name: 'objectifs', type: 'json', nullable: true)] private $objectifs; /** * * @var string - * @ORM\Column(name="objectifsAutre", type="text", nullable=true) */ - private $objectifsAutre; + #[ORM\Column(name: 'objectifsAutre', type: 'text', nullable: true)] + private ?string $objectifsAutre = null; /** * * @var bool - * @ORM\Column(name="is_bilan_fullfilled", type="boolean", options={"default"=false}) */ - private $isBilanFullfilled = false; + #[ORM\Column(name: 'is_bilan_fullfilled', type: 'boolean', options: ['default' => false])] + private ?bool $isBilanFullfilled = false; - const SAVOIR_ETRE = [ + public const SAVOIR_ETRE = [ 'assiduite', 'ponctualite', 'respect_consigne_securite', @@ -225,54 +212,48 @@ class Immersion /** * @var array|null - * - * @ORM\Column(name="savoirEtre", type="json", nullable=true) */ + #[ORM\Column(name: 'savoirEtre', type: 'json', nullable: true)] private $savoirEtre; /** * * @var string - * @ORM\Column(name="savoirEtreNote", type="text", nullable=true) */ - private $savoirEtreNote; + #[ORM\Column(name: 'savoirEtreNote', type: 'text', nullable: true)] + private ?string $savoirEtreNote = null; /** * @var string - * - * @ORM\Column(name="noteimmersion", type="text") */ - private $noteImmersion = ''; + #[ORM\Column(name: 'noteimmersion', type: 'text')] + private ?string $noteImmersion = ''; /** * @var string|null - * - * @ORM\Column(name="principalesActivites", type="text", nullable=true) */ - private $principalesActivites; + #[ORM\Column(name: 'principalesActivites', type: 'text', nullable: true)] + private ?string $principalesActivites = null; /** * @var string|null - * - * @ORM\Column(name="competencesAcquises", type="text", nullable=true) */ - private $competencesAcquises; + #[ORM\Column(name: 'competencesAcquises', type: 'text', nullable: true)] + private ?string $competencesAcquises = null; /** * @var string|null - * - * @ORM\Column(name="competencesADevelopper", type="text", nullable=true) */ - private $competencesADevelopper; + #[ORM\Column(name: 'competencesADevelopper', type: 'text', nullable: true)] + private ?string $competencesADevelopper = null; /** * @var string|null - * - * @ORM\Column(name="noteBilan", type="text", nullable=true) */ - private $noteBilan; + #[ORM\Column(name: 'noteBilan', type: 'text', nullable: true)] + private ?string $noteBilan = null; - const PONCTUALITE_SALARIE = [ + public const PONCTUALITE_SALARIE = [ 'aucun', 'un', 'plusieurs' @@ -281,18 +262,18 @@ class Immersion /** * * @var string|null - * @ORM\Column(name="ponctualite_salarie", type="text", nullable=true) */ - private $ponctualiteSalarie; + #[ORM\Column(name: 'ponctualite_salarie', type: 'text', nullable: true)] + private ?string $ponctualiteSalarie = null; /** * * @var string|null - * @ORM\Column(name="ponctualite_salarie_note", type="text", nullable=true) */ - private $ponctualiteSalarieNote; + #[ORM\Column(name: 'ponctualite_salarie_note', type: 'text', nullable: true)] + private ?string $ponctualiteSalarieNote = null; - const ASSIDUITE = [ + public const ASSIDUITE = [ 'aucun', 'un', 'plusieurs' @@ -301,32 +282,32 @@ class Immersion /** * * @var string|null - * @ORM\Column(name="assiduite", type="text", nullable=true) */ - private $assiduite; + #[ORM\Column(name: 'assiduite', type: 'text', nullable: true)] + private ?string $assiduite = null; /** * * @var string|null - * @ORM\Column(name="assiduite_note", type="text", nullable=true) */ - private $assiduiteNote; + #[ORM\Column(name: 'assiduite_note', type: 'text', nullable: true)] + private ?string $assiduiteNote = null; /** * * @var string|null - * @ORM\Column(name="interet_activite", type="text", nullable=true) */ - private $interetActivite; + #[ORM\Column(name: 'interet_activite', type: 'text', nullable: true)] + private ?string $interetActivite = null; /** * * @var string|null - * @ORM\Column(name="interet_activite_note", type="text", nullable=true) */ - private $interetActiviteNote; + #[ORM\Column(name: 'interet_activite_note', type: 'text', nullable: true)] + private ?string $interetActiviteNote = null; - const INTEGRE_REGLE = [ + public const INTEGRE_REGLE = [ '1_temps', 'rapidement', 'pas_encore' @@ -335,114 +316,114 @@ class Immersion /** * * @var string|null - * @ORM\Column(name="integre_regle", type="text", nullable=true) */ - private $integreRegle; + #[ORM\Column(name: 'integre_regle', type: 'text', nullable: true)] + private ?string $integreRegle = null; /** * * @var string|null - * @ORM\Column(name="integre_regle_note", type="text", nullable=true) */ - private $integreRegleNote; + #[ORM\Column(name: 'integre_regle_note', type: 'text', nullable: true)] + private ?string $integreRegleNote = null; /** * * @var string|null - * @ORM\Column(name="esprit_initiative", type="text", nullable=true) */ - private $espritInitiative; + #[ORM\Column(name: 'esprit_initiative', type: 'text', nullable: true)] + private ?string $espritInitiative = null; /** * * @var string|null - * @ORM\Column(name="esprit_initiative_note", type="text", nullable=true) */ - private $espritInitiativeNote; + #[ORM\Column(name: 'esprit_initiative_note', type: 'text', nullable: true)] + private ?string $espritInitiativeNote = null; /** * * @var string|null - * @ORM\Column(name="organisation", type="text", nullable=true) */ - private $organisation; + #[ORM\Column(name: 'organisation', type: 'text', nullable: true)] + private ?string $organisation = null; /** * * @var string|null - * @ORM\Column(name="organisation_note", type="text", nullable=true) */ - private $organisationNote; + #[ORM\Column(name: 'organisation_note', type: 'text', nullable: true)] + private ?string $organisationNote = null; /** * * @var string|null - * @ORM\Column(name="capacite_travail_equipe", type="text", nullable=true) */ - private $capaciteTravailEquipe; + #[ORM\Column(name: 'capacite_travail_equipe', type: 'text', nullable: true)] + private ?string $capaciteTravailEquipe = null; /** * * @var string|null - * @ORM\Column(name="capacite_travail_equipe_note", type="text", nullable=true) */ - private $capaciteTravailEquipeNote; + #[ORM\Column(name: 'capacite_travail_equipe_note', type: 'text', nullable: true)] + private ?string $capaciteTravailEquipeNote = null; /** * * @var string|null - * @ORM\Column(name="style_vestimentaire", type="text", nullable=true) */ - private $styleVestimentaire; + #[ORM\Column(name: 'style_vestimentaire', type: 'text', nullable: true)] + private ?string $styleVestimentaire = null; /** * * @var string|null - * @ORM\Column(name="style_vestimentaire_note", type="text", nullable=true) */ - private $styleVestimentaireNote; + #[ORM\Column(name: 'style_vestimentaire_note', type: 'text', nullable: true)] + private ?string $styleVestimentaireNote = null; /** * * @var string|null - * @ORM\Column(name="langage_prof", type="text", nullable=true) */ - private $langageProf; + #[ORM\Column(name: 'langage_prof', type: 'text', nullable: true)] + private ?string $langageProf = null; /** * * @var string|null - * @ORM\Column(name="langage_prof_note", type="text", nullable=true) */ - private $langageProfNote; + #[ORM\Column(name: 'langage_prof_note', type: 'text', nullable: true)] + private ?string $langageProfNote = null; /** * * @var string|null - * @ORM\Column(name="applique_consigne", type="text", nullable=true) */ - private $appliqueConsigne; + #[ORM\Column(name: 'applique_consigne', type: 'text', nullable: true)] + private ?string $appliqueConsigne = null; /** * * @var string|null - * @ORM\Column(name="applique_consigne_note", type="text", nullable=true) */ - private $appliqueConsigneNote; + #[ORM\Column(name: 'applique_consigne_note', type: 'text', nullable: true)] + private ?string $appliqueConsigneNote = null; /** * * @var string|null - * @ORM\Column(name="respect_hierarchie", type="text", nullable=true) */ - private $respectHierarchie; + #[ORM\Column(name: 'respect_hierarchie', type: 'text', nullable: true)] + private ?string $respectHierarchie = null; /** * * @var string|null - * @ORM\Column(name="respect_hierarchie_note", type="text", nullable=true) */ - private $respectHierarchieNote; + #[ORM\Column(name: 'respect_hierarchie_note', type: 'text', nullable: true)] + private ?string $respectHierarchieNote = null; /** * Get id. @@ -1248,7 +1229,7 @@ class Immersion return $this; } - public function __toString() + public function __toString(): string { return 'Rapport "immersion" de '.$this->getPerson(); } diff --git a/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php b/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php index 95e0fc136..cc60faa45 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php +++ b/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php @@ -1,5 +1,14 @@ domaineActiviteValide; } - public function setDomaineActiviteSouhait(string $domaineActiviteSouhait = null) + public function setDomaineActiviteSouhait(?string $domaineActiviteSouhait = null) { $this->domaineActiviteSouhait = $domaineActiviteSouhait; return $this; } - public function setDomaineActiviteValide(string $domaineActiviteValide = null) + public function setDomaineActiviteValide(?string $domaineActiviteValide = null) { $this->domaineActiviteValide = $domaineActiviteValide; return $this; } - public function __toString() + public function __toString(): string { return 'Rapport "projet professionnel" de '.$this->getPerson().' daté du '. $this->getReportDate()->format('d-m-Y'); diff --git a/src/Bundle/ChillJobBundle/src/Entity/Rome/Appellation.php b/src/Bundle/ChillJobBundle/src/Entity/Rome/Appellation.php index e3e2dedb4..3b389c4d7 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Rome/Appellation.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Rome/Appellation.php @@ -1,51 +1,38 @@ libelle; } diff --git a/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php b/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php index d6ab5a751..c3908c77a 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php @@ -1,57 +1,46 @@ appellations = new ArrayCollection(); $this->appellation = new ArrayCollection(); } - /** * Get id. * diff --git a/src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php b/src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php index bc69b70fd..f840c024b 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php @@ -1,6 +1,16 @@ CSPerson::RESSOURCES, 'moyen_transport__label' => CSPerson::MOBILITE_MOYEN_TRANSPORT, 'type_contrat__label' => CSPerson::TYPE_CONTRAT, 'permis_conduire__label' => CSPerson::PERMIS_CONDUIRE, 'accompagnement__label' => CSPerson::ACCOMPAGNEMENTS, 'situation_professionnelle__label' => CSPerson::SITUATION_PROFESSIONNELLE, - 'neet_eligibility__label' => CSPerson::NEET_ELIGIBILITY + 'neet_eligibility__label' => CSPerson::NEET_ELIGIBILITY, ]; /** @@ -62,7 +70,7 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal /** * Rebuild fields array, combining parent ListPerson and ListCSPerson, - * adding query type as value + * adding query type as value. * * @return array */ @@ -89,7 +97,7 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal 'address_postcode_label' => 'string', 'address_country_name' => 'string', 'address_country_code' => 'string', - 'address_isnoaddress' => 'boolean' + 'address_isnoaddress' => 'boolean', ]; $CSfields = [ @@ -119,14 +127,14 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal 'datefindernieremploi' => 'date', 'type_contrat__label' => 'json', 'ressource__label' => 'json', - 'moyen_transport__label' => 'json' + 'moyen_transport__label' => 'json', ]; return array_merge($fields, $CSfields); } /** - * Return array FIELDS keys only + * Return array FIELDS keys only. * * @return array */ @@ -137,12 +145,13 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal /** * give the list of keys the current export added to the queryBuilder in - * self::initiateQuery + * self::initiateQuery. * * Example: if your query builder will contains `SELECT count(id) AS count_id ...`, * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return array */ public function getQueryKeys($data) @@ -152,7 +161,6 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal $fields = []; foreach ($data['fields'] as $key) { switch ($key) { - case 'ressource__label': case 'moyen_transport__label': foreach ($csperson[$key] as $item) { @@ -164,27 +172,28 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal case 'prescripteur__name': case 'prescripteur__email': case 'prescripteur__phone': - $key = str_replace('__', '.', $key); + $key = str_replace('__', '.', (string) $key); + // no break case 'situation_professionnelle__label': case 'neet_eligibility__label': - case 'accompagnement__label': case 'permis_conduire__label': case 'type_contrat__label': - default: $fields[] = $key; } } + return $fields; } /** * Some fields values are arrays that have to be splitted in columns. - * This function split theses fields + * This function split theses fields. * * @param array $rows + * * @return array|\Closure */ private function splitArrayToColumns($rows) @@ -196,21 +205,17 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal */ $results = []; foreach ($rows as $row) { - /** * @var string $key - * @var mixed $value */ $res = []; foreach ($row as $key => $value) { - switch ($key) { case 'ressource__label': case 'moyen_transport__label': - foreach ($csperson[$key] as $item) { $this->translationCompatKey($item, $key); - if (($value === null)||(count($value) === 0)) { + if ((null === $value) || (0 === count($value))) { $res[$item] = ''; } else { foreach ($value as $v) { @@ -219,25 +224,22 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal if ($item === $v) { $res[$item] = 'x'; break; - } else { - $res[$item] = ''; } + $res[$item] = ''; } } } break; case 'situation_professionnelle__label': - $f = false; - if ($value === 'en_activite') { + if ('en_activite' === $value) { $f = true; } $res[$key] = $value; break; case 'type_contrat__label': - if (! empty($value)) { $res[$key] = ($f) ? $value : null; } else { @@ -248,25 +250,25 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal case 'prescripteur__name': case 'prescripteur__email': case 'prescripteur__phone': + $key = str_replace('__', '.', (string) $key); - $key = str_replace('__', '.', $key); - + // no break case 'neet_eligibility__label': case 'accompagnement__label': case 'permis_conduire__label': - default: $res[$key] = $value; } } $results[] = $res; } + return $results; } /** * Make item compatible with YAML messages ids - * for fields that are splitted in columns (with field key to replace) + * for fields that are splitted in columns (with field key to replace). * * AVANT * key: projet_prof__volume_horaire__label @@ -274,7 +276,7 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal * APRES * item: projet_prof.volume_horaire.temps_plein * - * @param string $item (&) passed by reference + * @param string $item (&) passed by reference * @param string $key */ private function translationCompatKey(&$item, $key) @@ -284,73 +286,64 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal $item = $key; } - /** - * @param FormBuilderInterface $builder - */ public function buildForm(FormBuilderInterface $builder) { parent::buildForm($builder); // ajouter un '?' dans la query $choices = array_combine($this->getFields(), $this->getFields()); - $builder->add('fields', ChoiceType::class, array( + $builder->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, 'choices' => $choices, - 'data' => $choices, //les checkbox cochés !! + 'data' => $choices, + // les checkbox cochés !! 'choices_as_values' => true, 'label' => 'Fields to include in export', - 'choice_label' => function ($key) { - return str_replace('__', '.', $key); - }, - 'choice_attr' => function($val) { - if (substr($val, 0, 8) === 'address_') { + 'choice_label' => fn ($key) => str_replace('__', '.', (string) $key), + 'choice_attr' => function ($val) { + if (str_starts_with($val, 'address_')) { return ['data-display-target' => 'address_date']; - } else { - return []; } + + return []; }, - 'constraints' => [new Callback(array( - 'callback' => function($selected, ExecutionContextInterface $context) { - if (count($selected) === 0) { - $context->buildViolation('You must select at least one element') - ->atPath('fields') - ->addViolation(); - } + 'constraints' => [new Callback(['callback' => function ($selected, ExecutionContextInterface $context) { + if (0 === count($selected)) { + $context->buildViolation('You must select at least one element') + ->atPath('fields') + ->addViolation(); } - ))] - )); + }])], + ]); } /** - * @param array $requiredModifiers - * @param array $acl - * @param array $data * @return \Doctrine\ORM\NativeQuery|\Doctrine\ORM\QueryBuilder + * * @throws \Doctrine\DBAL\Exception\InvalidArgumentException */ - public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(function($el) { return $el['center']; }, $acl); + $centers = array_map(fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!\array_key_exists('fields', $data)) { - throw new \Doctrine\DBAL\Exception\InvalidArgumentException("any fields " - . "have been checked"); + throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked'); } - $qb = $this->entityManager->createQueryBuilder() + return $this->entityManager->createQueryBuilder() ->from('ChillPersonBundle:Person', 'person') ->join('person.center', 'center') ->andWhere('center IN (:authorized_centers)') ->setParameter('authorized_centers', $centers) ; - return $qb; } /** * @param \Doctrine\ORM\NativeQuery|\Doctrine\ORM\QueryBuilder $qb - * @param mixed[] $data + * @param mixed[] $data + * * @return mixed|mixed[] */ public function getResult($qb, $data) @@ -358,14 +351,13 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal $qb->select('person.id'); $ids = $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); - $this->personIds = array_map(function ($e) { return $e['id']; }, $ids); + $this->personIds = array_map(fn ($e) => $e['id'], $ids); - $personIdsParameters = '?'. \str_repeat(', ?', count($this->personIds) -1); + $personIdsParameters = '?'.\str_repeat(', ?', count($this->personIds) - 1); $query = \str_replace('%person_ids%', $personIdsParameters, self::QUERY); $rsm = new Query\ResultSetMapping(); - foreach ($this->allFields() as $name => $type) { if ($data['fields'][$name]) { $rsm->addScalarResult(strtolower($name), $name, $type); @@ -375,13 +367,13 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal $nq = $this->entityManager->createNativeQuery($query, $rsm); $idx = 0; - for ($i=1; $i<=8; $i++) { - $idx++; + for ($i = 1; $i <= 8; ++$i) { + ++$idx; $nq->setParameter($idx, $data['address_date'], 'date'); } - for ($i=1; $i<=(count($this->personIds)); $i++) { - $idx++; - $nq->setParameter($idx, $this->personIds[$i-1]); + for ($i = 1; $i <= count($this->personIds); ++$i) { + ++$idx; + $nq->setParameter($idx, $this->personIds[$i - 1]); } return $this->splitArrayToColumns( @@ -390,9 +382,9 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal } /** - * @param string $key The column key, as added in the query + * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm` + * @param mixed $data The data from the export's form (as defined in `buildForm` * * @return \Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ @@ -400,92 +392,89 @@ class ListCSPerson extends ListPerson implements ListInterface, ExportElementVal { $csperson = self::CSPERSON; - switch ($key) { - case 'countryOfBirth': - case 'situation_familiale': - case 'closingmotive': - case 'nationality': - return function ($value) use ($key) { - if ($value === '_header') { return $key; } - return $value['fr']; - }; - case 'accompagnement__label': - case 'permis_conduire__label': - case 'type_contrat__label': - return function ($value) use ($key, $csperson) { - if ($value === '_header') { - return $this->translator->trans( - str_replace('__', '.', $key) - ); - } - if (empty($value)) { return ''; } - $arr = []; - foreach ($value as $v) { - $this->translationCompatKey($v, $key); - $arr[] = $this->translator->trans($v); - } - return implode(', ', $arr); - }; - case 'situation_professionnelle__label': - case 'neet_eligibility__label': - return function ($value) use ($key) { - if ($value === '_header') { - return $this->translator->trans( - str_replace('__', '.', $key) - ); - } - if (empty($value)) { return ''; } - $this->translationCompatKey($value, $key); - return $this->translator->trans($value); - }; - case 'birthdate': - case 'address_valid_from': - case 'recentopeningdate': - case 'recentclosingdate': - case 'findernieremploidate': - case 'cafinscriptiondate': - case 'contratiejdate': - case 'cerinscriptiondate': - case 'ppaeinscriptiondate': - case 'neetcommissiondate': - case 'datefindernieremploi': - /** @var \DateTime $value */ - return function($value) use ($key) { - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $value->format('d-m-Y'); - }; + return match ($key) { + 'countryOfBirth', 'situation_familiale', 'closingmotive', 'nationality' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } - // remplace les getLabels de ListPerson - // (pas possible d'utiliser parent qui appelle une méthode private pour les customfields) - case 'gender' : - return function ($value) { - if ($value === '_header') { return 'gender'; } - return $this->translator->trans($value); - }; - case 'address_country_name': - return function ($value) use ($key) { - if ($value === '_header') { return \strtolower($key); } - if ($value === null) { return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); - }; - case 'address_isnoaddress': - return parent::getLabels($key, $values, $data); - default: - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - if (empty($value)) { return ''; } - return $value; - }; - } + return $value['fr']; + }, + 'accompagnement__label', 'permis_conduire__label', 'type_contrat__label' => function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans( + str_replace('__', '.', $key) + ); + } + if (empty($value)) { + return ''; + } + $arr = []; + foreach ($value as $v) { + $this->translationCompatKey($v, $key); + $arr[] = $this->translator->trans($v); + } + + return implode(', ', $arr); + }, + 'situation_professionnelle__label', 'neet_eligibility__label' => function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans( + str_replace('__', '.', $key) + ); + } + if (empty($value)) { + return ''; + } + $this->translationCompatKey($value, $key); + + return $this->translator->trans($value); + }, + 'birthdate', 'address_valid_from', 'recentopeningdate', 'recentclosingdate', 'findernieremploidate', 'cafinscriptiondate', 'contratiejdate', 'cerinscriptiondate', 'ppaeinscriptiondate', 'neetcommissiondate', 'datefindernieremploi' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $value->format('d-m-Y'); + }, + 'gender' => function ($value) { + if ('_header' === $value) { + return 'gender'; + } + + return $this->translator->trans($value); + }, + 'address_country_name' => function ($value) use ($key) { + if ('_header' === $value) { + return \strtolower($key); + } + if (null === $value) { + return ''; + } + + return $this->translatableStringHelper->localize(json_decode($value, true)); + }, + 'address_isnoaddress' => parent::getLabels($key, $values, $data), + default => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $value; + }, + }; } /** - * Native Query SQL + * Native Query SQL. */ - const QUERY = << 'integer', 'firstname' => 'string', 'lastname' => 'string', @@ -52,8 +59,6 @@ class ListCV implements ListInterface, ExportElementValidatedInterface /** * ListAcquisition constructor. - * - * @param EntityManagerInterface $em */ public function __construct(EntityManagerInterface $em) { @@ -65,24 +70,21 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * violation on the data. * * @param mixed $data the data, as returned by the user - * @param ExecutionContextInterface $context */ public function validateForm($data, ExecutionContextInterface $context) {} /** - * get a title, which will be used in UI (and translated) + * get a title, which will be used in UI (and translated). * * @return string */ public function getTitle() { - return "Liste des CVs par personne"; + return 'Liste des CVs par personne'; } /** * Add a form to collect data from the user. - * - * @param FormBuilderInterface $builder */ public function buildForm(FormBuilderInterface $builder) { @@ -98,34 +100,34 @@ class ListCV implements ListInterface, ExportElementValidatedInterface 'attr' => ['class' => ''], 'constraints' => [new Callback([ 'callback' => function ($selected, ExecutionContextInterface $context) { - if (count($selected) === 0) { + if (0 === count($selected)) { $context ->buildViolation('You must select at least one element') ->atPath('fields') ->addViolation(); } - } - ])] + }, + ])], ]) ->add('reportdate_min', ChillDateType::class, [ 'label' => 'Date du rapport après le', 'required' => false, 'label_attr' => [ - 'class' => 'reportdate_range' + 'class' => 'reportdate_range', ], 'attr' => [ - 'class' => 'reportdate_range' - ] + 'class' => 'reportdate_range', + ], ]) ->add('reportdate_max', ChillDateType::class, [ 'label' => 'Date du rapport avant le', 'required' => false, 'label_attr' => [ - 'class' => 'report_date_range' + 'class' => 'report_date_range', ], 'attr' => [ - 'class' => 'report_date_range' - ] + 'class' => 'report_date_range', + ], ]) ; } @@ -151,7 +153,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface */ public function getDescription() { - return "Crée une liste des CVs en fonction de différents paramètres."; + return 'Crée une liste des CVs en fonction de différents paramètres.'; } /** @@ -164,12 +166,12 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * * The returned object should be an instance of QueryBuilder or NativeQuery. * - * @param array $requiredModifiers - * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` + * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` * @param array $data the data from the form, if any - * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute. + * + * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute */ - public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { return $this->entityManager->createQueryBuilder() ->from('ChillPersonBundle:Person', 'person'); @@ -184,14 +186,13 @@ class ListCV implements ListInterface, ExportElementValidatedInterface */ public function supportsModifiers() { - return [ 'cv', 'person' ]; + return ['cv', 'person']; } /** * Return the required Role to execute the Export. * - * @return \Symfony\Component\Security\Core\Role\Role - * + * @return Role */ public function requiredRole() { @@ -205,17 +206,18 @@ class ListCV implements ListInterface, ExportElementValidatedInterface */ public function getAllowedFormattersTypes() { - return [ FormatterInterface::TYPE_LIST ]; + return [FormatterInterface::TYPE_LIST]; } /** * give the list of keys the current export added to the queryBuilder in - * self::initiateQuery + * self::initiateQuery. * * Example: if your query builder will contains `SELECT count(id) AS count_id ...`, * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return array */ public function getQueryKeys($data) @@ -224,7 +226,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface } /** - * Return array FIELDS keys only + * Return array FIELDS keys only. * * @return array */ @@ -237,7 +239,8 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * Return the results of the query builder. * * @param QueryBuilder|\Doctrine\ORM\NativeQuery $qb - * @param mixed[] $data the data from the export's form (added by self::buildForm) + * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return mixed[] an array of results */ public function getResult($qb, $data) @@ -245,8 +248,8 @@ class ListCV implements ListInterface, ExportElementValidatedInterface $qb->select('person.id'); $ids = $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); - $this->personIds = array_map(function ($e) { return $e['id']; }, $ids); - $personIdsParameters = '?'. \str_repeat(', ?', count($this->personIds) -1); + $this->personIds = array_map(fn ($e) => $e['id'], $ids); + $personIdsParameters = '?'.\str_repeat(', ?', count($this->personIds) - 1); $query = \str_replace('%person_ids%', $personIdsParameters, self::QUERY); $rsm = new Query\ResultSetMapping(); @@ -260,12 +263,12 @@ class ListCV implements ListInterface, ExportElementValidatedInterface $nq = $this->entityManager->createNativeQuery($query, $rsm); $idx = 1; - for ($i=1; $i<=(count($this->personIds)); $i++) { - $idx++; - $nq->setParameter($i, $this->personIds[$i-1]); + for ($i = 1; $i <= count($this->personIds); ++$i) { + ++$idx; + $nq->setParameter($i, $this->personIds[$i - 1]); } $nq->setParameter($idx++, $data['reportdate_min'], 'date'); - $nq->setParameter($idx , $data['reportdate_max'], 'date'); + $nq->setParameter($idx, $data['reportdate_max'], 'date'); return $nq->getResult(); } @@ -309,56 +312,57 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * which do not need to be translated, or value already translated in * database. But the header must be, in every case, translated. * - * - * @param string $key The column key, as added in the query + * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm` + * @param mixed $data The data from the export's form (as defined in `buildForm` + * * @return \Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ public function getLabels($key, array $values, $data) { + return match ($key) { + 'birthdate' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } - switch ($key) { - case 'birthdate': - /** @var \DateTime $value */ - return function($value) use ($key) { - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $value->format('d-m-Y'); - }; - case 'countryofbirth': - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - return $value['fr']; - }; - case 'gender': - return function ($value) use ($key) { - $gend_array = [ 'man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé' ]; - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $gend_array[$value]; - }; - case 'id': - case 'firstname': - case 'lastname': - case 'placeofbirth': - case 'formationlevel': - default: - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - return $value; - }; - } + return $value->format('d-m-Y'); + }, + 'countryofbirth' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + + return $value['fr']; + }, + 'gender' => function ($value) use ($key) { + $gend_array = ['man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé']; + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $gend_array[$value]; + }, + default => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + + return $value; + }, + }; } /** - * Native Query SQL + * Native Query SQL. */ - const QUERY = << Frein::FREINS_PERSO, 'freinsemploi' => Frein::FREINS_EMPLOI, ]; @@ -38,7 +45,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface /** * @var array */ - const FIELDS = [ + public const FIELDS = [ 'id' => 'integer', 'firstname' => 'string', 'lastname' => 'string', @@ -58,8 +65,6 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface */ protected $personIds = []; - - /** * @var EntityManagerInterface */ @@ -67,8 +72,6 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface /** * ListAcquisition constructor. - * - * @param EntityManagerInterface $em */ public function __construct(EntityManagerInterface $em) { @@ -80,24 +83,21 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * violation on the data. * * @param mixed $data the data, as returned by the user - * @param ExecutionContextInterface $context */ public function validateForm($data, ExecutionContextInterface $context) {} /** - * get a title, which will be used in UI (and translated) + * get a title, which will be used in UI (and translated). * * @return string */ public function getTitle() { - return "Liste des freins identifiés par personne"; + return 'Liste des freins identifiés par personne'; } /** * Add a form to collect data from the user. - * - * @param FormBuilderInterface $builder */ public function buildForm(FormBuilderInterface $builder) { @@ -113,7 +113,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface 'attr' => ['class' => ''], 'constraints' => [new Callback([ 'callback' => function ($selected, ExecutionContextInterface $context) { - if (count($selected) === 0) { + if (0 === count($selected)) { $context ->buildViolation('You must select at least one element') ->atPath('fields') @@ -166,7 +166,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface */ public function getDescription() { - return "Crée une liste des personnes et de leurs freins identifiés en fonction de différents paramètres."; + return 'Crée une liste des personnes et de leurs freins identifiés en fonction de différents paramètres.'; } /** @@ -179,15 +179,15 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * * The returned object should be an instance of QueryBuilder or NativeQuery. * - * @param array $requiredModifiers - * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` + * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` * @param array $data the data from the form, if any - * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute. + * + * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute */ - public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { return $this->entityManager->createQueryBuilder() - ->from('ChillPersonBundle:Person', 'person'); + ->from('ChillPersonBundle:Person', 'person'); } /** @@ -199,14 +199,13 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface */ public function supportsModifiers() { - return [ 'frein', 'person' ]; + return ['frein', 'person']; } /** * Return the required Role to execute the Export. * - * @return \Symfony\Component\Security\Core\Role\Role - * + * @return Role */ public function requiredRole() { @@ -220,11 +219,11 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface */ public function getAllowedFormattersTypes() { - return [ FormatterInterface::TYPE_LIST ]; + return [FormatterInterface::TYPE_LIST]; } /** - * Return array FIELDS keys only + * Return array FIELDS keys only. * * @return array */ @@ -235,12 +234,13 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface /** * give the list of keys the current export added to the queryBuilder in - * self::initiateQuery + * self::initiateQuery. * * Example: if your query builder will contains `SELECT count(id) AS count_id ...`, * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return array */ public function getQueryKeys($data) @@ -248,11 +248,9 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface $freins = self::FREINS; $fields = []; foreach ($data['fields'] as $key) { - switch ($key) { case 'freinsperso': case 'freinsemploi': - foreach ($freins[$key] as $item) { $this->translationCompatKey($item, $key); $fields[] = $item; @@ -263,27 +261,29 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface $fields[] = $key; } } + return $fields; } /** * Make key compatible with YAML messages ids - * for fields that are splitted in columns + * for fields that are splitted in columns. * - * @param string $item (&) passed by reference + * @param string $item (&) passed by reference * @param string $key */ private function translationCompatKey(&$item, $key) { $prefix = substr_replace($key, 'freins_', 0, 6); - $item = $prefix .'.'. $item; + $item = $prefix.'.'.$item; } /** * Some fields values are arrays that have to be splitted in columns. - * This function split theses fields + * This function split theses fields. * * @param array $rows + * * @return array|\Closure */ private function splitArrayToColumns($rows) @@ -295,34 +295,27 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface */ $results = []; foreach ($rows as $row) { - /** * @var string $key - * @var mixed $value */ $res = []; foreach ($row as $key => $value) { - switch ($key) { case 'freinsperso': case 'freinsemploi': - foreach ($freins[$key] as $item) { $this->translationCompatKey($item, $key); - if (count($value) === 0) { + if (0 === count($value)) { $res[$item] = ''; - } else { foreach ($value as $v) { - $this->translationCompatKey($v, $key); if ($item === $v) { $res[$item] = 'x'; break; - } else { - $res[$item] = ''; } + $res[$item] = ''; } } } @@ -334,6 +327,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface } $results[] = $res; } + return $results; } @@ -341,7 +335,8 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * Return the results of the query builder. * * @param QueryBuilder|\Doctrine\ORM\NativeQuery $qb - * @param mixed[] $data the data from the export's form (added by self::buildForm) + * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return mixed[]|\closure an array of results */ public function getResult($qb, $data) @@ -349,8 +344,8 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface $qb->select('person.id'); $ids = $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); - $this->personIds = array_map(function ($e) { return $e['id']; }, $ids); - $personIdsParameters = '?'. \str_repeat(', ?', count($this->personIds) -1); + $this->personIds = array_map(fn ($e) => $e['id'], $ids); + $personIdsParameters = '?'.\str_repeat(', ?', count($this->personIds) - 1); $query = \str_replace('%person_ids%', $personIdsParameters, self::QUERY); $rsm = new Query\ResultSetMapping(); @@ -364,12 +359,12 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface $nq = $this->entityManager->createNativeQuery($query, $rsm); $idx = 1; - for ($i=1; $i<=(count($this->personIds)); $i++) { - $idx++; - $nq->setParameter($i, $this->personIds[$i-1]); + for ($i = 1; $i <= count($this->personIds); ++$i) { + ++$idx; + $nq->setParameter($i, $this->personIds[$i - 1]); } $nq->setParameter($idx++, $data['reportdate_min'], 'date'); - $nq->setParameter($idx , $data['reportdate_max'], 'date'); + $nq->setParameter($idx, $data['reportdate_max'], 'date'); return $this->splitArrayToColumns( $nq->getResult() @@ -415,60 +410,60 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * which do not need to be translated, or value already translated in * database. But the header must be, in every case, translated. * - * - * @param string $key The column key, as added in the query + * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm` + * @param mixed $data The data from the export's form (as defined in `buildForm` + * * @return \Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ public function getLabels($key, array $values, $data) { + return match ($key) { + 'reportdate', 'birthdate' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } - switch ($key) { - case 'reportdate': - case 'birthdate': - /** @var \DateTime $value */ - return function($value) use ($key) { - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $value->format('d-m-Y'); - }; - case 'countryofbirth': - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - return $value['fr']; - }; - case 'gender': - return function ($value) use ($key) { - $gend_array = [ 'man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé' ]; - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $gend_array[$value]; - }; - case 'id': - case 'firstname': - case 'lastname': - case 'placeofbirth': - case 'notesperso': - case 'notesemploi': - default: - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - if (empty($value)) { return ''; } - return $value; - }; - } + return $value->format('d-m-Y'); + }, + 'countryofbirth' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + + return $value['fr']; + }, + 'gender' => function ($value) use ($key) { + $gend_array = ['man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé']; + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $gend_array[$value]; + }, + default => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $value; + }, + }; } - /** - * Native Query SQL + * Native Query SQL. */ - const QUERY = << ProjetProfessionnel::TYPE_CONTRAT, - 'projet_prof__volume_horaire__label' => ProjetProfessionnel::VOLUME_HORAIRES + 'projet_prof__volume_horaire__label' => ProjetProfessionnel::VOLUME_HORAIRES, ]; /** * @var array */ - const FIELDS = [ + public const FIELDS = [ 'id' => 'integer', 'firstname' => 'string', 'lastname' => 'string', @@ -70,8 +77,6 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn /** * ListAcquisition constructor. - * - * @param EntityManagerInterface $em */ public function __construct(EntityManagerInterface $em) { @@ -83,24 +88,21 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * violation on the data. * * @param mixed $data the data, as returned by the user - * @param ExecutionContextInterface $context */ public function validateForm($data, ExecutionContextInterface $context) {} /** - * get a title, which will be used in UI (and translated) + * get a title, which will be used in UI (and translated). * * @return string */ public function getTitle() { - return "Liste des projets professionnels par personne"; + return 'Liste des projets professionnels par personne'; } /** * Add a form to collect data from the user. - * - * @param FormBuilderInterface $builder */ public function buildForm(FormBuilderInterface $builder) { @@ -110,16 +112,14 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn 'expanded' => true, 'choices_as_values' => true, 'label' => 'Fields to include in export', - 'choice_label' => function ($key) { - return str_replace('__', '.', $key); - }, + 'choice_label' => fn ($key) => str_replace('__', '.', (string) $key), 'choices' => array_combine($this->getFields(), $this->getFields()), 'data' => array_combine($this->getFields(), $this->getFields()), 'choice_attr' => [], 'attr' => ['class' => ''], 'constraints' => [new Callback([ 'callback' => function ($selected, ExecutionContextInterface $context) { - if (count($selected) === 0) { + if (0 === count($selected)) { $context ->buildViolation('You must select at least one element') ->atPath('fields') @@ -172,7 +172,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn */ public function getDescription() { - return "Crée une liste des personnes et de leur projet professionnel en fonction de différents paramètres."; + return 'Crée une liste des personnes et de leur projet professionnel en fonction de différents paramètres.'; } /** @@ -185,12 +185,12 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * * The returned object should be an instance of QueryBuilder or NativeQuery. * - * @param array $requiredModifiers - * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` + * @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )` * @param array $data the data from the form, if any - * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute. + * + * @return QueryBuilder|\Doctrine\ORM\NativeQuery the query to execute */ - public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { return $this->entityManager->createQueryBuilder() ->from('ChillPersonBundle:Person', 'person'); @@ -205,14 +205,13 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn */ public function supportsModifiers() { - return [ 'projetprofessionnel', 'person' ]; + return ['projetprofessionnel', 'person']; } /** * Return the required Role to execute the Export. * - * @return \Symfony\Component\Security\Core\Role\Role - * + * @return Role */ public function requiredRole() { @@ -226,11 +225,11 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn */ public function getAllowedFormattersTypes() { - return [ FormatterInterface::TYPE_LIST ]; + return [FormatterInterface::TYPE_LIST]; } /** - * Return array FIELDS keys only + * Return array FIELDS keys only. * * @return array */ @@ -241,12 +240,13 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn /** * give the list of keys the current export added to the queryBuilder in - * self::initiateQuery + * self::initiateQuery. * * Example: if your query builder will contains `SELECT count(id) AS count_id ...`, * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return array */ public function getQueryKeys($data) @@ -255,37 +255,37 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn $fields = []; foreach ($data['fields'] as $key) { - switch ($key) { case 'projet_prof__type_contrat__label': case 'projet_prof__volume_horaire__label': - foreach ($projet_professionnel[$key] as $item) { $this->translationCompatKey($item, $key); $fields[] = $item; } break; - case "projet_prof__souhait__code": - case "projet_prof__type_contrat__note": - case "projet_prof__volume_horaire__note": - case "projet_prof__idee": - case "projet_prof__encoursdeconstruction": - case "projet_prof__valide__note": - case "projet_prof__valide__code": - case "projet_prof__note": - $key = str_replace('__', '.', $key); + case 'projet_prof__souhait__code': + case 'projet_prof__type_contrat__note': + case 'projet_prof__volume_horaire__note': + case 'projet_prof__idee': + case 'projet_prof__encoursdeconstruction': + case 'projet_prof__valide__note': + case 'projet_prof__valide__code': + case 'projet_prof__note': + $key = str_replace('__', '.', (string) $key); + // no break default: $fields[] = $key; } } + return $fields; } /** * Make item compatible with YAML messages ids - * for fields that are splitted in columns (with field key to replace) + * for fields that are splitted in columns (with field key to replace). * * AVANT * key: projet_prof__volume_horaire__label @@ -293,7 +293,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * APRES * item: projet_prof.volume_horaire.temps_plein * - * @param string $item (&) passed by reference + * @param string $item (&) passed by reference * @param string $key */ private function translationCompatKey(&$item, $key) @@ -305,9 +305,10 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn /** * Some fields values are arrays that have to be splitted in columns. - * This function split theses fields + * This function split theses fields. * * @param array $rows + * * @return array|\Closure */ private function splitArrayToColumns($rows) @@ -319,24 +320,19 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn */ $results = []; foreach ($rows as $row) { - /** * @var string $key - * @var mixed $value */ $res = []; foreach ($row as $key => $value) { - switch ($key) { case 'projet_prof__type_contrat__label': case 'projet_prof__volume_horaire__label': - foreach ($projet_professionnel[$key] as $item) { $this->translationCompatKey($item, $key); - if (count($value) === 0) { + if (0 === count($value)) { $res[$item] = ''; - } else { foreach ($value as $v) { $this->translationCompatKey($v, $key); @@ -344,30 +340,31 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn if ($item === $v) { $res[$item] = 'x'; break; - } else { - $res[$item] = ''; } + $res[$item] = ''; } } } break; - case "projet_prof__souhait__code": - case "projet_prof__type_contrat__note": - case "projet_prof__volume_horaire__note": - case "projet_prof__idee": - case "projet_prof__encoursdeconstruction": - case "projet_prof__valide__note": - case "projet_prof__valide__code": - case "projet_prof__note": - $key = str_replace('__', '.', $key); + case 'projet_prof__souhait__code': + case 'projet_prof__type_contrat__note': + case 'projet_prof__volume_horaire__note': + case 'projet_prof__idee': + case 'projet_prof__encoursdeconstruction': + case 'projet_prof__valide__note': + case 'projet_prof__valide__code': + case 'projet_prof__note': + $key = str_replace('__', '.', (string) $key); + // no break default: $res[$key] = $value; } } $results[] = $res; } + return $results; } @@ -375,16 +372,17 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * Return the results of the query builder. * * @param QueryBuilder|\Doctrine\ORM\NativeQuery $qb - * @param mixed[] $data the data from the export's form (added by self::buildForm) + * @param mixed[] $data the data from the export's form (added by self::buildForm) + * * @return mixed[] an array of results */ public function getResult($qb, $data) { - $qb->select('person.id'); + $qb->select('person.id'); $ids = $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); - $this->personIds = array_map(function ($e) { return $e['id']; }, $ids); - $personIdsParameters = '?'. \str_repeat(', ?', count($this->personIds) -1); + $this->personIds = array_map(fn ($e) => $e['id'], $ids); + $personIdsParameters = '?'.\str_repeat(', ?', count($this->personIds) - 1); $query = \str_replace('%person_ids%', $personIdsParameters, self::QUERY); $rsm = new Query\ResultSetMapping(); @@ -398,12 +396,12 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn $nq = $this->entityManager->createNativeQuery($query, $rsm); $idx = 1; - for ($i=1; $i<=(count($this->personIds)); $i++) { - $idx++; - $nq->setParameter($i, $this->personIds[$i-1]); + for ($i = 1; $i <= count($this->personIds); ++$i) { + ++$idx; + $nq->setParameter($i, $this->personIds[$i - 1]); } $nq->setParameter($idx++, $data['reportdate_min'], 'date'); - $nq->setParameter($idx , $data['reportdate_max'], 'date'); + $nq->setParameter($idx, $data['reportdate_max'], 'date'); return $this->splitArrayToColumns( $nq->getResult() @@ -449,63 +447,70 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * which do not need to be translated, or value already translated in * database. But the header must be, in every case, translated. * - * - * @param string $key The column key, as added in the query + * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm` + * @param mixed $data The data from the export's form (as defined in `buildForm` + * * @return \Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ public function getLabels($key, array $values, $data) { - switch ($key) { - case 'birthdate': - /** @var \DateTime $value */ - return function($value) use ($key) { - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $value->format('d-m-Y'); - }; - case 'countryofbirth': - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - return $value['fr']; - }; - case 'projet_prof.valide.code': - case 'projet_prof.souhait.code': - return function ($value) use ($key) { - if ($value === '_header') { return $key; } - if ($value === '{NULL}') { return ''; } - return str_replace(['{','}'], '', $value); - }; - case 'gender': - return function ($value) use ($key) { - $gend_array = [ 'man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé' ]; - if ($value === '_header') { return $key; } - if (empty($value)) { return ''; } - return $gend_array[$value]; - }; - case 'id': - case 'firstname': - case 'lastname': - case 'placeofbirth': + return match ($key) { + 'birthdate' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } - default: - return function ($value) use ($key) { - if ($value === '_header') { - return $key; - } - if (empty($value)) { return ''; } - return $value; - }; - } + return $value->format('d-m-Y'); + }, + 'countryofbirth' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + + return $value['fr']; + }, + 'projet_prof.valide.code', 'projet_prof.souhait.code' => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if ('{NULL}' === $value) { + return ''; + } + + return str_replace(['{', '}'], '', $value); + }, + 'gender' => function ($value) use ($key) { + $gend_array = ['man' => 'Homme', 'woman' => 'Femme', 'both' => 'Indéterminé']; + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $gend_array[$value]; + }, + default => function ($value) use ($key) { + if ('_header' === $value) { + return $key; + } + if (empty($value)) { + return ''; + } + + return $value; + }, + }; } /** - * Native Query SQL + * Native Query SQL. */ - const QUERY = << 'Accompagnement', 'multiple' => true, 'expanded' => true, - 'choice_label' => function($k) { return 'accompagnement.'.$k; } - ]) + 'choice_label' => fn ($k) => 'accompagnement.'.$k, + ]) ->add('accompagnementRQTHDate', ChillDateType::class, [ 'label' => "Date d'accompagnement RQTH", 'required' => false, - - ]) - ->add('accompagnementComment', TextAreaType::class, [ - 'label' => "Accompagnement autre: précisions", + ]) + ->add('accompagnementComment', TextareaType::class, [ + 'label' => 'Accompagnement autre: précisions', 'required' => false, - ]) ->add('poleEmploiId', TextType::class, [ - 'label' => "Identifiant pôle emploi", + 'label' => 'Identifiant pôle emploi', 'required' => false, ]) ->add('poleEmploiInscriptionDate', ChillDateType::class, [ 'label' => "Date d'inscription Pôle emploi", - 'required' => false + 'required' => false, ]) ->add('cafId', TextType::class, [ - 'label' => "Numéro allocataire CAF", - 'required' => false + 'label' => 'Numéro allocataire CAF', + 'required' => false, ]) ->add('cafInscriptionDate', ChillDateType::class, [ 'label' => "Date d'inscription à la CAF", - 'required' => false + 'required' => false, ]) ->add('cERInscriptionDate', ChillDateType::class, [ - 'label' => "Date CER", - 'required' => false + 'label' => 'Date CER', + 'required' => false, ]) ->add('pPAEInscriptionDate', ChillDateType::class, [ - 'label' => "Date PPAE", - 'required' => false + 'label' => 'Date PPAE', + 'required' => false, ]) ->add('nEETEligibilite', ChoiceType::class, [ - 'label' => "Éligibilité NEET", + 'label' => 'Éligibilité NEET', 'choices' => \array_combine(CSPerson::NEET_ELIGIBILITY, CSPerson::NEET_ELIGIBILITY), - 'choice_label' => function($k) { return 'neet_eligibility.'.$k; }, + 'choice_label' => fn ($k) => 'neet_eligibility.'.$k, 'multiple' => false, 'expanded' => true, - 'required' => false + 'required' => false, ]) ->add('cERSignataire', TextType::class, [ - 'label' => "Signataire CER", - 'required' => false + 'label' => 'Signataire CER', + 'required' => false, ]) ->add('pPAESignataire', TextType::class, [ - 'label' => "Signataire PPAE", - 'required' => false + 'label' => 'Signataire PPAE', + 'required' => false, ]) ->add('nEETCommissionDate', ChillDateType::class, [ - 'label' => "Date commission NEET", - 'required' => false + 'label' => 'Date commission NEET', + 'required' => false, ]) ->add('fSEMaDemarcheCode', TextType::class, [ 'label' => 'Code "Ma démarche FSE"', - 'required' => false + 'required' => false, ]) ->add('prescripteur', PickThirdPartyType::class, [ 'required' => false, 'types' => ['prescripteur'], 'label' => 'Prescripteur', - 'center' => $options['center'] + 'center' => $options['center'], ]) ->add('dispositifsNotes', TextareaType::class, [ 'required' => false, - 'label' => "Notes" + 'label' => 'Notes', ]) ->add('dateContratIEJ', ChillDateType::class, [ 'required' => false, - 'label' => " Date du contrat d’engagement IEJ" + 'label' => ' Date du contrat d’engagement IEJ', ]) ->add('dateAvenantIEJ', ChillDateType::class, [ 'required' => false, - 'label' => " Date de l'avenant IEJ" + 'label' => " Date de l'avenant IEJ", ]); } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\CSPerson' - )); + $resolver->setDefaults(['data_class' => CSPerson::class]); $resolver ->setDefined('center') ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]) - ; + ; } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_csperson'; diff --git a/src/Bundle/ChillJobBundle/src/Form/CSPersonPersonalSituationType.php b/src/Bundle/ChillJobBundle/src/Form/CSPersonPersonalSituationType.php index 2b2a8fa23..ea6896553 100644 --- a/src/Bundle/ChillJobBundle/src/Form/CSPersonPersonalSituationType.php +++ b/src/Bundle/ChillJobBundle/src/Form/CSPersonPersonalSituationType.php @@ -1,5 +1,14 @@ add('personMaritalStatus', Select2MaritalStatusType::class, array( - 'required' => false, - 'label' => 'État civil' - )) + ->add('personMaritalStatus', Select2MaritalStatusType::class, ['required' => false, 'label' => 'État civil']) ->add('situationLogement', ChoiceType::class, [ 'choices' => \array_combine( CSPerson::SITUATIONS_LOGEMENTS, - CSPerson::SITUATIONS_LOGEMENTS), - 'choice_label' => function($k) { return 'situation_logement.'.$k; }, + CSPerson::SITUATIONS_LOGEMENTS + ), + 'choice_label' => fn ($k) => 'situation_logement.'.$k, 'required' => false, 'label' => 'Situation de logement', 'multiple' => false, - 'expanded' => true + 'expanded' => true, ]) ->add('situationLogementPrecision', TextareaType::class, [ 'label' => 'Précisions', - 'required' => false + 'required' => false, ]) ->add('enfantACharge', IntegerType::class, [ 'label' => 'Enfants à charge', - 'required' => false + 'required' => false, ]) ->add('niveauMaitriseLangue', ChoiceType::class, [ 'choices' => \array_combine( CSPerson::NIVEAU_MAITRISE_LANGUE, - CSPerson::NIVEAU_MAITRISE_LANGUE), - 'choice_label' => function($k) { return 'niveau_maitrise_langue.'.$k; }, + CSPerson::NIVEAU_MAITRISE_LANGUE + ), + 'choice_label' => fn ($k) => 'niveau_maitrise_langue.'.$k, 'multiple' => true, 'required' => false, 'expanded' => true, - 'label' => 'Maitrise de la langue française' + 'label' => 'Maitrise de la langue française', ]) ->add('vehiculePersonnel', ChoiceType::class, [ 'choices' => [ 'Oui' => true, - 'Non' => false + 'Non' => false, ], 'required' => false, - 'multiple' => false + 'multiple' => false, ]) ->add('permisConduire', ChoiceType::class, [ 'choices' => [ - \array_combine(CSPerson::PERMIS_CONDUIRE, CSPerson::PERMIS_CONDUIRE) + \array_combine(CSPerson::PERMIS_CONDUIRE, CSPerson::PERMIS_CONDUIRE), ], 'label' => 'Permis de conduire', 'required' => false, 'multiple' => true, 'expanded' => true, - 'choice_label' => function($k) { return 'permis_conduire.'.$k; } + 'choice_label' => fn ($k) => 'permis_conduire.'.$k, ]) ->add('situationProfessionnelle', ChoiceType::class, [ 'choices' => \array_combine(CSPerson::SITUATION_PROFESSIONNELLE, CSPerson::SITUATION_PROFESSIONNELLE), 'required' => false, 'multiple' => false, 'expanded' => true, - 'choice_label' => function($k) { return 'situation_professionnelle.'.$k; } + 'choice_label' => fn ($k) => 'situation_professionnelle.'.$k, ]) ->add('dateFinDernierEmploi', ChillDateType::class, [ 'label' => 'Date de la fin du dernier emploi', - 'required' => false + 'required' => false, ]) ->add('typeContrat', ChoiceType::class, [ 'choices' => \array_combine(CSPerson::TYPE_CONTRAT, CSPerson::TYPE_CONTRAT), @@ -92,33 +97,33 @@ class CSPersonPersonalSituationType extends AbstractType 'required' => false, 'multiple' => true, 'expanded' => true, - 'choice_label' => function($k) { return 'type_contrat.'.$k; } + 'choice_label' => fn ($k) => 'type_contrat.'.$k, ]) ->add('typeContratAide', TextType::class, [ - 'label' => "Type de contrat aidé", - 'required' => false + 'label' => 'Type de contrat aidé', + 'required' => false, ]) ->add('ressources', ChoiceType::class, [ 'choices' => \array_combine(CSPerson::RESSOURCES, CSPerson::RESSOURCES), - 'choice_label' => function($k) { return 'ressource.'.$k; }, + 'choice_label' => fn ($k) => 'ressource.'.$k, 'required' => false, 'multiple' => true, 'expanded' => true, ]) ->add('ressourcesComment', TextareaType::class, [ 'label' => 'Information autre ressource', - 'required' => false + 'required' => false, ]) ->add('ressourceDate1Versement', ChillDateType::class, [ 'label' => "Date du premier versement (si bénéficiaire d'une aide)", 'required' => false, ]) ->add('cPFMontant', MoneyType::class, [ - 'label' => "Montant CPF", + 'label' => 'Montant CPF', 'required' => false, ]) ->add('acompteDIF', MoneyType::class, [ - 'label' => "Compte DIF", + 'label' => 'Compte DIF', 'required' => false, ]) ->add('handicapIs', ChoiceType::class, [ @@ -126,7 +131,7 @@ class CSPersonPersonalSituationType extends AbstractType 'required' => false, 'choices' => [ 'Oui' => true, - 'Non' => false + 'Non' => false, ], 'multiple' => false, 'expanded' => true, @@ -141,123 +146,113 @@ class CSPersonPersonalSituationType extends AbstractType 'multiple' => false, 'expanded' => true, 'choices' => \array_combine(CSPerson::HANDICAP_RECOMMANDATIONS, CSPerson::HANDICAP_RECOMMANDATIONS), - 'choice_label' => function($k) { return 'handicap_recommandation.'.$k; } + 'choice_label' => fn ($k) => 'handicap_recommandation.'.$k, ]) ->add('handicapAccompagnement', PickThirdPartyType::class, [ 'center' => $options['center'], - 'types' => [ 'prescripteur' ], + 'types' => ['prescripteur'], 'required' => false, - 'multiple' => false + 'multiple' => false, ]) ->add('mobiliteMoyenDeTransport', ChoiceType::class, [ 'required' => false, 'multiple' => true, 'expanded' => true, - 'label' => "Moyens de transports accessibles", + 'label' => 'Moyens de transports accessibles', 'choices' => \array_combine( CSPerson::MOBILITE_MOYEN_TRANSPORT, - CSPerson::MOBILITE_MOYEN_TRANSPORT), - 'choice_label' => function($k) { - return 'moyen_transport.'.$k; - } + CSPerson::MOBILITE_MOYEN_TRANSPORT + ), + 'choice_label' => fn ($k) => 'moyen_transport.'.$k, ]) ->add('mobiliteNotes', TextareaType::class, [ 'required' => false, - 'label' => "Notes concernant la mobilité" + 'label' => 'Notes concernant la mobilité', ]) ->add('documentCV', StoredObjectType::class, [ 'label' => 'CV', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAgrementIAE', StoredObjectType::class, [ 'label' => 'Document Agrément IAE', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentRQTH', StoredObjectType::class, [ 'label' => 'Document RQTH', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAttestationNEET', StoredObjectType::class, [ 'label' => 'Attestation NEET', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentCI', StoredObjectType::class, [ 'label' => 'Carte d\'identité', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentTitreSejour', StoredObjectType::class, [ 'label' => 'Titre de séjour', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAttestationFiscale', StoredObjectType::class, [ 'label' => 'Attestation fiscale', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentPermis', StoredObjectType::class, [ 'label' => 'Permis', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAttestationCAAF', StoredObjectType::class, [ 'label' => 'Attestation CAF', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentContraTravail', StoredObjectType::class, [ 'label' => 'Contrat de travail', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAttestationFormation', StoredObjectType::class, [ 'label' => 'Attestation formation', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentQuittanceLoyer', StoredObjectType::class, [ 'label' => 'Quittance de loyer', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentFactureElectricite', StoredObjectType::class, [ 'label' => 'Facture d\'électricité', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) ->add('documentAttestationSecuriteSociale', StoredObjectType::class, [ 'label' => 'Attestation de sécurité sociale', 'required' => false, - 'error_bubbling' => false + 'error_bubbling' => false, ]) - ; - - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\CSPerson' - )); - - $resolver->setRequired('center') - ->setAllowedTypes('center', [ \Chill\MainBundle\Entity\Center::class ]) - ; + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => CSPerson::class]); + + $resolver->setRequired('center') + ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]) + ; } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_csperson'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/CV/ExperienceType.php b/src/Bundle/ChillJobBundle/src/Form/CV/ExperienceType.php index 9950d2b87..6b5e0df3a 100644 --- a/src/Bundle/ChillJobBundle/src/Form/CV/ExperienceType.php +++ b/src/Bundle/ChillJobBundle/src/Form/CV/ExperienceType.php @@ -1,5 +1,14 @@ true, 'label' => 'Poste', 'label_attr' => [ - 'class' => 'required ' - ] + 'class' => 'required ', + ], ]) ->add('structure', TextType::class, [ 'required' => false, - 'label' => "Nom de la structure" + 'label' => 'Nom de la structure', ]) ->add('startDate', ChillDateType::class, [ 'required' => false, - 'label' => 'Date de début' + 'label' => 'Date de début', ]) ->add('endDate', ChillDateType::class, [ 'required' => false, - 'label' => "Date de fin" + 'label' => 'Date de fin', ]) ->add('contratType', ChoiceType::class, [ 'required' => false, 'expanded' => true, 'multiple' => false, 'choices' => \array_combine(Experience::CONTRAT_TYPE, Experience::CONTRAT_TYPE), - 'choice_label' => function($k) { return 'xp_contrat_type.'.$k; } + 'choice_label' => fn ($k) => 'xp_contrat_type.'.$k, ]) ->add('notes', TextareaType::class, [ 'label' => 'Notes', - 'required' => false + 'required' => false, ]) - ; - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\CV\Experience' - )); + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => Experience::class]); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_cv_experience'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/CV/FormationType.php b/src/Bundle/ChillJobBundle/src/Form/CV/FormationType.php index ec1792713..fa0e75982 100644 --- a/src/Bundle/ChillJobBundle/src/Form/CV/FormationType.php +++ b/src/Bundle/ChillJobBundle/src/Form/CV/FormationType.php @@ -1,5 +1,14 @@ add('title', TextType::class, [ 'required' => true, - 'label' => "Nom de la formation", + 'label' => 'Nom de la formation', 'label_attr' => [ - 'class' => 'required ' - ] + 'class' => 'required ', + ], ]) ->add('organisme', TextType::class, [ 'label' => 'Organisme', - 'required' => false + 'required' => false, ]) ->add('startDate', ChillDateType::class, [ 'required' => false, - 'label' => "Date de début" + 'label' => 'Date de début', ]) ->add('endDate', ChillDateType::class, [ 'required' => false, - 'label' => "Date de fin" + 'label' => 'Date de fin', ]) ->add('diplomaObtained', ChoiceType::class, [ - 'label' => "Diplôme obtenu ?", + 'label' => 'Diplôme obtenu ?', 'required' => false, 'multiple' => false, 'expanded' => true, 'choices' => \array_combine(F::DIPLOMA_OBTAINED, F::DIPLOMA_OBTAINED), - 'choice_label' => function($k) { return 'diploma_obtained.'.$k; } + 'choice_label' => fn ($k) => 'diploma_obtained.'.$k, ]) ->add('diplomaReconnue', ChoiceType::class, [ - 'label' => "Diplôme reconnu en France ?", + 'label' => 'Diplôme reconnu en France ?', 'required' => false, 'multiple' => false, 'expanded' => true, 'choices' => \array_combine(F::DIPLOMA_RECONNU, F::DIPLOMA_RECONNU), - 'choice_label' => function($k) { return 'diploma_reconnu.'.$k; } + 'choice_label' => fn ($k) => 'diploma_reconnu.'.$k, ]) - ; - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\CV\Formation' - )); + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => F::class]); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_cv_formation'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/CVType.php b/src/Bundle/ChillJobBundle/src/Form/CVType.php index a4265de2c..38f3ae7eb 100644 --- a/src/Bundle/ChillJobBundle/src/Form/CVType.php +++ b/src/Bundle/ChillJobBundle/src/Form/CVType.php @@ -1,5 +1,14 @@ false, 'expanded' => true, 'choices' => \array_combine(CV::FORMATION_LEVEL, CV::FORMATION_LEVEL), - 'choice_label' => function($k) { return 'formation_level.'.$k; } + 'choice_label' => fn ($k) => 'formation_level.'.$k, ]) ->add('formationType', ChoiceType::class, [ - 'label' => "Type de formation", + 'label' => 'Type de formation', 'required' => false, 'multiple' => false, 'expanded' => true, 'choices' => \array_combine(CV::FORMATION_TYPE, CV::FORMATION_TYPE), - 'choice_label' => function($k) { return 'formation_type.'.$k; } + 'choice_label' => fn ($k) => 'formation_type.'.$k, ]) ->add('spokenLanguages', Select2LanguageType::class, [ 'required' => false, 'multiple' => true, - ]) ->add('notes', TextareaType::class, [ - 'label' => "Note", - 'required' => false + 'label' => 'Note', + 'required' => false, ]) ->add('formations', ChillCollectionType::class, [ - 'label' => "Formations", + 'label' => 'Formations', 'entry_type' => FormationType::class, 'allow_add' => true, 'allow_delete' => true, @@ -59,36 +64,28 @@ class CVType extends AbstractType 'button_remove_label' => 'Retirer cette formation', 'required' => false, 'by_reference' => false, - 'block_name' => 'formation_list' + 'block_name' => 'formation_list', ]) ->add('experiences', ChillCollectionType::class, [ - 'label' => "Expériences", + 'label' => 'Expériences', 'entry_type' => ExperienceType::class, 'allow_add' => true, 'allow_delete' => true, 'button_add_label' => 'Ajouter une expérience', 'button_remove_label' => 'Retirer cette expérience', 'required' => false, - 'by_reference' => false + 'by_reference' => false, ]) - ; - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\CV' - )); + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => CV::class]); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_cv'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php b/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php index aab8fae7a..c1fd33334 100644 --- a/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php +++ b/src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php @@ -1,6 +1,14 @@ validator = $validator; } - public function loadChoiceList($value = null): ChoiceListInterface { return new ArrayChoiceList($this->lazyLoadedAppellations, $value); @@ -73,16 +71,15 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface public function loadChoicesForValues($values, $value = null) { - $choices = []; - foreach($values as $v) { + foreach ($values as $v) { if (empty($v)) { continue; } // start with "original-" ? then we load from api - if (\substr($v, 0, \strlen('original-')) === 'original-') { + if (str_starts_with($v, 'original-')) { $code = \substr($v, \strlen('original-')); $appellation = $this->appellationRepository->findOneByCode($code); } else { @@ -90,17 +87,17 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface $appellation = $this->appellationRepository->find($id); } - if (NULL === $appellation) { + if (null === $appellation) { $def = $this->apiAppellation->getAppellation($code); $metier = $this->em->getRepository(Metier::class) ->findOneByCode($def->metier->code) - ; + ; - if ($metier === NULL) { + if (null === $metier) { $metier = (new Metier()) ->setCode($def->metier->code) ->setLibelle($def->metier->libelle) - ; + ; } $appellation = new Appellation(); @@ -109,16 +106,14 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface ->setCode($def->code) ->setLibelle($def->libelle) ->setMetier($metier) - ; + ; - if ($this->validator->validate($appellation) && $this->validator->validate($metier)) - { + if ($this->validator->validate($appellation) && $this->validator->validate($metier)) { $this->em->persist($appellation); } } - if ($this->em->contains($metier) and $this->em->contains($appellation)) - { + if ($this->em->contains($metier) and $this->em->contains($appellation)) { $choices[] = $appellation; } } @@ -129,7 +124,7 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface public function loadValuesForChoices(array $choices, $value = null) { foreach ($choices as $choice) { - if (NULL === $choice) { + if (null === $choice) { $values[] = null; continue; } diff --git a/src/Bundle/ChillJobBundle/src/Form/FreinType.php b/src/Bundle/ChillJobBundle/src/Form/FreinType.php index 8f9afdbb8..6aa9f71bd 100644 --- a/src/Bundle/ChillJobBundle/src/Form/FreinType.php +++ b/src/Bundle/ChillJobBundle/src/Form/FreinType.php @@ -1,5 +1,14 @@ add('reportDate', ChillDateType::class, [ - 'label' => 'Date du rapport' + 'label' => 'Date du rapport', ]) ->add('freinsPerso', ChoiceType::class, [ 'label' => 'Freins identifiés liés à la situation personnelle', 'choices' => \array_combine(Frein::FREINS_PERSO, Frein::FREINS_PERSO), - 'choice_label' => function($k) { return 'freins_perso.'.$k; }, + 'choice_label' => fn ($k) => 'freins_perso.'.$k, 'required' => false, 'expanded' => true, 'multiple' => true, @@ -32,37 +38,29 @@ class FreinType extends AbstractType ->add('freinsEmploi', ChoiceType::class, [ 'label' => 'Freins identifiés liés à la situation professionnelle', 'choices' => \array_combine(Frein::FREINS_EMPLOI, Frein::FREINS_EMPLOI), - 'choice_label' => function($k) { return 'freins_emploi.'.$k; }, + 'choice_label' => fn ($k) => 'freins_emploi.'.$k, 'required' => false, 'expanded' => true, 'multiple' => true, ]) ->add('notesPerso', TextareaType::class, [ 'label' => 'Notes concernant la situation personnelle', - 'required' => false + 'required' => false, ]) ->add('notesEmploi', TextareaType::class, [ 'label' => 'Notes concernant l\'accès à l\'emploi', - 'required' => false + 'required' => false, ]) - ; - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\Frein' - )); + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => Frein::class]); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_frein'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/ImmersionType.php b/src/Bundle/ChillJobBundle/src/Form/ImmersionType.php index e237ba33c..655b32bb4 100644 --- a/src/Bundle/ChillJobBundle/src/Form/ImmersionType.php +++ b/src/Bundle/ChillJobBundle/src/Form/ImmersionType.php @@ -1,5 +1,14 @@ add('entreprise', PickThirdPartyType::class, [ 'center' => $options['center'], - 'types' => [ 'entreprise' ], + 'types' => ['entreprise'], 'label' => "Identité de l'entreprise", 'required' => true, - 'multiple' => false + 'multiple' => false, ]) ->add('domaineActivite', TextType::class, [ 'label' => "Domaine d'activité", 'required' => true, ]) ->add('tuteurName', TextType::class, [ - 'label' => "Nom du tuteur", - 'required' => true + 'label' => 'Nom du tuteur', + 'required' => true, ]) ->add('tuteurFonction', TextType::class, [ - 'label' => "Fonction du tuteur", - 'required' => true + 'label' => 'Fonction du tuteur', + 'required' => true, ]) ->add('tuteurPhoneNumber', TextType::class, [ - 'label' => "Téléphone du tuteur", - 'required' => true + 'label' => 'Téléphone du tuteur', + 'required' => true, ]) ->add('structureAccName', TextType::class, [ - 'label' => "Nom de la structure", - "required" => false + 'label' => 'Nom de la structure', + 'required' => false, ]) ->add('structureAccPhonenumber', TextType::class, [ - 'label' => "Téléphone de la structure", - 'required' => false + 'label' => 'Téléphone de la structure', + 'required' => false, ]) ->add('structureAccEmail', EmailType::class, [ 'label' => 'Email de la structure', - 'required' => false + 'required' => false, ]) ->add('structureAccAddress', AddressType::class, [ 'label' => 'Addresse de la structure d\'accompagnement', 'required' => false, 'has_valid_from' => false, - 'null_if_empty' => true + 'null_if_empty' => true, ]) ->add('posteTitle', TextType::class, [ 'label' => 'Intitulé du poste', - 'required' => true + 'required' => true, ]) ->add('posteLieu', TextType::class, [ 'label' => "Lieu d'exercice", - 'required' => true + 'required' => true, ]) ->add('debutDate', ChillDateType::class, [ 'label' => "Date de début de l'immersion", - 'required' => true + 'required' => true, ]) ->add('duration', DateIntervalType::class, [ 'unit_choices' => [ - "Weeks" => 'W', - "Months" => 'M', - "Days" => 'D' - ], + 'Weeks' => 'W', + 'Months' => 'M', + 'Days' => 'D', + ], 'label' => "Durée de l'immersion", - 'required' => true + 'required' => true, ]) ->add('horaire', TextareaType::class, [ - 'label' => "Horaire du stagiaire", + 'label' => 'Horaire du stagiaire', 'required' => true, ]) ->add('objectifs', ChoiceType::class, [ - 'label' => "Objectifs", + 'label' => 'Objectifs', 'required' => false, 'multiple' => true, 'expanded' => true, 'choices' => \array_combine(Immersion::OBJECTIFS, Immersion::OBJECTIFS), - 'choice_label' => function($k) { return 'immersion_objectif.'.$k; } + 'choice_label' => fn ($k) => 'immersion_objectif.'.$k, ]) ->add('objectifsAutre', TextareaType::class, [ 'label' => 'Précision sur les objectifs', - 'required' => false + 'required' => false, ]) ->add('noteImmersion', TextareaType::class, [ - 'label' => "Note", - 'required' => false + 'label' => 'Note', + 'required' => false, ]) ; - } elseif ($options['step'] === 'bilan') { + } elseif ('bilan' === $options['step']) { $builder ->add('savoirEtre', ChoiceType::class, [ - 'label' => "Savoir-être du jeune", + 'label' => 'Savoir-être du jeune', 'required' => false, 'multiple' => true, 'expanded' => true, 'choices' => \array_combine(Immersion::SAVOIR_ETRE, Immersion::SAVOIR_ETRE), - 'choice_label' => function($k) { return 'immersion_savoir_etre.'.$k; } + 'choice_label' => fn ($k) => 'immersion_savoir_etre.'.$k, ]) ->add('savoirEtreNote', TextareaType::class, [ - 'label' => "Note", - 'required' => false + 'label' => 'Note', + 'required' => false, ]) ->add('principalesActivites', TextareaType::class, [ - 'label' => "Principales activités", - 'required' => false + 'label' => 'Principales activités', + 'required' => false, ]) ->add('competencesAcquises', TextareaType::class, [ - 'label' => "Compétences acquises", - 'required' => false + 'label' => 'Compétences acquises', + 'required' => false, ]) ->add('competencesADevelopper', TextareaType::class, [ - 'label' => "Compétences à développer", - 'required' => false + 'label' => 'Compétences à développer', + 'required' => false, ]) ->add('noteBilan', TextareaType::class, [ - 'label' => "Notes sur le bilan", - 'required' => false + 'label' => 'Notes sur le bilan', + 'required' => false, ]) - ; + ; foreach ([ - ['ponctualiteSalarie', Immersion::PONCTUALITE_SALARIE, "Ponctualité du salarié"], - ['assiduite', Immersion::ASSIDUITE, "Assiduité"], - ['interetActivite', Immersion::YES_NO_NSP, "La personne s’intéresse à l’ensemble des activités et membres de l’entreprise"], - ['integreRegle', Immersion::INTEGRE_REGLE, "La personne a intégré les règles (les principes) de l’entreprise"], - ['espritInitiative', Immersion::YES_NO_NSP, "La personne fait preuve d’esprit d’initiative"], - ['organisation', Immersion::YES_NO_NSP, "La personne a fait preuve d’organisation"], - ['capaciteTravailEquipe', Immersion::YES_NO_NSP, "Sa capacité à travailler en équipe"], - ['styleVestimentaire', Immersion::YES_NO_NSP, "Style vestimentaire adapté"], - ['langageProf', Immersion::YES_NO_NSP, "Langage professionnel"], - ['appliqueConsigne', Immersion::YES_NO_NSP, "Applique les consignes"], - ['respectHierarchie', Immersion::YES_NO_NSP, "Respecte les niveaux hiérarchiques"], - - ] as list($name, $choices, $label)) { - + ['ponctualiteSalarie', Immersion::PONCTUALITE_SALARIE, 'Ponctualité du salarié'], + ['assiduite', Immersion::ASSIDUITE, 'Assiduité'], + ['interetActivite', Immersion::YES_NO_NSP, 'La personne s’intéresse à l’ensemble des activités et membres de l’entreprise'], + ['integreRegle', Immersion::INTEGRE_REGLE, 'La personne a intégré les règles (les principes) de l’entreprise'], + ['espritInitiative', Immersion::YES_NO_NSP, 'La personne fait preuve d’esprit d’initiative'], + ['organisation', Immersion::YES_NO_NSP, 'La personne a fait preuve d’organisation'], + ['capaciteTravailEquipe', Immersion::YES_NO_NSP, 'Sa capacité à travailler en équipe'], + ['styleVestimentaire', Immersion::YES_NO_NSP, 'Style vestimentaire adapté'], + ['langageProf', Immersion::YES_NO_NSP, 'Langage professionnel'], + ['appliqueConsigne', Immersion::YES_NO_NSP, 'Applique les consignes'], + ['respectHierarchie', Immersion::YES_NO_NSP, 'Respecte les niveaux hiérarchiques'], + ] as [$name, $choices, $label]) { $builder ->add($name, ChoiceType::class, [ 'label' => $label, @@ -163,47 +166,35 @@ class ImmersionType extends AbstractType 'required' => false, 'expanded' => true, 'choices' => $choices, - 'choice_label' => function($el) use ($choices, $name) { - if ($choices === Immersion::YES_NO_NSP) { + 'choice_label' => function ($el) use ($choices, $name) { + if (Immersion::YES_NO_NSP === $choices) { return 'immersion_nsp.'.$el; } return 'immersion_'.$name.'.'.$el; - } + }, ]) ->add($name.'Note', TextareaType::class, [ - 'label' => "Notes", - 'required' => false + 'label' => 'Notes', + 'required' => false, ]); - } } } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\Immersion', - 'step' => 'immersion' - )); + $resolver->setDefaults(['data_class' => Immersion::class, 'step' => 'immersion']); $resolver ->setAllowedValues('step', ['immersion', 'bilan']) ->setRequired('center') ->setAllowedTypes('center', \Chill\MainBundle\Entity\Center::class) - ; + ; } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_immersion'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/ProjetProfessionnelType.php b/src/Bundle/ChillJobBundle/src/Form/ProjetProfessionnelType.php index a03573d7c..76f3e5b32 100644 --- a/src/Bundle/ChillJobBundle/src/Form/ProjetProfessionnelType.php +++ b/src/Bundle/ChillJobBundle/src/Form/ProjetProfessionnelType.php @@ -1,5 +1,14 @@ add('domaineActiviteSouhait', TextareaType::class, [ 'label' => "Domaine d'activité souhaité", - 'required' => false + 'required' => false, ]) ->add('reportDate', ChillDateType::class, [ 'label' => 'Date', - 'required' => true + 'required' => true, ]) ->add('typeContrat', ChoiceType::class, [ 'label' => 'Type de contrat recherché', 'multiple' => true, 'expanded' => true, - 'choices' => \array_combine(ProjetProfessionnel::TYPE_CONTRAT, - ProjetProfessionnel::TYPE_CONTRAT), - 'choice_label' => function($k) { return 'projet_prof.type_contrat.'.$k; } + 'choices' => \array_combine( + ProjetProfessionnel::TYPE_CONTRAT, + ProjetProfessionnel::TYPE_CONTRAT + ), + 'choice_label' => fn ($k) => 'projet_prof.type_contrat.'.$k, ]) ->add('typeContratNotes', TextareaType::class, [ 'label' => 'Notes concernant le contrat recherché', @@ -50,13 +57,15 @@ class ProjetProfessionnelType extends AbstractType 'multiple' => true, 'expanded' => true, 'required' => true, - 'choices' => \array_combine(ProjetProfessionnel::VOLUME_HORAIRES, - ProjetProfessionnel::VOLUME_HORAIRES), - 'choice_label' => function($k) { return 'projet_prof.volume_horaire.'.$k; } + 'choices' => \array_combine( + ProjetProfessionnel::VOLUME_HORAIRES, + ProjetProfessionnel::VOLUME_HORAIRES + ), + 'choice_label' => fn ($k) => 'projet_prof.volume_horaire.'.$k, ]) ->add('volumeHoraireNotes', TextareaType::class, [ 'label' => 'Notes concernant le volume horaire', - 'required' => false + 'required' => false, ]) ->add('idee', TextareaType::class, [ 'label' => 'Idée', @@ -74,7 +83,7 @@ class ProjetProfessionnelType extends AbstractType ]) ->add('domaineActiviteValide', TextareaType::class, [ 'label' => "Domaine d'activité validé", - 'required' => false + 'required' => false, ]) ->add('valideNotes', TextareaType::class, [ 'label' => 'Validé (notes)', @@ -82,28 +91,18 @@ class ProjetProfessionnelType extends AbstractType ]) ->add('projetProfessionnelNote', TextareaType::class, [ 'label' => 'Notes concernant le projet professionnel', - 'required' => false + 'required' => false, ]) - ; - - - }/** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Chill\ChillJobBundle\Entity\ProjetProfessionnel' - )); + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(['data_class' => ProjetProfessionnel::class]); } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'csconnectes_spbundle_projetprofessionnel'; } - - } diff --git a/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php b/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php index a7f761df6..471d5e7ce 100644 --- a/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php +++ b/src/Bundle/ChillJobBundle/src/Form/Type/PickRomeAppellationType.php @@ -1,6 +1,14 @@ addModelTransformer($this->romeAppellationTransformer) - ; + // ->addModelTransformer($this->romeAppellationTransformer) } public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefault('class', Appellation::class) - ->setDefault('choice_label', function(Appellation $a) { - return $a->getLibelle(); - }) - ->setDefault('placeholder', 'Choisir une appellation') - //->setDefault('attr', ['class' => 'select2 ']) - ->setDefault('choice_loader', function(Options $o) { - return new RomeAppellationChoiceLoader( - $this->em, - $this->apiPartenaire, - $this->validator - ); - }) + ->setDefault('choice_label', fn (Appellation $a) => $a->getLibelle()) + ->setDefault('placeholder', 'Choisir une appellation') + // ->setDefault('attr', ['class' => 'select2 ']) + ->setDefault('choice_loader', fn (Options $o) => new RomeAppellationChoiceLoader( + $this->em, + $this->apiPartenaire, + $this->validator + )) ; } @@ -116,7 +107,7 @@ class PickRomeAppellationType extends AbstractType $view->vars['attr']['data-rome-appellation-picker'] = true; $view->vars['attr']['data-select-interactive-loading'] = true; $view->vars['attr']['data-search-url'] = $this->urlGenerator - ->generate('chill_pole_emploi_api_appellation_search', [ '_format' => 'json' ]); + ->generate('chill_pole_emploi_api_appellation_search', ['_format' => 'json']); $view->vars['attr']['data-placeholder'] = 'Choisir une appellation'; $view->vars['attr']['data-no-results-label'] = $this->translator->trans('select2.no_results'); $view->vars['attr']['data-error-load-label'] = $this->translator->trans('select2.error_loading'); diff --git a/src/Bundle/ChillJobBundle/src/Menu/MenuBuilder.php b/src/Bundle/ChillJobBundle/src/Menu/MenuBuilder.php index 3f40d11ba..bd329e440 100644 --- a/src/Bundle/ChillJobBundle/src/Menu/MenuBuilder.php +++ b/src/Bundle/ChillJobBundle/src/Menu/MenuBuilder.php @@ -1,5 +1,14 @@ authorizationChecker->isGranted(CSConnectesVoter::REPORT_NEW, $person)) { - $menu->addChild('Situation personnelle', [ - 'route' => 'chill_crud_csperson_personal_situation_view', - 'routeParameters' => [ - 'id' => $person->getId() - ] - ]) + $menu->addChild('Situation personnelle', [ + 'route' => 'chill_crud_csperson_personal_situation_view', + 'routeParameters' => [ + 'id' => $person->getId(), + ], + ]) ->setExtras([ - 'order'=> 50 + 'order' => 50, ]); - $menu->addChild('Dispositifs', [ - 'route' => 'chill_crud_csperson_dispositifs_view', - 'routeParameters' => [ - 'id' => $person->getId() - ] - ]) + $menu->addChild('Dispositifs', [ + 'route' => 'chill_crud_csperson_dispositifs_view', + 'routeParameters' => [ + 'id' => $person->getId(), + ], + ]) ->setExtras([ - 'order'=> 51 + 'order' => 51, ]); } $menu->addChild('Parcours d\'accompagnement', [ - 'route' => 'chill_csconnectes_csreport_index', - 'routeParameters' => [ - 'person' => $person->getId() - ] - ]) + 'route' => 'chill_csconnectes_csreport_index', + 'routeParameters' => [ + 'person' => $person->getId(), + ], + ]) ->setExtras([ - 'order' => 52 + 'order' => 52, ]); } public static function getMenuIds(): array { - return [ 'person' ]; + return ['person']; } } diff --git a/src/Bundle/ChillJobBundle/src/Repository/CSPersonRepository.php b/src/Bundle/ChillJobBundle/src/Repository/CSPersonRepository.php index 1b7fdee2e..177917364 100644 --- a/src/Bundle/ChillJobBundle/src/Repository/CSPersonRepository.php +++ b/src/Bundle/ChillJobBundle/src/Repository/CSPersonRepository.php @@ -1,13 +1,20 @@ authorizationHelper = $authorizationHelper; } - protected function supports($attribute, $subject) { if (!\in_array($attribute, self::ALL)) { @@ -73,9 +75,8 @@ class CSConnectesVoter extends AbstractChillVoter implements ProvideRoleHierarch $center = $subject->getPerson()->getCenter(); } - switch($attribute) { + switch ($attribute) { case self::REPORT_NEW: - return $this->authorizationHelper->userHasAccess($token->getUser(), $center, $attribute); case self::REPORT_CV: @@ -86,7 +87,6 @@ class CSConnectesVoter extends AbstractChillVoter implements ProvideRoleHierarch return $this->authorizationHelper->userHasAccess($token->getUser(), $center, $attribute); case self::REPORT_DELETE: - if ($subject instanceof Immersion) { $date = \DateTimeImmutable::createFromMutable($subject->getDebutDate())->add($subject->getDuration()); } else { diff --git a/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsVoter.php b/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsVoter.php index 620dcbcf9..0949bcfc9 100644 --- a/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsVoter.php +++ b/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsVoter.php @@ -1,5 +1,14 @@ authorizationHelper->getReachableCenters($user, new Role($attribute)); - if ($subject === null) { + if (null === $subject) { return count($centers) > 0; } @@ -89,11 +91,11 @@ class ExportsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInt */ public function getRolesWithHierarchy() { - return [ 'CSConnectes' => $this->getRoles() ]; + return ['CSConnectes' => $this->getRoles()]; } /** - * return an array of role provided by the object + * return an array of role provided by the object. * * @return string[] array of roles (as string) */ @@ -103,7 +105,7 @@ class ExportsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInt } /** - * return roles which doesn't need + * return roles which doesn't need. * * @return string[] array of roles without scopes */ @@ -115,7 +117,8 @@ class ExportsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInt /** * @return array */ - private function getAttributes() { - return [ self::EXPORT ]; + private function getAttributes() + { + return [self::EXPORT]; } } diff --git a/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php b/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php index e92f9fb0b..4e983c8b9 100644 --- a/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php +++ b/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php @@ -1,9 +1,21 @@ abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SCHEMA chill_csconnectes'); $this->addSql('CREATE TABLE chill_csconnectes.cs_person ( @@ -92,12 +101,11 @@ final class Version20191119172511 extends AbstractMigration $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.typeContrat IS NULL'); $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.ressources IS NULL'); $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.accompagnement IS NULL'); - } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP TABLE chill_csconnectes.cs_person'); $this->addSql('DROP SCHEMA chill_csconnectes CASCADE'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20191129112321.php b/src/Bundle/ChillJobBundle/src/migrations/Version20191129112321.php index 593ae7c5f..361c68207 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20191129112321.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20191129112321.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX chill_csconnectes.IDX_10864f31217bbb47'); $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CERSignataire TEXT DEFAULT NULL'); @@ -28,11 +37,11 @@ final class Version20191129112321 extends AbstractMigration $this->addSql('ALTER TABLE chill_csconnectes.cs_person ALTER person_id DROP NOT NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->throwIrreversibleMigrationException("this migration is not reversible (" - . "actions on primary keys)"); - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->throwIrreversibleMigrationException('this migration is not reversible (' + .'actions on primary keys)'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX UNIQ_10864F31217BBB47'); $this->addSql('DROP INDEX cs_person_pkey'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200113104411.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200113104411.php index e5c859844..57228f5b6 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200113104411.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200113104411.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SEQUENCE chill_csconnectes.immersion_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE TABLE chill_csconnectes.immersion (id INT NOT NULL, person_id INT DEFAULT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSONB DEFAULT NULL, savoirEtre JSONB DEFAULT NULL, noteimmersion TEXT NOT NULL, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, PRIMARY KEY(id))'); @@ -25,9 +34,9 @@ final class Version20200113104411 extends AbstractMigration $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB435E47E35 FOREIGN KEY (referent_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP SEQUENCE chill_csconnectes.immersion_id_seq CASCADE'); $this->addSql('DROP TABLE chill_csconnectes.immersion'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200113142525.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200113142525.php index 92677a8bc..03d4c44e6 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200113142525.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200113142525.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD structureAccEmail TEXT DEFAULT NULL'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD structureAccAddress_id INT DEFAULT NULL'); $this->addSql('CREATE INDEX IDX_FBB3CBB4B5E04267 ON chill_csconnectes.immersion (structureAccAddress_id)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP structureAccEmail'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP structureAccAddress_id'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200114081435.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200114081435.php index 9cbb47b8c..9d4000b44 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200114081435.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200114081435.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD is_bilan_fullfilled BOOLEAN DEFAULT \'false\' NOT NULL'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD savoirEtreNote TEXT DEFAULT NULL'); @@ -23,9 +32,9 @@ final class Version20200114081435 extends AbstractMigration $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB4B5E04267 FOREIGN KEY (structureAccAddress_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP CONSTRAINT FK_FBB3CBB4B5E04267'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP is_bilan_fullfilled'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200124130244.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200124130244.php index 4f3e79c49..1d2e5e4d1 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200124130244.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200124130244.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD datecontratIEJ DATE DEFAULT NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP datecontratIEJ'); - } } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200124132321.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200124132321.php index ebfaaf5ff..cd12ef238 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200124132321.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200124132321.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD typeContratAide TEXT DEFAULT NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP typeContratAide'); } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200127132932.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200127132932.php index fb11969c4..6cf29a7dd 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200127132932.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200127132932.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD objectifsAutre TEXT DEFAULT NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP objectifsAutre'); - } } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200205132532.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200205132532.php index 94fe839f9..495943467 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200205132532.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200205132532.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP SEQUENCE report_id_seq CASCADE'); $this->addSql('CREATE SEQUENCE chill_csconnectes.rome_appellation_id_seq ' - . 'INCREMENT BY 1 MINVALUE 1 START 1'); + .'INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_csconnectes.rome_metier_id_seq ' - . 'INCREMENT BY 1 MINVALUE 1 START 1'); + .'INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_csconnectes.projet_professionnel_id_seq ' - . 'INCREMENT BY 1 MINVALUE 1 START 1'); + .'INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE TABLE chill_csconnectes.rome_appellation (' - . 'id INT NOT NULL, metier_id INT DEFAULT NULL, code VARCHAR(40) NOT NULL, ' - . 'libelle TEXT NOT NULL, PRIMARY KEY(id))'); + .'id INT NOT NULL, metier_id INT DEFAULT NULL, code VARCHAR(40) NOT NULL, ' + .'libelle TEXT NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_D9E9CABCED16FA20 ON chill_csconnectes.rome_appellation (metier_id)'); $this->addSql('CREATE TABLE chill_csconnectes.rome_metier (id INT NOT NULL, ' - . 'libelle TEXT NOT NULL, code VARCHAR(20) NOT NULL, PRIMARY KEY(id))'); + .'libelle TEXT NOT NULL, code VARCHAR(20) NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_csconnectes.projet_professionnel (id INT NOT NULL, ' - . 'person_id INT DEFAULT NULL, reportDate DATE NOT NULL, ' - . 'typeContrat JSONB DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, ' - . 'volumeHoraire JSONB DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, ' - . 'idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, ' - . 'valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, ' - . 'PRIMARY KEY(id))'); + .'person_id INT DEFAULT NULL, reportDate DATE NOT NULL, ' + .'typeContrat JSONB DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, ' + .'volumeHoraire JSONB DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, ' + .'idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, ' + .'valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, ' + .'PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_12E4FFBF217BBB47 ON chill_csconnectes.projet_professionnel (person_id)'); $this->addSql('CREATE TABLE chill_csconnectes.projetprofessionnel_souhait (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); $this->addSql('CREATE INDEX IDX_3280B96DB87BF7B5 ON chill_csconnectes.projetprofessionnel_souhait (projetprofessionnel_id)'); @@ -48,13 +57,11 @@ final class Version20200205132532 extends AbstractMigration $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait ADD CONSTRAINT FK_3280B96D7CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_csconnectes.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE0B87BF7B5 FOREIGN KEY (projetprofessionnel_id) REFERENCES chill_csconnectes.projet_professionnel (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE07CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_csconnectes.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - - } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait DROP CONSTRAINT FK_3280B96D7CDE30DD'); $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide DROP CONSTRAINT FK_E0501BE07CDE30DD'); @@ -70,7 +77,5 @@ final class Version20200205132532 extends AbstractMigration $this->addSql('DROP TABLE chill_csconnectes.projet_professionnel'); $this->addSql('DROP TABLE chill_csconnectes.projetprofessionnel_souhait'); $this->addSql('DROP TABLE chill_csconnectes.projetprofessionnel_valide'); - - } } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200207224152.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200207224152.php index 0eeca852f..9384f5ea5 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200207224152.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200207224152.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE INDEX code_appellation_idx ON chill_csconnectes.rome_appellation (code)'); $this->addSql('CREATE INDEX code_metier_idx ON chill_csconnectes.rome_metier (code)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX code_appellation_idx ON chill_csconnectes.rome_appellation'); $this->addSql('DROP INDEX code_metier_idx ON chill_csconnectes.rome_metier'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200210105342.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200210105342.php index f7001d23d..dc5dc7fab 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200210105342.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200210105342.php @@ -1,4 +1,13 @@ -addSql("CREATE UNIQUE INDEX UNIQ_D9E9CABC77153098 ON chill_csconnectes.rome_appellation (code);"); - $this->addSql("CREATE UNIQUE INDEX UNIQ_3274952577153098 ON chill_csconnectes.rome_metier (code);"); - $this->addSql("DROP INDEX IF EXISTS chill_csconnectes.code_metier_idx "); - $this->addSql("DROP INDEX IF EXISTS chill_csconnectes.code_appellation_idx "); - + $this->addSql('CREATE UNIQUE INDEX UNIQ_D9E9CABC77153098 ON chill_csconnectes.rome_appellation (code);'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_3274952577153098 ON chill_csconnectes.rome_metier (code);'); + $this->addSql('DROP INDEX IF EXISTS chill_csconnectes.code_metier_idx '); + $this->addSql('DROP INDEX IF EXISTS chill_csconnectes.code_appellation_idx '); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->addSql("DROP INDEX chill_csconnectes.UNIQ_D9E9CABC77153098"); - $this->addSql("DROP INDEX chill_csconnectes.UNIQ_3274952577153098"); + $this->addSql('DROP INDEX chill_csconnectes.UNIQ_D9E9CABC77153098'); + $this->addSql('DROP INDEX chill_csconnectes.UNIQ_3274952577153098'); } } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200313124323.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200313124323.php index 93777f2b8..de2dbafab 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200313124323.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200313124323.php @@ -1,4 +1,13 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.cv_formation ALTER diplomaobtained TYPE VARCHAR(255)'); $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD ponctualite_salarie TEXT DEFAULT NULL'); @@ -46,9 +55,9 @@ final class Version20200313124323 extends AbstractMigration $this->addSql('COMMENT ON COLUMN chill_3party.third_party.types IS NULL'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP ponctualite_salarie'); $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP ponctualite_salarie_note'); diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200403114520.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200403114520.php index f7e68f9e0..a1a4e4f5e 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200403114520.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200403114520.php @@ -1,4 +1,13 @@ -addSql("ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteSouhait TEXT DEFAULT NULL;"); - $this->addSql("ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteValide TEXT DEFAULT NULL;"); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteSouhait TEXT DEFAULT NULL;'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteValide TEXT DEFAULT NULL;'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->addSql("ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteSouhait"); - $this->addSql("ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteValide"); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteSouhait'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteValide'); } } diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20200403123148.php b/src/Bundle/ChillJobBundle/src/migrations/Version20200403123148.php index b6c40b5f9..c117ed34b 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20200403123148.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20200403123148.php @@ -1,4 +1,13 @@ -addSql("ALTER TABLE chill_csconnectes.cs_person ADD dateavenantIEJ DATE DEFAULT NULL;"); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD dateavenantIEJ DATE DEFAULT NULL;'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { - $this->addSql("ALTER TABLE chill_csconnectes.cs_person DROP dateavenantIEJ"); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP dateavenantIEJ'); } }