From 264fff5c36e05e3f38cc6480a8ab031e62c4b286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Nov 2023 12:11:29 +0100 Subject: [PATCH 001/132] Implement asynchronous upload feature in Openstack Object Store Those features were previously stored in champs-libres/async-upload-bundle This commit introduces several new classes within the ChillDocStore bundle for handling asynchronous uploads onto an Openstack Object Store. Specifically, the TempUrlOpenstackGenerator, SignedUrl, TempUrlGeneratorInterface, TempUrlGenerateEvent, and TempUrlGeneratorException classes have been created. This implementation will allow for generating "temporary URLs", which assist in securely and temporarily uploading resources to the OpenStack Object Store. This feature enables the handling of file uploads in a more scalable and efficient manner in high-volume environments. Additionally, corresponding unit tests have also been added to ensure the accuracy of this new feature. --- .../TempUrlOpenstackGenerator.php | 192 ++++++++++++++++++ .../Event/TempUrlGenerateEvent.php | 31 +++ .../Exception/TempUrlGeneratorException.php | 14 ++ .../AsyncUpload/SignedUrl.php | 21 ++ .../AsyncUpload/SignedUrlPost.php | 28 +++ .../AsyncUpload/TempUrlGeneratorInterface.php | 23 +++ .../TempUrlOpenstackGeneratorTest.php | 151 ++++++++++++++ 7 files changed, 460 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Event/TempUrlGenerateEvent.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/TempUrlGeneratorException.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/TempUrlGeneratorInterface.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php new file mode 100644 index 000000000..742e4285c --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php @@ -0,0 +1,192 @@ +max_expire_delay; + $submit_delay ??= $this->max_submit_delay; + + if ($delay < 2) { + throw new TempUrlGeneratorException("The delay of {$delay} is too ".'short (<2 sec) to properly use this token'); + } + + if ($delay > $this->max_expire_delay) { + throw new TempUrlGeneratorException('The given delay is greater than the max delay authorized.'); + } + + if ($submit_delay < 15) { + throw new TempUrlGeneratorException("The submit delay of {$delay} is too ".'short (<15 sec) to properly use this token'); + } + + if ($submit_delay > $this->max_submit_delay) { + throw new TempUrlGeneratorException('The given submit delay is greater than the max submit delay authorized.'); + } + + if ($max_file_count > $this->max_file_count) { + throw new TempUrlGeneratorException('The number of files is greater than the authorized number of files'); + } + + $expires = $this->clock->now()->add(new \DateInterval('PT'.(string) $delay.'S')); + + $object_name = $this->generateObjectName(); + + $g = new SignedUrlPost( + $url = $this->generateUrl($object_name), + $expires, + $this->max_post_file_size, + $max_file_count, + $submit_delay, + '', + $object_name, + $this->generateSignaturePost($url, $expires) + ); + + $this->event_dispatcher->dispatch( + new TempUrlGenerateEvent($g), + ); + + $this->logger->info( + 'generate signature for url', + (array) $g + ); + + return $g; + } + + /** + * Generate an absolute public url for a GET request on the object. + */ + public function generate(string $method, string $object_name, int $expire_delay = null): SignedUrl + { + if ($expire_delay > $this->max_expire_delay) { + throw new TempUrlGeneratorException(sprintf('The expire delay (%d) is greater than the max_expire_delay (%d)', $expire_delay, $this->max_expire_delay)); + } + $url = $this->generateUrl($object_name); + + $expires = $this->clock->now() + ->add(new \DateInterval(sprintf('PT%dS', $expire_delay ?? $this->max_expire_delay))); + $args = [ + 'temp_url_sig' => $this->generateSignature($method, $url, $expires), + 'temp_url_expires' => $expires->format('U'), + ]; + $url = $url.'?'.\http_build_query($args); + + $signature = new SignedUrl($method, $url, $expires); + + $this->event_dispatcher->dispatch( + new TempUrlGenerateEvent($signature) + ); + + return $signature; + } + + private function generateUrl($relative_path): string + { + return match (str_ends_with($this->base_url, '/')) { + true => $this->base_url.$relative_path, + false => $this->base_url.'/'.$relative_path + }; + } + + private function generateObjectName() + { + // inspiration from https://stackoverflow.com/a/4356295/1572236 + $charactersLength = strlen(self::CHARACTERS); + $randomString = ''; + for ($i = 0; $i < 21; ++$i) { + $randomString .= self::CHARACTERS[random_int(0, $charactersLength - 1)]; + } + + return $randomString; + } + + private function generateSignaturePost($url, \DateTimeImmutable $expires) + { + $path = \parse_url((string) $url, PHP_URL_PATH); + + $body = sprintf( + "%s\n%s\n%s\n%s\n%s", + $path, + '', // redirect is empty + (string) $this->max_post_file_size, + (string) $this->max_file_count, + $expires->format('U') + ) + ; + + $this->logger->debug( + 'generate signature post', + ['url' => $body, 'method' => 'POST'] + ); + + return \hash_hmac('sha512', $body, $this->key, false); + } + + private function generateSignature($method, $url, \DateTimeImmutable $expires) + { + if ('POST' === $method) { + return $this->generateSignaturePost($url, $expires); + } + + $path = \parse_url((string) $url, PHP_URL_PATH); + + $body = sprintf( + "%s\n%s\n%s", + $method, + $expires->format('U'), + $path + ) + ; + + $this->logger->debug( + 'generate signature GET', + ['url' => $body, 'method' => 'GET'] + ); + + return \hash_hmac('sha512', $body, $this->key, false); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Event/TempUrlGenerateEvent.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Event/TempUrlGenerateEvent.php new file mode 100644 index 000000000..619dba4e0 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Event/TempUrlGenerateEvent.php @@ -0,0 +1,31 @@ +data->method; + } + + public function getData(): SignedUrl + { + return $this->data; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/TempUrlGeneratorException.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/TempUrlGeneratorException.php new file mode 100644 index 000000000..29c7e78ed --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/TempUrlGeneratorException.php @@ -0,0 +1,14 @@ +generate($method, $objectName, $expireDelay); + + self::assertEquals($expected, $signedUrl); + } + + /** + * @dataProvider dataProviderGeneratePost + */ + public function testGeneratePost(string $baseUrl, \DateTimeImmutable $now, string $key, string $method, string $objectName, int $expireDelay, SignedUrl $expected): void + { + $logger = new NullLogger(); + $eventDispatcher = new EventDispatcher(); + $clock = new MockClock($now); + + $generator = new TempUrlOpenstackGenerator( + $logger, + $eventDispatcher, + $clock, + $baseUrl, + $key, + 1800, + 1800, + 150 + ); + + $signedUrl = $generator->generatePost(); + + self::assertEquals('POST', $signedUrl->method); + self::assertEquals((int) $clock->now()->format('U') + 1800, $signedUrl->expires->getTimestamp()); + self::assertEquals(150, $signedUrl->max_file_size); + self::assertEquals(1, $signedUrl->max_file_count); + self::assertEquals(1800, $signedUrl->submit_delay); + self::assertEquals('', $signedUrl->redirect); + self::assertGreaterThanOrEqual(20, strlen($signedUrl->prefix)); + } + + public function dataProviderGenerate(): iterable + { + $now = \DateTimeImmutable::createFromFormat('U', '1702041743'); + $expireDelay = 1800; + $baseUrls = [ + 'https://objectstore.example/v1/my_account/container/', + 'https://objectstore.example/v1/my_account/container', + ]; + $objectName = 'object'; + $method = 'GET'; + $key = 'MYKEY'; + + $signedUrl = new SignedUrl( + 'GET', + 'https://objectstore.example/v1/my_account/container/object?temp_url_sig=0aeef353a5f6e22d125c76c6ad8c644a59b222ba1b13eaeb56bf3d04e28b081d11dfcb36601ab3aa7b623d79e1ef03017071bbc842fb7b34afec2baff895bf80&temp_url_expires=1702043543', + \DateTimeImmutable::createFromFormat('U', '1702043543') + ); + + foreach ($baseUrls as $baseUrl) { + yield [ + $baseUrl, + $now, + $key, + $method, + $objectName, + $expireDelay, + $signedUrl, + ]; + } + } + + public function dataProviderGeneratePost(): iterable + { + $now = \DateTimeImmutable::createFromFormat('U', '1702041743'); + $expireDelay = 1800; + $baseUrls = [ + 'https://objectstore.example/v1/my_account/container/', + 'https://objectstore.example/v1/my_account/container', + ]; + $objectName = 'object'; + $method = 'GET'; + $key = 'MYKEY'; + + $signedUrl = new SignedUrlPost( + 'https://objectstore.example/v1/my_account/container/object?temp_url_sig=0aeef353a5f6e22d125c76c6ad8c644a59b222ba1b13eaeb56bf3d04e28b081d11dfcb36601ab3aa7b623d79e1ef03017071bbc842fb7b34afec2baff895bf80&temp_url_expires=1702043543', + \DateTimeImmutable::createFromFormat('U', '1702043543'), + 150, + 1, + 1800, + '', + 'abc', + 'abc' + ); + + foreach ($baseUrls as $baseUrl) { + yield [ + $baseUrl, + $now, + $key, + $method, + $objectName, + $expireDelay, + $signedUrl, + ]; + } + } +} From d68802282552ad02a6ba8ce48d9bfd595f0fbb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 13:45:27 +0100 Subject: [PATCH 002/132] Add Controller to get asyncUpload signatures Added new files for handling asynchronous file uploads in ChillDocStoreBundle. The new files include a controller for generating temporary URLs (AsyncUploadController.php), a security authorization file (AsyncUploadVoter.php), and a corresponding test file (AsyncUploadControllerTest.php). These implementations permit asynchronous uploads via POST, GET, and HEAD methods while maintaining security protocols. --- .../Controller/AsyncUploadController.php | 100 ++++++++++++++++ .../Authorization/AsyncUploadVoter.php | 41 +++++++ .../Controller/AsyncUploadControllerTest.php | 110 ++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php create mode 100644 src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/Controller/AsyncUploadControllerTest.php diff --git a/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php b/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php new file mode 100644 index 000000000..decfde596 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php @@ -0,0 +1,100 @@ +tempUrlGenerator + ->generatePost( + $request->query->has('expires_delay') ? $request->query->getInt('expires_delay') : null, + $request->query->has('submit_delay') ? $request->query->getInt('submit_delay') : null + ) + ; + break; + case 'get': + case 'head': + $object_name = $request->query->get('object_name', null); + + if (null === $object_name) { + return (new JsonResponse((object) [ + 'message' => 'the object_name is null', + ])) + ->setStatusCode(JsonResponse::HTTP_BAD_REQUEST); + } + $p = $this->tempUrlGenerator->generate( + $method, + $object_name, + $request->query->has('expires_delay') ? $request->query->getInt('expires_delay') : null + ); + break; + default: + return (new JsonResponse((object) ['message' => 'the method ' + ."{$method} is not valid"])) + ->setStatusCode(JsonResponse::HTTP_BAD_REQUEST); + } + } catch (TempUrlGeneratorException $e) { + $this->logger->warning('The client requested a temp url' + .' which sparkle an error.', [ + 'message' => $e->getMessage(), + 'expire_delay' => $request->query->getInt('expire_delay', 0), + 'file_count' => $request->query->getInt('file_count', 1), + 'method' => $method, + ]); + + $p = new \stdClass(); + $p->message = $e->getMessage(); + $p->status = JsonResponse::HTTP_BAD_REQUEST; + + return new JsonResponse($p, JsonResponse::HTTP_BAD_REQUEST); + } + + if (!$this->security->isGranted(AsyncUploadVoter::GENERATE_SIGNATURE, $p)) { + throw new AccessDeniedHttpException('not allowed to generate this signature'); + } + + return new JsonResponse( + $this->serializer->serialize($p, 'json', [AbstractNormalizer::GROUPS => ['read']]), + Response::HTTP_OK, + [], + true + ); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php new file mode 100644 index 000000000..1d7ad759a --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AsyncUploadVoter.php @@ -0,0 +1,41 @@ +method, ['POST', 'GET', 'HEAD'], true)) { + return false; + } + + return $this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN'); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Controller/AsyncUploadControllerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Controller/AsyncUploadControllerTest.php new file mode 100644 index 000000000..02150e3be --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/Controller/AsyncUploadControllerTest.php @@ -0,0 +1,110 @@ +expectException(AccessDeniedHttpException::class); + $controller = $this->buildAsyncUploadController(false); + + $controller->getSignedUrl('POST', new Request()); + } + + public function testGeneratePost(): void + { + $controller = $this->buildAsyncUploadController(true); + + $actual = $controller->getSignedUrl('POST', new Request()); + $decodedActual = json_decode($actual->getContent(), true, JSON_THROW_ON_ERROR, JSON_THROW_ON_ERROR); + + self::assertArrayHasKey('method', $decodedActual); + self::assertEquals('POST', $decodedActual['method']); + } + + public function testGenerateGet(): void + { + $controller = $this->buildAsyncUploadController(true); + + $actual = $controller->getSignedUrl('GET', new Request(['object_name' => 'abc'])); + $decodedActual = json_decode($actual->getContent(), true, JSON_THROW_ON_ERROR, JSON_THROW_ON_ERROR); + + self::assertArrayHasKey('method', $decodedActual); + self::assertEquals('GET', $decodedActual['method']); + } + + private function buildAsyncUploadController( + bool $isGranted, + ): AsyncUploadController { + $tempUrlGenerator = new class () implements TempUrlGeneratorInterface { + public function generatePost(int $expire_delay = null, int $submit_delay = null, int $max_file_count = 1): SignedUrlPost + { + return new SignedUrlPost( + 'https://object.store.example', + new \DateTimeImmutable('1 hour'), + 150, + 1, + 1800, + '', + 'abc', + 'abc' + ); + } + + public function generate(string $method, string $object_name, int $expire_delay = null): SignedUrl + { + return new SignedUrl( + $method, + 'https://object.store.example', + new \DateTimeImmutable('1 hour') + ); + } + }; + + $serializer = $this->prophesize(SerializerInterface::class); + $serializer->serialize(Argument::type(SignedUrl::class), 'json', Argument::type('array')) + ->will(fn (array $args): string => json_encode(['method' => $args[0]->method], JSON_THROW_ON_ERROR, 3)); + + $security = $this->prophesize(Security::class); + $security->isGranted(AsyncUploadVoter::GENERATE_SIGNATURE, Argument::type(SignedUrl::class)) + ->willReturn($isGranted); + + return new AsyncUploadController( + $tempUrlGenerator, + $serializer->reveal(), + $security->reveal(), + new NullLogger() + ); + } +} From a70572266f9dea4d715704af9c5ad1c3bed5db87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 16:08:29 +0100 Subject: [PATCH 003/132] Refactor TempUrlOpenstackGenerator to use parameter bag and Bundle configuration The TempUrlOpenstackGenerator now uses a ParameterBag for configuration instead of individual parameters. This simplifies the handling of configuration values and makes the code more maintainable. The parameter configuration has also been included in the chill_doc_store configuration array for a unified approach. --- .../TempUrlOpenstackGenerator.php | 28 +++++--- .../ChillDocStoreExtension.php | 3 +- .../DependencyInjection/Configuration.php | 64 ++++++++++++++++++- .../TempUrlOpenstackGeneratorTest.php | 45 ++++++++++--- 4 files changed, 118 insertions(+), 22 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php index 742e4285c..9d79d3603 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGenerator.php @@ -18,6 +18,7 @@ use Chill\DocStoreBundle\AsyncUpload\SignedUrlPost; use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Clock\ClockInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -27,17 +28,28 @@ final readonly class TempUrlOpenstackGenerator implements TempUrlGeneratorInterf { private const CHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + private string $base_url; + private string $key; + private int $max_expire_delay; + private int $max_submit_delay; + private int $max_post_file_size; + private int $max_file_count; + public function __construct( private LoggerInterface $logger, private EventDispatcherInterface $event_dispatcher, private ClockInterface $clock, - private string $base_url, - private string $key, - private int $max_expire_delay, - private int $max_submit_delay, - private int $max_post_file_size, - private int $max_file_count = 1 - ) {} + ParameterBagInterface $parameterBag, + ) { + $config = $parameterBag->get('chill_doc_store')['openstack']['temp_url']; + + $this->key = $config['temp_url_key']; + $this->base_url = $config['temp_url_base_path']; + $this->max_expire_delay = $config['max_expires_delay']; + $this->max_submit_delay = $config['max_submit_delay']; + $this->max_post_file_size = $config['max_post_file_size']; + $this->max_file_count = $config['max_post_file_count']; + } /** * @throws TempUrlGeneratorException @@ -115,7 +127,7 @@ final readonly class TempUrlOpenstackGenerator implements TempUrlGeneratorInterf ]; $url = $url.'?'.\http_build_query($args); - $signature = new SignedUrl($method, $url, $expires); + $signature = new SignedUrl(strtoupper($method), $url, $expires); $this->event_dispatcher->dispatch( new TempUrlGenerateEvent($signature) diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php index f57e675dd..70c479456 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php @@ -32,6 +32,8 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); + $container->setParameter('chill_doc_store', $config); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); $loader->load('services/media.yaml'); @@ -94,7 +96,6 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf 'routing' => [ 'resources' => [ '@ChillDocStoreBundle/config/routes.yaml', - '@ChampsLibresAsyncUploaderBundle/config/routes.yaml', ], ], ]); diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php index 466158783..7c6a08f80 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\DependencyInjection; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -24,11 +25,68 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_doc_store'); + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); - // Here you should define the parameters that are allowed to - // configure your bundle. See the documentation linked above for - // more information on that topic. + /* @phpstan-ignore-next-line As there are inconsistencies in return types, but the code works... */ + $rootNode->children() + // openstack node + ->arrayNode('openstack') + ->info('parameters to authenticate and generate temp url against the openstack object storage service') + ->addDefaultsIfNotSet() + ->children() + // openstack.temp_url + ->arrayNode('temp_url') + ->addDefaultsIfNotSet() + ->children() + // openstack.temp_url.temp_url_key + ->scalarNode('temp_url_key') + ->isRequired()->cannotBeEmpty() + ->info('the temp url key') + ->end() + + ->scalarNode('temp_url_base_path') + ->isRequired()->cannotBeEmpty() + ->info('the base path to add **before** the path to media. Must contains the container') + ->end() + + ->scalarNode('container') + ->info('the container name') + ->isRequired()->cannotBeEmpty() + ->end() + + ->integerNode('max_post_file_size') + ->defaultValue(15_000_000) + ->info('Maximum size of the posted file, in bytes') + ->end() + + ->integerNode('max_post_file_count') + ->defaultValue(1) + ->info('Maximum number of files which may be posted at once using a POST operation using async upload') + ->end() + + ->integerNode('max_expires_delay') + ->defaultValue(180) + ->info('the maximum of seconds a cryptographic signature ' + .'will be valid for submitting a file. This should be ' + .'short, to avoid uploading multiple files') + ->end() + + ->integerNode('max_submit_delay') + ->defaultValue(3600) + ->info('the maximum of seconds between the upload of a file and ' + .'a the submission of the form. This delay will also prevent ' + .'the check of persistence of uploaded file. Should be long ' + .'enough for keeping user-friendly forms') + ->end() + + ->end() // end of children 's temp_url + ->end() // end array temp_url + + ->end() // end of children's openstack + ->end() // end of openstack + ->end() // end of root's children + ->end(); return $treeBuilder; } diff --git a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php index 25c5a1ebc..77d2f8252 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php @@ -17,6 +17,7 @@ use Chill\DocStoreBundle\AsyncUpload\SignedUrlPost; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Symfony\Component\Clock\MockClock; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\EventDispatcher\EventDispatcher; /** @@ -34,16 +35,28 @@ class TempUrlOpenstackGeneratorTest extends TestCase $logger = new NullLogger(); $eventDispatcher = new EventDispatcher(); $clock = new MockClock($now); + $parameters = new ParameterBag( + [ + 'chill_doc_store' => [ + 'openstack' => [ + 'temp_url' => [ + 'temp_url_key' => $key, + 'temp_url_base_path' => $baseUrl, + 'max_post_file_size' => 150, + 'max_post_file_count' => 1, + 'max_expires_delay' => 1800, + 'max_submit_delay' => 1800, + ], + ], + ], + ] + ); $generator = new TempUrlOpenstackGenerator( $logger, $eventDispatcher, $clock, - $baseUrl, - $key, - 1800, - 1800, - 150 + $parameters, ); $signedUrl = $generator->generate($method, $objectName, $expireDelay); @@ -59,16 +72,28 @@ class TempUrlOpenstackGeneratorTest extends TestCase $logger = new NullLogger(); $eventDispatcher = new EventDispatcher(); $clock = new MockClock($now); + $parameters = new ParameterBag( + [ + 'chill_doc_store' => [ + 'openstack' => [ + 'temp_url' => [ + 'temp_url_key' => $key, + 'temp_url_base_path' => $baseUrl, + 'max_post_file_size' => 150, + 'max_post_file_count' => 1, + 'max_expires_delay' => 1800, + 'max_submit_delay' => 1800, + ], + ], + ], + ] + ); $generator = new TempUrlOpenstackGenerator( $logger, $eventDispatcher, $clock, - $baseUrl, - $key, - 1800, - 1800, - 150 + $parameters, ); $signedUrl = $generator->generatePost(); From 450e7c348bf01f6a3b6595827682c48e3641c16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 16:09:06 +0100 Subject: [PATCH 004/132] Fix and clean DI configuration for chill_doc_store for usage with AsyncUpload --- .../Service/StoredObjectManager.php | 7 +++- .../ChillDocStoreBundle/config/services.yaml | 38 +++++++------------ .../src/Resources/config/services.php | 5 --- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php index 34df98fa2..e5f7c4ee4 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php +++ b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Service; use Base64Url\Base64Url; -use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; +use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Exception\StoredObjectManagerException; use Symfony\Component\HttpFoundation\Request; @@ -27,7 +27,10 @@ final class StoredObjectManager implements StoredObjectManagerInterface private array $inMemory = []; - public function __construct(private readonly HttpClientInterface $client, private readonly TempUrlGeneratorInterface $tempUrlGenerator) {} + public function __construct( + private readonly HttpClientInterface $client, + private readonly TempUrlGeneratorInterface $tempUrlGenerator + ) {} public function getLastModified(StoredObject $document): \DateTimeInterface { diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 04fc3ace3..061b0f9c8 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -1,11 +1,12 @@ -parameters: -# cl_chill_person.example.class: Chill\PersonBundle\Example - services: - Chill\DocStoreBundle\Repository\: + _defaults: autowire: true autoconfigure: true + + Chill\DocStoreBundle\Repository\: resource: "../Repository/" + tags: + - { name: doctrine.repository_service } Chill\DocStoreBundle\Form\DocumentCategoryType: class: Chill\DocStoreBundle\Form\DocumentCategoryType @@ -15,8 +16,6 @@ services: Chill\DocStoreBundle\Form\PersonDocumentType: class: Chill\DocStoreBundle\Form\PersonDocumentType - autowire: true - autoconfigure: true # arguments: # - "@chill.main.helper.translatable_string" tags: @@ -24,50 +23,41 @@ services: Chill\DocStoreBundle\Security\Authorization\: resource: "./../Security/Authorization" - autowire: true - autoconfigure: true tags: - { name: chill.role } Chill\DocStoreBundle\Workflow\: resource: './../Workflow/' - autoconfigure: true - autowire: true Chill\DocStoreBundle\Serializer\Normalizer\: - autowire: true resource: '../Serializer/Normalizer/' tags: - - { name: 'serializer.normalizer', priority: 16 } + - { name: serializer.normalizer, priority: 16 } Chill\DocStoreBundle\Service\: - autowire: true - autoconfigure: true resource: '../Service/' Chill\DocStoreBundle\GenericDoc\Manager: - autowire: true - autoconfigure: true arguments: $providersForAccompanyingPeriod: !tagged_iterator chill_doc_store.generic_doc_accompanying_period_provider $providersForPerson: !tagged_iterator chill_doc_store.generic_doc_person_provider - Chill\DocStoreBundle\GenericDoc\Twig\GenericDocExtension: - autoconfigure: true - autowire: true + Chill\DocStoreBundle\GenericDoc\Twig\GenericDocExtension: ~ Chill\DocStoreBundle\GenericDoc\Twig\GenericDocExtensionRuntime: - autoconfigure: true - autowire: true arguments: $renderers: !tagged_iterator chill_doc_store.generic_doc_renderer Chill\DocStoreBundle\GenericDoc\Providers\: - autowire: true - autoconfigure: true resource: '../GenericDoc/Providers/' Chill\DocStoreBundle\GenericDoc\Renderer\: + resource: '../GenericDoc/Renderer/' + + Chill\DocStoreBundle\AsyncUpload\Driver\: autowire: true autoconfigure: true - resource: '../GenericDoc/Renderer/' + resource: '../AsyncUpload/Driver/' + + Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface: + alias: Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\TempUrlOpenstackGenerator diff --git a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php index a962c9e67..005994bb6 100644 --- a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php +++ b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; use ChampsLibres\WopiBundle\Contracts\AuthorizationManagerInterface; use ChampsLibres\WopiBundle\Contracts\UserManagerInterface; use ChampsLibres\WopiBundle\Service\Wopi as CLWopi; @@ -60,8 +59,4 @@ return static function (ContainerConfigurator $container) { ->set(UserManager::class); $services->alias(UserManagerInterface::class, UserManager::class); - - // TODO: Move this into the async bundle (low priority) - $services - ->alias(TempUrlGeneratorInterface::class, 'async_uploader.temp_url_generator'); }; From 4fd5a37df382df3017de292372989855dbe839d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 16:09:26 +0100 Subject: [PATCH 005/132] Add serializer groups to SignedUrl and SignedUrlPost classes, include tests Serializer groups have been added to the SignedUrl and SignedUrlPost classes to ensure correct serialization. Two new test files were also included: SignedUrlNormalizerTest and SignedUrlPostNormalizerTest which test the normalization of instances of the classes. --- .../AsyncUpload/SignedUrl.php | 17 +++++ .../AsyncUpload/SignedUrlPost.php | 26 ++++++++ .../Normalizer/SignedUrlNormalizerTest.php | 55 ++++++++++++++++ .../SignedUrlPostNormalizerTest.php | 66 +++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlNormalizerTest.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlPostNormalizerTest.php diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php index 583325a26..9003a69ea 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php @@ -11,11 +11,28 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\AsyncUpload; +use Symfony\Component\Serializer\Annotation as Serializer; + readonly class SignedUrl { public function __construct( + /** + * @Serializer\Groups({"read"}) + */ public string $method, + + /** + * @Serializer\Groups({"read"}) + */ public string $url, public \DateTimeImmutable $expires, ) {} + + /** + * @Serializer\Groups({"read"}) + */ + public function getExpires(): int + { + return $this->expires->getTimestamp(); + } } diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php index 98e273635..4a5b4e0fb 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php @@ -11,16 +11,42 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\AsyncUpload; +use Symfony\Component\Serializer\Annotation as Serializer; + readonly class SignedUrlPost extends SignedUrl { public function __construct( string $url, \DateTimeImmutable $expires, + + /** + * @Serializer\Groups({"read"}) + */ public int $max_file_size, + + /** + * @Serializer\Groups({"read"}) + */ public int $max_file_count, + + /** + * @Serializer\Groups({"read"}) + */ public int $submit_delay, + + /** + * @Serializer\Groups({"read"}) + */ public string $redirect, + + /** + * @Serializer\Groups({"read"}) + */ public string $prefix, + + /** + * @Serializer\Groups({"read"}) + */ public string $signature, ) { parent::__construct('POST', $url, $expires); diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlNormalizerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlNormalizerTest.php new file mode 100644 index 000000000..8cf9c5a6d --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlNormalizerTest.php @@ -0,0 +1,55 @@ +get(NormalizerInterface::class); + } + + public function testNormalizerSignedUrl(): void + { + $signedUrl = new SignedUrl( + 'GET', + 'https://object.store.example/container/object', + \DateTimeImmutable::createFromFormat('U', '1700000') + ); + + $actual = self::$normalizer->normalize($signedUrl, 'json', [AbstractNormalizer::GROUPS => ['read']]); + + self::assertEqualsCanonicalizing( + [ + 'method' => 'GET', + 'expires' => 1_700_000, + 'url' => 'https://object.store.example/container/object', + ], + $actual + ); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlPostNormalizerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlPostNormalizerTest.php new file mode 100644 index 000000000..3d510d22b --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/Serializer/Normalizer/SignedUrlPostNormalizerTest.php @@ -0,0 +1,66 @@ +get(NormalizerInterface::class); + } + + public function testNormalizerSignedUrl(): void + { + $signedUrl = new SignedUrlPost( + 'https://object.store.example/container/object', + \DateTimeImmutable::createFromFormat('U', '1700000'), + 15000, + 1, + 180, + '', + 'abc', + 'SiGnaTure' + ); + + $actual = self::$normalizer->normalize($signedUrl, 'json', [AbstractNormalizer::GROUPS => ['read']]); + + self::assertEqualsCanonicalizing( + [ + 'max_file_size' => 15000, + 'max_file_count' => 1, + 'submit_delay' => 180, + 'redirect' => '', + 'prefix' => 'abc', + 'signature' => 'SiGnaTure', + 'method' => 'POST', + 'expires' => 1_700_000, + 'url' => 'https://object.store.example/container/object', + ], + $actual + ); + } +} From 1195767eb3f6641802ea63810a7600f2193b8156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 16:53:38 +0100 Subject: [PATCH 006/132] Add Twig AsyncUploadExtension and its associated test Created AsyncUploadExtension under Chill\DocStoreBundle\AsyncUpload\Templating to provide Twig filter functions for generating URLs for asynchronous file uploads. To ensure correctness, AsyncUploadExtensionTest was implemented in Bundle\ChillDocStoreBundle\Tests\AsyncUpload\Templating. Service definitions were also updated in services.yaml. --- .../Templating/AsyncUploadExtension.php | 69 +++++++++++++++++ .../Templating/AsyncUploadExtensionTest.php | 77 +++++++++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 5 +- 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php new file mode 100644 index 000000000..0464b37b9 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Templating/AsyncUploadExtension.php @@ -0,0 +1,69 @@ +computeSignedUrl(...)), + new TwigFilter('generate_url', $this->computeGenerateUrl(...)), + ]; + } + + public function computeSignedUrl(StoredObject|string $file, string $method = 'GET', int $expiresDelay = null): string + { + if ($file instanceof StoredObject) { + $object_name = $file->getFilename(); + } else { + $object_name = $file; + } + + return $this->tempUrlGenerator->generate($method, $object_name, $expiresDelay)->url; + } + + public function computeGenerateUrl(StoredObject|string $file, string $method = 'GET', int $expiresDelay = null): string + { + if ($file instanceof StoredObject) { + $object_name = $file->getFilename(); + } else { + $object_name = $file; + } + + $args = [ + 'method' => $method, + 'object_name' => $object_name, + ]; + + if (null !== $expiresDelay) { + $args['expires_delay'] = $expiresDelay; + } + + return $this->routingUrlGenerator->generate('async_upload.generate_url', $args); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php new file mode 100644 index 000000000..78ed1a1d9 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php @@ -0,0 +1,77 @@ +prophesize(TempUrlGeneratorInterface::class); + $generator->generate(Argument::in(['GET', 'POST']), Argument::type('string'), Argument::any()) + ->will(fn (array $args): SignedUrl => new SignedUrl($args[0], 'https://object.store.example/container/'.$args[1], new \DateTimeImmutable('1 hours'))); + + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate('async_upload.generate_url', Argument::type('array')) + ->willReturn('url'); + + $this->asyncUploadExtension = new AsyncUploadExtension( + $generator->reveal(), + $urlGenerator->reveal() + ); + } + + /** + * @dataProvider dataProviderStoredObject + */ + public function testComputeSignedUrl(StoredObject|string $storedObject): void + { + $actual = $this->asyncUploadExtension->computeSignedUrl($storedObject); + + self::assertStringContainsString('https://object.store.example/container', $actual); + self::assertStringContainsString(is_string($storedObject) ? $storedObject : $storedObject->getFilename(), $actual); + } + + /** + * @dataProvider dataProviderStoredObject + */ + public function testComputeGenerateUrl(StoredObject|string $storedObject): void + { + $actual = $this->asyncUploadExtension->computeGenerateUrl($storedObject); + + self::assertEquals('url', $actual); + } + + public function dataProviderStoredObject(): iterable + { + yield [(new StoredObject())->setFilename('blabla')]; + + yield ['blabla']; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 061b0f9c8..c510064f1 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -55,9 +55,10 @@ services: resource: '../GenericDoc/Renderer/' Chill\DocStoreBundle\AsyncUpload\Driver\: - autowire: true - autoconfigure: true resource: '../AsyncUpload/Driver/' + Chill\DocStoreBundle\AsyncUpload\Templating\: + resource: '../AsyncUpload/Templating/' + Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface: alias: Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\TempUrlOpenstackGenerator From 28d09a820677f59b6533df510d4d621bf1158898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 18:37:58 +0100 Subject: [PATCH 007/132] Add form and types to handle async files --- .../Entity/StoredObject.php | 2 +- .../Form/AccompanyingCourseDocumentType.php | 33 +------- .../Form/DocumentCategoryType.php | 20 ++--- .../Form/StoredObjectType.php | 12 +-- .../Form/Type/AsyncUploaderType.php | 77 +++++++++++++++++++ .../AsyncFileExistsValidatorTest.php | 67 ++++++++++++++++ .../Validator/Constraints/AsyncFileExists.php | 32 ++++++++ .../Constraints/AsyncFileExistsValidator.php | 67 ++++++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 15 +--- .../config/services/form.yaml | 24 +++--- 10 files changed, 271 insertions(+), 78 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Form/Type/AsyncUploaderType.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/Validator/Constraints/AsyncFileExistsValidatorTest.php create mode 100644 src/Bundle/ChillDocStoreBundle/Validator/Constraints/AsyncFileExists.php create mode 100644 src/Bundle/ChillDocStoreBundle/Validator/Constraints/AsyncFileExistsValidator.php diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 2ee60d80a..abccdccc7 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Entity; use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface; -use ChampsLibres\AsyncUploaderBundle\Validator\Constraints\AsyncFileExists; +use Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists; use ChampsLibres\WopiLib\Contract\Entity\Document; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index 0fced39d3..7ae41f96e 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -14,13 +14,10 @@ namespace Chill\DocStoreBundle\Form; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Entity\Document; use Chill\DocStoreBundle\Entity\DocumentCategory; -use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -29,33 +26,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class AccompanyingCourseDocumentType extends AbstractType { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var ObjectManager - */ - protected $om; - - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; - - /** - * the user running this form. - * - * @var User - */ - protected $user; - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; - } + private readonly TranslatableStringHelperInterface $translatableStringHelper + ) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index f3506d631..6396314e2 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -20,23 +20,15 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class DocumentCategoryType extends AbstractType { - private $chillBundlesFlipped; - - public function __construct($kernelBundles) - { - // TODO faire un service dans CHillMain - foreach ($kernelBundles as $key => $value) { - if (str_starts_with((string) $key, 'Chill')) { - $this->chillBundlesFlipped[$value] = $key; - } - } - } - public function buildForm(FormBuilderInterface $builder, array $options) { + $bundles = [ + 'chill-doc-store' => 'chill-doc-store', + ]; + $builder ->add('bundleId', ChoiceType::class, [ - 'choices' => $this->chillBundlesFlipped, + 'choices' => $bundles, 'disabled' => false, ]) ->add('idInsideBundle', null, [ @@ -44,7 +36,7 @@ class DocumentCategoryType extends AbstractType ]) ->add('documentClass', null, [ 'disabled' => false, - ]) // cahcerh par default PersonDocument + ]) ->add('name', TranslatableStringFormType::class); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 77484208f..414d94f20 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Form; -use ChampsLibres\AsyncUploaderBundle\Form\Type\AsyncUploaderType; +use Chill\DocStoreBundle\Form\Type\AsyncUploaderType; use Chill\DocStoreBundle\Entity\StoredObject; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\AbstractType; @@ -26,15 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class StoredObjectType extends AbstractType { - /** - * @var EntityManagerInterface - */ - protected $em; - - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; - } + public function __construct(private readonly EntityManagerInterface $em) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillDocStoreBundle/Form/Type/AsyncUploaderType.php b/src/Bundle/ChillDocStoreBundle/Form/Type/AsyncUploaderType.php new file mode 100644 index 000000000..58d4eebb1 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Form/Type/AsyncUploaderType.php @@ -0,0 +1,77 @@ +get('chill_doc_store')['openstack']['temp_url']; + + $this->expires_delay = $config['max_expires_delay']; + $this->max_submit_delay = $config['max_submit_delay']; + $this->max_post_file_size = $config['max_post_file_size']; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'expires_delay' => $this->expires_delay, + 'max_post_size' => $this->max_post_file_size, + 'submit_delay' => $this->max_submit_delay, + 'max_files' => 1, + 'error_bubbling' => false, + ]); + + $resolver->setAllowedTypes('expires_delay', ['int']); + $resolver->setAllowedTypes('max_post_size', ['int']); + $resolver->setAllowedTypes('max_files', ['int']); + $resolver->setAllowedTypes('submit_delay', ['int']); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options + ) { + $view->vars['attr']['data-async-file-upload'] = true; + $view->vars['attr']['data-generate-temp-url-post'] = $this + ->url_generator->generate('async_upload.generate_url', [ + 'expires_delay' => $options['expires_delay'], + 'method' => 'post', + 'submit_delay' => $options['submit_delay'], + ]); + $view->vars['attr']['data-temp-url-get'] = $this->url_generator + ->generate('async_upload.generate_url', ['method' => 'GET']); + $view->vars['attr']['data-max-files'] = $options['max_files']; + $view->vars['attr']['data-max-post-size'] = $options['max_post_size']; + } + + public function getParent() + { + return HiddenType::class; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Validator/Constraints/AsyncFileExistsValidatorTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Validator/Constraints/AsyncFileExistsValidatorTest.php new file mode 100644 index 000000000..6e46ee370 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/Validator/Constraints/AsyncFileExistsValidatorTest.php @@ -0,0 +1,67 @@ + 404]); + } + + return new MockResponse('', ['http_code' => 200]); + }); + + $generator = $this->prophesize(TempUrlGeneratorInterface::class); + $generator->generate(Argument::in(['GET', 'HEAD']), Argument::type('string'), Argument::any()) + ->will(fn (array $args): SignedUrl => new SignedUrl($args[0], 'https://object.store.example/container/'.$args[1], new \DateTimeImmutable('1 hours'))); + + return new AsyncFileExistsValidator($generator->reveal(), $client); + } + + public function testWhenFileExistsIsValid(): void + { + $this->validator->validate((new StoredObject())->setFilename('present'), new AsyncFileExists()); + + $this->assertNoViolation(); + } + + public function testWhenFileIsNotPresent(): void + { + $this->validator->validate( + (new StoredObject())->setFilename('is_404'), + new AsyncFileExists(['message' => 'my_message']) + ); + + $this->buildViolation('my_message')->setParameter('{{ filename }}', 'is_404')->assertRaised(); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Validator/Constraints/AsyncFileExists.php b/src/Bundle/ChillDocStoreBundle/Validator/Constraints/AsyncFileExists.php new file mode 100644 index 000000000..4e251629b --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Validator/Constraints/AsyncFileExists.php @@ -0,0 +1,32 @@ +validateObject($value->getFilename(), $constraint); + } elseif (is_string($value)) { + $this->validateObject($value, $constraint); + } else { + throw new UnexpectedValueException($value, StoredObject::class.' or string'); + } + } + + protected function validateObject(string $file, Constraint $constraint): void + { + if (!$constraint instanceof AsyncFileExists) { + throw new UnexpectedTypeException($constraint, AsyncFileExists::class); + } + + $urlHead = $this->tempUrlGenerator->generate( + 'HEAD', + $file, + 30 + ); + + try { + $response = $this->client->request('HEAD', $urlHead->url); + + if (404 === $response->getStatusCode()) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ filename }}', $file) + ->addViolation(); + } + } catch (HttpExceptionInterface $exception) { + if (404 !== $exception->getResponse()->getStatusCode()) { + throw $exception; + } + } + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index c510064f1..27c04a60e 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -8,18 +8,6 @@ services: tags: - { name: doctrine.repository_service } - Chill\DocStoreBundle\Form\DocumentCategoryType: - class: Chill\DocStoreBundle\Form\DocumentCategoryType - arguments: [ "%kernel.bundles%" ] - tags: - - { name: form.type } - - Chill\DocStoreBundle\Form\PersonDocumentType: - class: Chill\DocStoreBundle\Form\PersonDocumentType - # arguments: - # - "@chill.main.helper.translatable_string" - tags: - - { name: form.type, alias: chill_docstorebundle_form_document } Chill\DocStoreBundle\Security\Authorization\: resource: "./../Security/Authorization" @@ -54,6 +42,9 @@ services: Chill\DocStoreBundle\GenericDoc\Renderer\: resource: '../GenericDoc/Renderer/' + Chill\DocStoreBundle\Validator\: + resource: '../Validator' + Chill\DocStoreBundle\AsyncUpload\Driver\: resource: '../AsyncUpload/Driver/' diff --git a/src/Bundle/ChillDocStoreBundle/config/services/form.yaml b/src/Bundle/ChillDocStoreBundle/config/services/form.yaml index 8d53d81f1..7515f306a 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/form.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/form.yaml @@ -1,13 +1,15 @@ services: - Chill\DocStoreBundle\Form\StoredObjectType: - arguments: - $em: '@Doctrine\ORM\EntityManagerInterface' - tags: - - { name: form.type } + _defaults: + autowire: true + autoconfigure: true - Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType: - class: Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType - arguments: - - "@chill.main.helper.translatable_string" - tags: - - { name: form.type, alias: chill_docstorebundle_form_document } + Chill\DocStoreBundle\Form\: + resource: '../../Form' + + Chill\DocStoreBundle\Form\PersonDocumentType: + tags: + - { name: form.type, alias: chill_docstorebundle_form_document } + + Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType: + tags: + - { name: form.type, alias: chill_docstorebundle_form_document } From 82ca32171570692f115bbc797bf6d58f0aa72b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Dec 2023 22:47:15 +0100 Subject: [PATCH 008/132] Add exceptions for async file handling failures Introduced two new exceptions, `BadCallToRemoteServer` and `TempUrlRemoteServerException`, to improve error handling in asynchronous file operations. These exceptions are thrown when there are issues with the remote server during an async file operation such as HTTP status codes >= 400 and if the server is unreachable. --- .../Exception/BadCallToRemoteServer.php | 20 +++++++++++++++++++ .../TempUrlRemoteServerException.php | 20 +++++++++++++++++++ .../Constraints/AsyncFileExistsValidator.php | 11 +++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/BadCallToRemoteServer.php create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/TempUrlRemoteServerException.php diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/BadCallToRemoteServer.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/BadCallToRemoteServer.php new file mode 100644 index 000000000..58ddfe0b0 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Exception/BadCallToRemoteServer.php @@ -0,0 +1,20 @@ +client->request('HEAD', $urlHead->url); - if (404 === $response->getStatusCode()) { + if (404 === $status = $response->getStatusCode()) { $this->context->buildViolation($constraint->message) ->setParameter('{{ filename }}', $file) ->addViolation(); + } elseif (500 <= $status) { + throw new TempUrlRemoteServerException($response->getStatusCode()); + } elseif (400 <= $status) { + throw new BadCallToRemoteServer($response->getContent(false), $response->getStatusCode()); } } catch (HttpExceptionInterface $exception) { if (404 !== $exception->getResponse()->getStatusCode()) { throw $exception; } + } catch (TransportExceptionInterface $e) { + throw new TempUrlRemoteServerException(0, previous: $e); } } } From 45e1ce034a3063b3da35994efb80f787e9900dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 11:35:44 +0100 Subject: [PATCH 009/132] Add ConfigureOpenstackObjectStorageCommand to ChillDocStoreBundle Added new command file "ConfigureOpenstackObjectStorageCommand.php" under ChillDocStoreBundle that helps in setting up OpenStack container for document storage. Along with the command, added corresponding test file "ConfigureOpenstackObjectStorageCommandTest.php" to ensure the functionality is working as expected. --- ...ConfigureOpenstackObjectStorageCommand.php | 90 +++++++++++++++++++ ...igureOpenstackObjectStorageCommandTest.php | 65 ++++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 3 + 3 files changed, 158 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommandTest.php diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php new file mode 100644 index 000000000..de6690faf --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php @@ -0,0 +1,90 @@ +get('chill_doc_store')['openstack']['temp_url']; + + $this->tempUrlKey = $config['temp_url_key']; + $this->basePath = $config['temp_url_base_path']; + + parent::__construct(); + } + + protected function configure() + { + $this->setDescription('Configure openstack container to store documents') + ->setName('chill:doc-store:configure-openstack') + ->addOption('os_token', 'o', InputOption::VALUE_REQUIRED, 'Openstack token') + ->addOption('domain', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Domain name') + ; + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + if (!$input->hasOption('os_token')) { + $output->writeln('The option os_token is required'); + + throw new \RuntimeException('The option os_token is required'); + } + + if (0 === count($input->getOption('domain'))) { + $output->writeln('At least one occurence of option domain is required'); + + throw new \RuntimeException('At least one occurence of option domain is required'); + } + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $domains = trim(implode(' ', $input->getOption('domain'))); + + if ($output->isVerbose()) { + $output->writeln(['Domains configured will be', $domains]); + } + + try { + $response = $this->client->request('POST', $this->basePath, [ + 'headers' => [ + 'X-Auth-Token' => $input->getOption('os_token'), + 'X-Container-Meta-Access-Control-Allow-Origin' => $domains, + 'X-Container-Meta-Temp-URL-Key' => $this->tempUrlKey, + ], + ]); + $response->getContent(); + } catch (HttpExceptionInterface $e) { + $output->writeln('Error'); + $output->writeln($e->getMessage()); + + if ($output->isVerbose()) { + $output->writeln($e->getTraceAsString()); + } + } + + return 0; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommandTest.php b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommandTest.php new file mode 100644 index 000000000..e0318313c --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommandTest.php @@ -0,0 +1,65 @@ + 204]); + }); + + $parameters = new ParameterBag([ + 'chill_doc_store' => [ + 'openstack' => [ + 'temp_url' => [ + 'temp_url_key' => '12345679801234567890', + 'temp_url_base_path' => 'https://object.store.example/v1/AUTH/container', + ], + ], + ], + ]); + + $command = new ConfigureOpenstackObjectStorageCommand($client, $parameters); + + $tester = new CommandTester($command); + + $status = $tester->execute([ + '--os_token' => 'abc', + '--domain' => ['https://chill.domain.social', 'https://chill2.domain.social'], + ]); + + self::assertSame(0, $status); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 27c04a60e..55163abb3 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -51,5 +51,8 @@ services: Chill\DocStoreBundle\AsyncUpload\Templating\: resource: '../AsyncUpload/Templating/' + Chill\DocStoreBundle\AsyncUpload\Command\: + resource: '../AsyncUpload/Command/' + Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface: alias: Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\TempUrlOpenstackGenerator From f131572344f175249bdb3ea3e68ae00330ecaaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 12:01:51 +0100 Subject: [PATCH 010/132] Remove references to old async upload bundle --- composer.json | 1 - .../ChillDocStoreExtension.php | 1 - .../Entity/StoredObject.php | 3 +- .../Object/ObjectToAsyncFileTransformer.php | 47 ------------------- .../Object/PersistenceChecker.php | 40 ---------------- .../Tests/StoredObjectManagerTest.php | 10 ++-- .../config/services/media.yaml | 9 ---- 7 files changed, 8 insertions(+), 103 deletions(-) delete mode 100644 src/Bundle/ChillDocStoreBundle/Object/ObjectToAsyncFileTransformer.php delete mode 100644 src/Bundle/ChillDocStoreBundle/Object/PersistenceChecker.php delete mode 100644 src/Bundle/ChillDocStoreBundle/config/services/media.yaml diff --git a/composer.json b/composer.json index 3195f732b..3a12f5617 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ "ext-json": "*", "ext-openssl": "*", "ext-redis": "*", - "champs-libres/async-uploader-bundle": "dev-sf4#d57134aee8e504a83c902ff0cf9f8d36ac418290", "champs-libres/wopi-bundle": "dev-master@dev", "champs-libres/wopi-lib": "dev-master@dev", "doctrine/doctrine-bundle": "^2.1", diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php index 70c479456..7ae5dcbe1 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/ChillDocStoreExtension.php @@ -36,7 +36,6 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); - $loader->load('services/media.yaml'); $loader->load('services/controller.yaml'); $loader->load('services/menu.yaml'); $loader->load('services/fixtures.yaml'); diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index abccdccc7..e937b2539 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Entity; -use ChampsLibres\AsyncUploaderBundle\Model\AsyncFileInterface; use Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists; use ChampsLibres\WopiLib\Contract\Entity\Document; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; @@ -33,7 +32,7 @@ use Symfony\Component\Serializer\Annotation as Serializer; * message="The file is not stored properly" * ) */ -class StoredObject implements AsyncFileInterface, Document, TrackCreationInterface +class StoredObject implements Document, TrackCreationInterface { use TrackCreationTrait; final public const STATUS_READY = 'ready'; diff --git a/src/Bundle/ChillDocStoreBundle/Object/ObjectToAsyncFileTransformer.php b/src/Bundle/ChillDocStoreBundle/Object/ObjectToAsyncFileTransformer.php deleted file mode 100644 index 8755b1c61..000000000 --- a/src/Bundle/ChillDocStoreBundle/Object/ObjectToAsyncFileTransformer.php +++ /dev/null @@ -1,47 +0,0 @@ -em = $em; - } - - public function toAsyncFile($data) - { - if ($data instanceof StoredObject) { - return $data; - } - } - - public function toData(AsyncFileInterface $asyncFile) - { - $object = $this->em - ->getRepository(StoredObject::class) - ->findByFilename($asyncFile->getObjectName()); - - return $object ?? (new StoredObject()) - ->setFilename($asyncFile->getObjectName()); - } -} diff --git a/src/Bundle/ChillDocStoreBundle/Object/PersistenceChecker.php b/src/Bundle/ChillDocStoreBundle/Object/PersistenceChecker.php deleted file mode 100644 index 97dfdfa92..000000000 --- a/src/Bundle/ChillDocStoreBundle/Object/PersistenceChecker.php +++ /dev/null @@ -1,40 +0,0 @@ -em = $em; - } - - public function isPersisted($object_name): bool - { - $qb = $this->em->createQueryBuilder(); - $qb->select('COUNT(m)') - ->from(StoredObject::class, 'm') - ->where($qb->expr()->eq('m.filename', ':object_name')) - ->setParameter('object_name', $object_name); - - return 1 === $qb->getQuery()->getSingleScalarResult(); - } -} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php index bf659ba9b..226f67118 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php @@ -11,7 +11,8 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Tests; -use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; +use Chill\DocStoreBundle\AsyncUpload\SignedUrl; +use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Exception\StoredObjectManagerException; use Chill\DocStoreBundle\Service\StoredObjectManager; @@ -163,8 +164,11 @@ final class StoredObjectManagerTest extends TestCase private function getTempUrlGenerator(StoredObject $storedObject): TempUrlGeneratorInterface { - $response = new \stdClass(); - $response->url = $storedObject->getFilename(); + $response = new SignedUrl( + 'PUT', + 'https://example.com/'.$storedObject->getFilename(), + new \DateTimeImmutable('1 hours') + ); $tempUrlGenerator = $this->createMock(TempUrlGeneratorInterface::class); diff --git a/src/Bundle/ChillDocStoreBundle/config/services/media.yaml b/src/Bundle/ChillDocStoreBundle/config/services/media.yaml deleted file mode 100644 index e6afe2155..000000000 --- a/src/Bundle/ChillDocStoreBundle/config/services/media.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - chill_doc_store.persistence_checker: - class: Chill\DocStoreBundle\Object\PersistenceChecker - arguments: - $em: '@Doctrine\ORM\EntityManagerInterface' - - Chill\DocStoreBundle\Object\ObjectToAsyncFileTransformer: - arguments: - $em: '@Doctrine\ORM\EntityManagerInterface' From 1065706e60cfa12ca4e7c6762df6e42a2e677fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 12:08:45 +0100 Subject: [PATCH 011/132] Re-configure test app --- tests/app/config/bundles.php | 1 - tests/app/config/packages/champs-libres.yaml | 14 -------------- tests/app/config/packages/chill_doc_store.yaml | 6 ++++++ 3 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 tests/app/config/packages/champs-libres.yaml create mode 100644 tests/app/config/packages/chill_doc_store.yaml diff --git a/tests/app/config/bundles.php b/tests/app/config/bundles.php index 36e3bcf03..d39a7c469 100644 --- a/tests/app/config/bundles.php +++ b/tests/app/config/bundles.php @@ -10,7 +10,6 @@ declare(strict_types=1); */ return [ - ChampsLibres\AsyncUploaderBundle\ChampsLibresAsyncUploaderBundle::class => ['all' => true], Chill\ActivityBundle\ChillActivityBundle::class => ['all' => true], Chill\AsideActivityBundle\ChillAsideActivityBundle::class => ['all' => true], Chill\CalendarBundle\ChillCalendarBundle::class => ['all' => true], diff --git a/tests/app/config/packages/champs-libres.yaml b/tests/app/config/packages/champs-libres.yaml deleted file mode 100644 index ebea3ef58..000000000 --- a/tests/app/config/packages/champs-libres.yaml +++ /dev/null @@ -1,14 +0,0 @@ -champs_libres_async_uploader: - openstack: - os_username: '%env(resolve:OS_USERNAME)%' # Required - os_password: '%env(resolve:OS_PASSWORD)%' # Required - os_tenant_id: '%env(resolve:OS_TENANT_ID)%' # Required - os_region_name: '%env(resolve:OS_REGION_NAME)%' # Required - os_auth_url: '%env(resolve:OS_AUTH_URL)%' # Required - temp_url: - temp_url_key: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_KEY)%' # Required - container: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_CONTAINER)%' # Required - temp_url_base_path: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_BASE_PATH)%' # Required. Do not forget a trailing slash - max_post_file_size: 15000000 # 15Mo (bytes) - max_expires_delay: 180 - max_submit_delay: 3600 diff --git a/tests/app/config/packages/chill_doc_store.yaml b/tests/app/config/packages/chill_doc_store.yaml new file mode 100644 index 000000000..994e19240 --- /dev/null +++ b/tests/app/config/packages/chill_doc_store.yaml @@ -0,0 +1,6 @@ +chill_doc_store: + openstack: + temp_url: + temp_url_key: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_KEY)%' # Required + container: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_CONTAINER)%' # Required + temp_url_base_path: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_BASE_PATH)%' # Required From 3fb04594eb30b491e52edeb98054e749132d9dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 15:49:37 +0100 Subject: [PATCH 012/132] add changie [ci-skip] --- .changes/unreleased/Feature-20231212-154841.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20231212-154841.yaml diff --git a/.changes/unreleased/Feature-20231212-154841.yaml b/.changes/unreleased/Feature-20231212-154841.yaml new file mode 100644 index 000000000..14e19345b --- /dev/null +++ b/.changes/unreleased/Feature-20231212-154841.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[DX] move async-upload-bundle features into chill-bundles' +time: 2023-12-12T15:48:41.954970271+01:00 +custom: + Issue: "221" From 16a5745df9558756d0a61cef3179c01770b1b2f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 3 Sep 2023 15:24:50 +0200 Subject: [PATCH 013/132] Update composer to symfony 5 (without config) --- composer.json | 45 +++++++++---------- .../SendShortMessageOnEligibleCalendar.php | 7 +-- .../SendTestShortMessageOnCalendarCommand.php | 7 +-- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index 3195f732b..90a352958 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "ext-json": "*", "ext-openssl": "*", "ext-redis": "*", - "champs-libres/async-uploader-bundle": "dev-sf4#d57134aee8e504a83c902ff0cf9f8d36ac418290", + "champs-libres/async-uploader-bundle": "dev-master@dev", "champs-libres/wopi-bundle": "dev-master@dev", "champs-libres/wopi-lib": "dev-master@dev", "doctrine/doctrine-bundle": "^2.1", @@ -33,27 +33,27 @@ "ramsey/uuid-doctrine": "^1.7", "sensio/framework-extra-bundle": "^5.5", "spomky-labs/base64url": "^2.0", - "symfony/browser-kit": "^4.4", + "symfony/browser-kit": "^5.4", "symfony/clock": "^6.2", - "symfony/css-selector": "^4.4", - "symfony/expression-language": "^4.4", - "symfony/form": "^4.4", - "symfony/framework-bundle": "^4.4", - "symfony/http-client": "^4.4 || ^5", - "symfony/http-foundation": "^4.4", - "symfony/intl": "^4.4", + "symfony/css-selector": "^5.4", + "symfony/expression-language": "^5.4", + "symfony/form": "^5.4", + "symfony/framework-bundle": "^5.4", + "symfony/http-client": "^5.4", + "symfony/http-foundation": "^5.4", + "symfony/intl": "^5.4", "symfony/mailer": "^5.4", "symfony/messenger": "^5.4", "symfony/mime": "^5.4", "symfony/monolog-bundle": "^3.5", - "symfony/security-bundle": "^4.4", - "symfony/serializer": "^5.3", - "symfony/translation": "^4.4", - "symfony/twig-bundle": "^4.4", - "symfony/validator": "^4.4", + "symfony/security-bundle": "^5.4", + "symfony/serializer": "^5.4", + "symfony/translation": "^5.4", + "symfony/twig-bundle": "^5.4", + "symfony/validator": "^5.4", "symfony/webpack-encore-bundle": "^1.11", - "symfony/workflow": "^4.4", - "symfony/yaml": "^4.4", + "symfony/workflow": "^5.4", + "symfony/yaml": "^5.4", "thenetworg/oauth2-azure": "^2.0", "twig/extra-bundle": "^3.0", "twig/intl-extra": "^3.0", @@ -73,16 +73,13 @@ "phpstan/phpstan-deprecation-rules": "^1.1", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": ">= 7.5", - "psalm/plugin-phpunit": "^0.18.4", - "psalm/plugin-symfony": "^4.0.2", "rector/rector": "^0.17.7", - "symfony/debug-bundle": "^5.1", - "symfony/dotenv": "^4.4", + "symfony/debug-bundle": "^5.4", + "symfony/dotenv": "^5.4", "symfony/maker-bundle": "^1.20", - "symfony/phpunit-bridge": "^4.4", - "symfony/stopwatch": "^4.4", - "symfony/var-dumper": "^4.4", - "vimeo/psalm": "^4.30.0" + "symfony/phpunit-bridge": "^5.4", + "symfony/stopwatch": "^5.4", + "symfony/var-dumper": "^5.4" }, "conflict": { "symfony/symfony": "*" diff --git a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php index a027c1bc2..6c1b31b9e 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php @@ -27,12 +27,7 @@ class SendShortMessageOnEligibleCalendar extends Command { public function __construct(private readonly BulkCalendarShortMessageSender $messageSender) { - parent::__construct(); - } - - public function getName() - { - return 'chill:calendar:send-short-messages'; + parent::__construct('chill:calendar:send-short-messages'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index bfbdd2abd..225b540df 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -47,12 +47,7 @@ class SendTestShortMessageOnCalendarCommand extends Command private readonly ShortMessageTransporterInterface $transporter, private readonly UserRepositoryInterface $userRepository ) { - parent::__construct(); - } - - public function getName() - { - return 'chill:calendar:test-send-short-message'; + parent::__construct('chill:calendar:test-send-short-message'); } protected function configure() From ceaabfb034dcadc1cc0a06db459148d36d565292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Sep 2023 12:05:29 +0200 Subject: [PATCH 014/132] Downgrade symfony bundle to ^5.4 (some were on 6.3) composer: restrict missing bundle to symfony 5.4 --- composer.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/composer.json b/composer.json index 90a352958..61ccfd73c 100644 --- a/composer.json +++ b/composer.json @@ -33,10 +33,19 @@ "ramsey/uuid-doctrine": "^1.7", "sensio/framework-extra-bundle": "^5.5", "spomky-labs/base64url": "^2.0", + "symfony/asset": "^5.4", "symfony/browser-kit": "^5.4", + "symfony/cache": "^5.4", "symfony/clock": "^6.2", + "symfony/config": "^5.4", + "symfony/console": "^5.4", "symfony/css-selector": "^5.4", + "symfony/dom-crawler": "^5.4", + "symfony/error-handler": "^5.4", + "symfony/event-dispatcher": "^5.4", "symfony/expression-language": "^5.4", + "symfony/filesystem": "^5.4", + "symfony/finder": "^5.4", "symfony/form": "^5.4", "symfony/framework-bundle": "^5.4", "symfony/http-client": "^5.4", @@ -46,8 +55,19 @@ "symfony/messenger": "^5.4", "symfony/mime": "^5.4", "symfony/monolog-bundle": "^3.5", + "symfony/options-resolver": "^5.4", + "symfony/process": "^5.4", + "symfony/property-access": "^5.4", + "symfony/property-info": "^5.4", + "symfony/routing": "^5.4", "symfony/security-bundle": "^5.4", + "symfony/security-core": "^5.4", + "symfony/security-csrf": "^5.4", + "symfony/security-guard": "^5.4", + "symfony/security-http": "^5.4", "symfony/serializer": "^5.4", + "symfony/string": "^5.4", + "symfony/templating": "^5.4", "symfony/translation": "^5.4", "symfony/twig-bundle": "^5.4", "symfony/validator": "^5.4", From 4c52aa366a1d88fa29332e632d900d5f7519f7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Sep 2023 12:05:57 +0200 Subject: [PATCH 015/132] Rector rules: add rules for 5.0 types --- rector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rector.php b/rector.php index 0dd8e355c..96bd47710 100644 --- a/rector.php +++ b/rector.php @@ -33,6 +33,7 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->sets([ LevelSetList::UP_TO_PHP_82, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_44, + \Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES, \Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, \Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90, ]); From c6bb7b1d9895784c3448e9e4c761274050bd3dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Sep 2023 12:06:07 +0200 Subject: [PATCH 016/132] Rector rules: apply rules for 5.0 types --- .../ChillMainBundle/Form/DataMapper/AddressDataMapper.php | 4 ++-- .../Form/DataMapper/ExportPickCenterDataMapper.php | 4 ++-- .../Form/DataMapper/PrivateCommentDataMapper.php | 4 ++-- .../ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php | 4 ++-- .../ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php | 4 ++-- .../Form/DataMapper/PersonAltNameDataMapper.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php index c88e2275b..8db31c0b1 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php @@ -28,7 +28,7 @@ class AddressDataMapper implements DataMapperInterface * @param Address $address * @param \Iterator $forms */ - public function mapDataToForms($address, $forms) + public function mapDataToForms($address, iterable $forms) { if (null === $address) { return; @@ -78,7 +78,7 @@ class AddressDataMapper implements DataMapperInterface * @param \Iterator $forms * @param Address $address */ - public function mapFormsToData($forms, &$address) + public function mapFormsToData(iterable $forms, &$address) { if (!$address instanceof Address) { $address = new Address(); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 73d048c1a..495c5d221 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\FormInterface; final readonly class ExportPickCenterDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, $forms): void + public function mapDataToForms($viewData, iterable $forms): void { if (null === $viewData) { return; @@ -31,7 +31,7 @@ final readonly class ExportPickCenterDataMapper implements DataMapperInterface // NOTE: we do not map back the regroupments } - public function mapFormsToData($forms, &$viewData): void + public function mapFormsToData(iterable $forms, &$viewData): void { /** @var array $forms */ $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php index 68fad0a99..4f6022afe 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php @@ -21,7 +21,7 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI { public function __construct(private readonly Security $security) {} - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, iterable $forms) { if (null === $viewData) { return null; @@ -36,7 +36,7 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI $forms['comments']->setData($viewData->getCommentForUser($this->security->getUser())); } - public function mapFormsToData($forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData) { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php index 6a139de7b..99dd4b053 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\Exception; class RollingDateDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, iterable $forms) { if (null === $viewData) { return; @@ -33,7 +33,7 @@ class RollingDateDataMapper implements DataMapperInterface $forms['fixedDate']->setData($viewData->getFixedDate()); } - public function mapFormsToData($forms, &$viewData): void + public function mapFormsToData(iterable $forms, &$viewData): void { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php index cf96292af..ef040d16b 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php @@ -18,7 +18,7 @@ class ScopePickerDataMapper implements DataMapperInterface { public function __construct(private readonly ?Scope $scope = null) {} - public function mapDataToForms($data, $forms) + public function mapDataToForms($data, iterable $forms) { $forms = iterator_to_array($forms); @@ -37,7 +37,7 @@ class ScopePickerDataMapper implements DataMapperInterface } } - public function mapFormsToData($forms, &$data) + public function mapFormsToData(iterable $forms, &$data) { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php index 0fc25eefe..ab36e3e9b 100644 --- a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php +++ b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php @@ -19,7 +19,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException; class PersonAltNameDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, iterable $forms) { if (null === $viewData) { return; @@ -47,7 +47,7 @@ class PersonAltNameDataMapper implements DataMapperInterface * @param FormInterface[] $forms * @param Collection $viewData */ - public function mapFormsToData($forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData) { $mapIndexToKey = []; From 2f8de4bf010c03e7565e7ed9adada17b479d34d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 6 Sep 2023 13:26:40 +0200 Subject: [PATCH 017/132] Upgrade recipes: symfony/security-bundle --- src/Bundle/ChillMainBundle/config/services/form.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index 226af2afe..86e78edfa 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -93,12 +93,12 @@ services: Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer: ~ - chill.main.form.advanced_search_type: - class: Chill\MainBundle\Form\AdvancedSearchType - arguments: - - "@chill_main.search_provider" - tags: - - { name: form.type } + #chill.main.form.advanced_search_type: + # class: Chill\MainBundle\Form\AdvancedSearchType + # arguments: + # - "@chill_main.search_provider" + # tags: + # - { name: form.type } Chill\MainBundle\Form\UserPasswordType: arguments: From f9a2d7f2d5c87e1058060dc79b63240bd192ab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Sep 2023 14:42:00 +0200 Subject: [PATCH 018/132] Add symfony runtime to composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 61ccfd73c..9a17a8257 100644 --- a/composer.json +++ b/composer.json @@ -98,6 +98,7 @@ "symfony/dotenv": "^5.4", "symfony/maker-bundle": "^1.20", "symfony/phpunit-bridge": "^5.4", + "symfony/runtime": "^5.4", "symfony/stopwatch": "^5.4", "symfony/var-dumper": "^5.4" }, From f68deca99298e07f0d116ed3337651667621d2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Sep 2023 14:42:11 +0200 Subject: [PATCH 019/132] Fix icu message --- src/Bundle/ChillMainBundle/Entity/User.php | 10 +++--- .../ChillTaskBundle/Menu/UserMenuBuilder.php | 36 ++++--------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 23dfe6926..07724b1c3 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -18,7 +18,8 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; -use libphonenumber\PhoneNumber; +use RuntimeException; +use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -37,7 +38,7 @@ use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint; * "user": User::class * }) */ -class User implements UserInterface, \Stringable +class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInterface { /** * @ORM\Id @@ -306,10 +307,7 @@ class User implements UserInterface, \Stringable return new ArrayCollection($sortedScopeHistories); } - /** - * @return string - */ - public function getPassword() + public function getPassword(): ?string { return $this->password; } diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index a8c299680..e744ddb24 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -19,38 +19,14 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -class UserMenuBuilder implements LocalMenuBuilderInterface +final readonly class UserMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - public $authorizationChecker; - - /** - * @var CountNotificationTask - */ - public $counter; - - /** - * @var TokenStorageInterface - */ - public $tokenStorage; - - /** - * @var TranslatorInterface - */ - public $translator; - public function __construct( - CountNotificationTask $counter, - TokenStorageInterface $tokenStorage, - TranslatorInterface $translator, - AuthorizationCheckerInterface $authorizationChecker + private CountNotificationTask $counter, + private TokenStorageInterface $tokenStorage, + private TranslatorInterface $translator, + private AuthorizationCheckerInterface $authorizationChecker ) { - $this->counter = $counter; - $this->tokenStorage = $tokenStorage; - $this->translator = $translator; - $this->authorizationChecker = $authorizationChecker; } public function buildMenu($menuId, MenuItem $menu, array $parameters) @@ -99,7 +75,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface return ['user']; } - protected function addItemInMenu(MenuItem $menu, $message, $number, $order, array $states = [], array $status = []) + private function addItemInMenu(MenuItem $menu, string $message, int $number, $order, array $states = [], array $status = []) { if (0 < $number) { $menu->addChild( From e2a37fd80b135b1d369417a91e2113844738cb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 17:12:01 +0100 Subject: [PATCH 020/132] fix typo in classname (Phonenumber => PhoneNumber) --- src/Bundle/ChillMainBundle/Entity/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 07724b1c3..58efc8326 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -18,7 +18,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; -use RuntimeException; +use libphonenumber\PhoneNumber; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation as Serializer; @@ -428,7 +428,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter } } - public function getPhonenumber(): ?PhoneNumber + public function getPhonenumber(): PhoneNumber { return $this->phonenumber; } From 99b7b2ec8802da53377d88bfa5efc492916d4ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 17:17:15 +0100 Subject: [PATCH 021/132] upgrade rector rules and apply them --- rector.php | 2 +- .../Tests/Controller/PersonControllerCreateTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 96bd47710..72a7cb9f5 100644 --- a/rector.php +++ b/rector.php @@ -32,7 +32,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ LevelSetList::UP_TO_PHP_82, - \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_44, + \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_50, \Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES, \Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, \Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90, diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index 572374bc1..ed3d44120 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -134,7 +134,7 @@ final class PersonControllerCreateTest extends WebTestCase return $form; } - public function testReviewExistingDetectionInversedLastNameWithFirstName() + public function testReviewExistingDetectionInversedLastNameWithFirstName(): never { $this->markTestSkipped(); $client = $this->getClientAuthenticated(); From f35f5f0876201177b5ace4a896b19c62acf4023e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 17:19:28 +0100 Subject: [PATCH 022/132] fixup! fix typo in classname (Phonenumber => PhoneNumber) --- src/Bundle/ChillMainBundle/Entity/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 58efc8326..fe1489337 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -428,7 +428,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter } } - public function getPhonenumber(): PhoneNumber + public function getPhonenumber(): ?PhoneNumber { return $this->phonenumber; } From ac98ba4555b1d08da5a4e056fb5ce37fe419b1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 17:56:27 +0100 Subject: [PATCH 023/132] re-organize phpstan deprecations files, with a baseline of deprecations for symfony 5.4 --- phpstan-baseline.neon | 25 ++ phpstan-deprecations-sf54.neon | 575 +++++++++++++++++++++++++++++++++ phpstan-deprecations.neon | 422 +----------------------- phpstan.neon.dist | 2 +- 4 files changed, 602 insertions(+), 422 deletions(-) create mode 100644 phpstan-deprecations-sf54.neon diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a89386f29..8af07174d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,30 @@ parameters: ignoreErrors: + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/PersonType.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Repository/NotificationRepository.php + - message: "#^Foreach overwrites \\$key with its key variable\\.$#" count: 1 diff --git a/phpstan-deprecations-sf54.neon b/phpstan-deprecations-sf54.neon new file mode 100644 index 000000000..019df1022 --- /dev/null +++ b/phpstan-deprecations-sf54.neon @@ -0,0 +1,575 @@ +parameters: + ignoreErrors: + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 5 + path: src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 5 + path: src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 2 + path: src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 3 + path: src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillCalendarBundle/Controller/CalendarController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 2 + path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 9 + path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 7 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 2 + path: src/Bundle/ChillEventBundle/Controller/EventController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillEventBundle/Controller/EventController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillEventBundle/Controller/EventTypeController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 10 + path: src/Bundle/ChillEventBundle/Controller/ParticipationController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillEventBundle/Controller/RoleController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillEventBundle/Controller/StatusController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 2 + path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 7 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 3 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 7 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 2 + path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php + + - + message: """ + #^Parameter \\$passwordEncoder of method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\UserPasswordEncoderInterface\\: + since Symfony 5\\.3, use \\{@link UserPasswordHasherInterface\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php + + - + message: """ + #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\EncoderFactory\\: + since Symfony 5\\.3, use \\{@link PasswordHasherFactory\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php + + - + message: """ + #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\MessageDigestPasswordEncoder\\: + since Symfony 5\\.3, use \\{@link MessageDigestPasswordHasher\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 2 + path: src/Bundle/ChillMainBundle/Controller/AbsenceController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/AddressApiController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/MenuController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/NotificationController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 5 + path: src/Bundle/ChillMainBundle/Controller/PasswordController.php + + - + message: """ + #^Parameter \\$passwordEncoder of method Chill\\\\MainBundle\\\\Controller\\\\PasswordController\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\UserPasswordEncoderInterface\\: + since Symfony 5\\.3, use \\{@link UserPasswordHasherInterface\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/PasswordController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/PostalCodeController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 5 + path: src/Bundle/ChillMainBundle/Controller/ScopeController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/SearchController.php + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: """ + #^Parameter \\$passwordEncoder of method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\UserPasswordEncoderInterface\\: + since Symfony 5\\.3, use \\{@link UserPasswordHasherInterface\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserProfileController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/WorkflowController.php + + - + message: """ + #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\EncoderFactory\\: + since Symfony 5\\.3, use \\{@link PasswordHasherFactory\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php + + - + message: """ + #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\MessageDigestPasswordEncoder\\: + since Symfony 5\\.3, use \\{@link MessageDigestPasswordHasher\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php + + - + message: """ + #^Parameter \\$passwordEncoder of method Chill\\\\MainBundle\\\\Form\\\\UserPasswordType\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Security\\\\Core\\\\Encoder\\\\UserPasswordEncoderInterface\\: + since Symfony 5\\.3, use \\{@link UserPasswordHasherInterface\\} instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Form/UserPasswordType.php + + - + message: """ + #^Call to deprecated method isMasterRequest\\(\\) of class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\: + since symfony/http\\-kernel 5\\.3, use isMainRequest\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 2 + path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php + + - + message: """ + #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Exception\\\\UsernameNotFoundException\\: + since Symfony 5\\.3 to be removed in 6\\.0, use UserNotFoundException instead\\.$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 3 + path: src/Bundle/ChillMainBundle/Validation/Validator/UserUniqueEmailAndUsername.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Validator/Constraints/Entity/UserCircleConsistencyValidator.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/CRUD/Controller/EntityPersonCRUDController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 3 + path: src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 5 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 3 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 13 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 6 + path: src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/ClosingMotiveController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 3 + path: src/Bundle/ChillPersonBundle/Controller/HouseholdController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 8 + path: src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillPersonBundle/Controller/PersonController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 8 + path: src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 4 + path: src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php + + - + message: """ + #^Call to deprecated method get\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, use method or constructor injection in your controller instead$# + """ + count: 7 + path: src/Bundle/ChillReportBundle/Controller/ReportController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 9 + path: src/Bundle/ChillReportBundle/Controller/ReportController.php + + - + message: """ + #^Call to deprecated method getDoctrine\\(\\) of class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\: + since Symfony 5\\.4, inject an instance of ManagerRegistry in your controller instead$# + """ + count: 8 + path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php + + - + message: """ + #^Call to deprecated method getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php diff --git a/phpstan-deprecations.neon b/phpstan-deprecations.neon index c83feeb59..7f47e9c71 100644 --- a/phpstan-deprecations.neon +++ b/phpstan-deprecations.neon @@ -1,36 +1,5 @@ parameters: ignoreErrors: - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 2 - path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php - - - - message: "#^Call to deprecated method setType\\(\\) of class Chill\\\\ActivityBundle\\\\Entity\\\\Activity\\.$#" - count: 1 - path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillActivityBundle/Entity/ActivityReason.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillActivityBundle/Form/ActivityType.php - - message: """ @@ -40,201 +9,10 @@ parameters: count: 1 path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php - - - - message: """ - #^Parameter \\$templating of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldChoice\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bridge\\\\Twig\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php - - - - message: "#^Used function LogicException not found\\.$#" - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php - - - - message: """ - #^Parameter \\$templating of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldDate\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bundle\\\\TwigBundle\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php - - - - message: """ - #^Parameter \\$twigEngine of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldLongChoice\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bridge\\\\Twig\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php - - - - message: """ - #^Parameter \\$templating of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldNumber\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bundle\\\\TwigBundle\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php - - - - message: """ - #^Parameter \\$templating of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldText\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bundle\\\\TwigBundle\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php - - - - message: """ - #^Parameter \\$templating of method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldTitle\\:\\:__construct\\(\\) has typehint with deprecated class Symfony\\\\Bundle\\\\TwigBundle\\\\TwigEngine\\: - since version 4\\.3, to be removed in 5\\.0; use Twig instead\\.$# - """ - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" count: 1 - path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 6 - path: src/Bundle/ChillEventBundle/Controller/EventController.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillEventBundle/Form/EventType.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillEventBundle/Form/Type/PickEventType.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php - - - - message: """ - #^Parameter \\$role of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php - - - - message: """ - #^Call to deprecated method getLanguageBundle\\(\\) of class Symfony\\\\Component\\\\Intl\\\\Intl\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use \\{@see Languages\\} or \\{@see Scripts\\} instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php - - - - message: """ - #^Call to deprecated method getRegionBundle\\(\\) of class Symfony\\\\Component\\\\Intl\\\\Intl\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use \\{@see Countries\\} instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php - - - - message: """ - #^Parameter \\$role of anonymous function has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php - - - - message: """ - #^Call to deprecated method getLanguageBundle\\(\\) of class Symfony\\\\Component\\\\Intl\\\\Intl\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use \\{@see Languages\\} or \\{@see Scripts\\} instead\\.$# - """ - count: 2 - path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php - - - - message: """ - #^Return type of method Chill\\\\MainBundle\\\\Entity\\\\User\\:\\:getRoles\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Entity/User.php - - - - message: """ - #^Class Chill\\\\MainBundle\\\\Form\\\\Event\\\\CustomizeFormEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 2 - path: src/Bundle/ChillMainBundle/Repository/NotificationRepository.php - - - - message: """ - #^Parameter \\$attribute of method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:userHasAccess\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php + path: src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php - message: """ @@ -244,14 +22,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php - - - message: """ - #^Parameter \\$role of method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:getReachableCircles\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php - - message: """ #^Parameter \\$centerResolverDispatcher of method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\DefaultVoterHelper\\:\\:__construct\\(\\) has typehint with deprecated interface Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcherInterface\\: @@ -276,14 +46,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php - - - message: """ - #^Class Chill\\\\MainBundle\\\\Security\\\\PasswordRecover\\\\PasswordRecoverEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php - - message: """ #^Class Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcher implements deprecated interface Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcherInterface\\: @@ -292,35 +54,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php - - - - message: """ - #^Class Chill\\\\MainBundle\\\\Templating\\\\Events\\\\DelegatedBlockRenderingEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php - - - - message: """ - #^Class Chill\\\\PersonBundle\\\\Actions\\\\ActionEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Actions/ActionEvent.php - - - - message: """ - #^Class Chill\\\\PersonBundle\\\\Controller\\\\AccompanyingCourseController extends deprecated class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\Controller\\: - since Symfony 4\\.2, use "Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController" instead\\.$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php - - message: """ #^Call to deprecated method getCurrentAccompanyingPeriod\\(\\) of class Chill\\\\PersonBundle\\\\Entity\\\\Person\\: @@ -329,56 +62,10 @@ parameters: count: 1 path: src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php - - - message: """ - #^Class Chill\\\\PersonBundle\\\\Controller\\\\PersonDuplicateController extends deprecated class Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\Controller\\: - since Symfony 4\\.2, use "Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController" instead\\.$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php - - message: "#^Access to deprecated property \\$proxyAccompanyingPeriodOpenState of class Chill\\\\PersonBundle\\\\Entity\\\\Person\\.$#" count: 2 path: src/Bundle/ChillPersonBundle/Entity/Person.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Form/PersonType.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php - - - - message: """ - #^Class Chill\\\\PersonBundle\\\\Privacy\\\\AccompanyingPeriodPrivacyEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php - - - - message: """ - #^Class Chill\\\\PersonBundle\\\\Privacy\\\\PrivacyEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php - - message: """ #^Parameter \\$centerResolverDispatcher of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriodACLAwareRepository\\:\\:__construct\\(\\) has typehint with deprecated interface Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcherInterface\\: @@ -387,48 +74,6 @@ parameters: count: 1 path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 3 - path: src/Bundle/ChillReportBundle/Controller/ReportController.php - - - - - message: """ - #^Parameter \\$role of method Chill\\\\ReportBundle\\\\Form\\\\ReportType\\:\\:appendScopeChoices\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillReportBundle/Form/ReportType.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillReportBundle/Search/ReportSearch.php - - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 2 - path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php - - message: """ #^Parameter \\$centerResolverDispatcher of method Chill\\\\TaskBundle\\\\Controller\\\\SingleTaskController\\:\\:__construct\\(\\) has typehint with deprecated interface Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcherInterface\\: @@ -437,46 +82,6 @@ parameters: count: 1 path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php - - - message: """ - #^Parameter \\$role of method Chill\\\\TaskBundle\\\\Controller\\\\SingleTaskController\\:\\:setCreateForm\\(\\) has typehint with deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php - - - - message: """ - #^Class Chill\\\\TaskBundle\\\\Event\\\\TaskEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Event/TaskEvent.php - - - - message: """ - #^Class Chill\\\\TaskBundle\\\\Event\\\\UI\\\\UIEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 4 - path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php - - - - message: """ - #^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php - - message: """ #^Parameter \\$centerResolverDispatcher of method Chill\\\\TaskBundle\\\\Form\\\\SingleTaskType\\:\\:__construct\\(\\) has typehint with deprecated interface Chill\\\\MainBundle\\\\Security\\\\Resolver\\\\CenterResolverDispatcherInterface\\: @@ -484,28 +89,3 @@ parameters: """ count: 1 path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php - - - - message: """ - #^Class Chill\\\\TaskBundle\\\\Security\\\\Authorization\\\\AuthorizationEvent extends deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event\\: - since Symfony 4\\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead$# - """ - count: 1 - path: src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php - - - - message: """ - #^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\: - since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$# - """ - count: 3 - path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php - diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 62dbe0468..648e4e608 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -31,4 +31,4 @@ includes: - phpstan-baseline-level-3.neon - phpstan-baseline-level-4.neon - phpstan-baseline-level-5.neon - + - phpstan-deprecations-sf54.neon From af663cf27cf7cd92a2eed265eda98a67d793488b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 22:33:57 +0100 Subject: [PATCH 024/132] Create the helper ChillSecurity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En symfony 5.4 le typage a été vraiment amélioré, et phpstan peut détecter plus d'erreur potentielles. Mais le problème est que Symfony "type" les `User` avec son propre `Symfony\Component\Security\Core\User\UserInterface` alors qu'on a besoin de `Chill\MainBundle\Entity\User`. Imaginons qu'on a ceci: ```php namespace Chill\Bundle\Service; final readonly class SomeService { public function myMethod(\Chill\MainBundle\Entity\User $user): void { // ... } } ``` Quand on l'appelle dans un contrôleur ou dans un service: ```php namespace Chill\Bundle\Service; use Symfony\Component\Security\Core\Security; final readonly OtherService { public function __construct(private Security $security, private SomeService $service) {} public function __invoke(): void { $this->service->myMethod($this->security->getUser()); } } ``` PHPstan va se plaindre: ``` Parameter #1 $user of method SomeService::myMethod() expects Chill\MainBundle\Entity\User, Symfony\Component\Security\Core\User\UserInterface|null given. ``` Du coup, j'ai créé ce service: ```php service->myMethod($this->security->getUser()); } } ``` Et tout va bien se passer. Ca sera dans la version de chill qui fait passer à symfony 5.4. --- .../Security/ChillSecurity.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Security/ChillSecurity.php diff --git a/src/Bundle/ChillMainBundle/Security/ChillSecurity.php b/src/Bundle/ChillMainBundle/Security/ChillSecurity.php new file mode 100644 index 000000000..eb21d00df --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/ChillSecurity.php @@ -0,0 +1,54 @@ +security->getUser(); + } + + public function getUser(): User + { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + throw new \LogicException(sprintf('authenticated user should be an instance of %s, %s given', User::class, null !== $user ? $user::class : self::class)); + } + + return $user; + } + + public function isGranted($attribute, $subject = null): bool + { + return $this->security->isGranted($attribute, $subject); + } + + public function getToken(): ?TokenInterface + { + return $this->security->getToken(); + } +} From da997badd92646d74128816268895728604e9366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 22:34:26 +0100 Subject: [PATCH 025/132] Fix phpstan issues --- .../Controller/ActivityController.php | 12 ++-- .../DataFixtures/ORM/LoadActivity.php | 2 +- .../Controller/AsideActivityController.php | 12 +++- .../Event/ListenToActivityCreate.php | 2 +- .../DocGeneratorTemplateController.php | 15 ++++- .../Controller/AbsenceController.php | 7 ++- .../Controller/NotificationController.php | 29 ++++------ .../Controller/PasswordController.php | 57 +++---------------- .../Controller/SearchController.php | 2 +- .../Controller/UserApiController.php | 10 +++- .../Controller/UserController.php | 13 ++++- .../Controller/UserProfileController.php | 11 +++- .../Controller/WorkflowController.php | 34 +++++------ src/Bundle/ChillMainBundle/Entity/User.php | 5 ++ .../AccompanyingCourseController.php | 53 +++++++++++------ .../AccompanyingCourseWorkApiController.php | 18 +++++- .../Controller/HouseholdMemberController.php | 57 ++++++++++++------- .../Controller/PersonDuplicateController.php | 25 ++++++-- .../DataMapper/PersonAltNameDataMapper.php | 8 +-- .../Form/Type/PickPersonType.php | 56 +++++------------- .../Privacy/PrivacyEventSubscriber.php | 37 ++++++------ .../config/services/controller.yaml | 6 -- .../ChillReportBundle/Form/ReportType.php | 46 +++++---------- .../Controller/SingleTaskController.php | 12 +++- .../Controller/TaskController.php | 4 +- .../ChillTaskBundle/Menu/UserMenuBuilder.php | 3 +- 26 files changed, 275 insertions(+), 261 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 06489010c..25dd3fedd 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -24,6 +24,7 @@ use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\LocationRepository; use Chill\MainBundle\Repository\UserRepositoryInterface; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; @@ -67,6 +68,7 @@ final class ActivityController extends AbstractController private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly PaginatorFactory $paginatorFactory, + private readonly ChillSecurity $security ) {} /** @@ -384,7 +386,7 @@ final class ActivityController extends AbstractController } $entity = new Activity(); - $entity->setUser($this->getUser()); + $entity->setUser($this->security->getUser()); if ($person instanceof Person) { $entity->setPerson($person); @@ -399,7 +401,7 @@ final class ActivityController extends AbstractController $entity->setDate(new \DateTime('now')); if ($request->query->has('activityData')) { - $activityData = $request->query->get('activityData'); + $activityData = $request->query->all('activityData'); if (\array_key_exists('durationTime', $activityData) && $activityType->getDurationTimeVisible() > 0) { $durationTimeInMinutes = $activityData['durationTime']; @@ -452,7 +454,7 @@ final class ActivityController extends AbstractController if (\array_key_exists('comment', $activityData) && $activityType->getCommentVisible() > 0) { $comment = new CommentEmbeddable(); $comment->setComment($activityData['comment']); - $comment->setUserId($this->getUser()->getid()); + $comment->setUserId($this->security->getUser()->getId()); $comment->setDate(new \DateTime('now')); $entity->setComment($comment); } @@ -513,7 +515,7 @@ final class ActivityController extends AbstractController $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); - $defaultLocation = $this->getUser()->getCurrentLocation(); + $defaultLocation = $this->security->getUser()->getCurrentLocation(); return $this->render($view, [ 'person' => $person, @@ -568,7 +570,7 @@ final class ActivityController extends AbstractController 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'data' => $data, - 'activityData' => $request->query->get('activityData', []), + 'activityData' => $request->query->all('activityData'), ]); } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index b205384e6..a547ab21e 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -64,7 +64,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface ->setPerson($person) ->setDate($this->faker->dateTimeThisYear()) ->setDurationTime($this->faker->dateTime(36000)) - ->setType($this->getRandomActivityType()) + ->setActivityType($this->getRandomActivityType()) ->setScope($this->getRandomScope()); // ->setAttendee($this->faker->boolean()) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index c29a5a6dc..e0d553327 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -15,19 +15,25 @@ use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository; use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\Pagination\PaginatorInterface; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; final class AsideActivityController extends CRUDController { - public function __construct(private readonly AsideActivityCategoryRepository $categoryRepository) {} + public function __construct(private readonly AsideActivityCategoryRepository $categoryRepository, private readonly ChillSecurity $security) {} public function createEntity(string $action, Request $request): object { + if (!$this->security->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } + $asideActivity = new AsideActivity(); - $asideActivity->setAgent($this->getUser()); - $asideActivity->setLocation($this->getUser()->getCurrentLocation()); + $asideActivity->setAgent($this->security->getUser()); + $asideActivity->setLocation($this->security->getUser()->getCurrentLocation()); $duration = $request->query->get('duration', '300'); $duration = \DateTime::createFromFormat('U', $duration); diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php index 82c76eea4..79629bfbb 100644 --- a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php +++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php @@ -29,7 +29,7 @@ class ListenToActivityCreate } if ($request->query->has('activityData')) { - $activityData = $request->query->get('activityData'); + $activityData = $request->query->all('activityData'); if (\array_key_exists('calendarId', $activityData)) { $calendarId = $activityData['calendarId']; diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index c9e1873b2..5f8d99f7c 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -20,6 +20,7 @@ use Chill\DocGeneratorBundle\Service\Generator\GeneratorInterface; use Chill\DocGeneratorBundle\Service\Messenger\RequestGenerationMessage; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Serializer\Model\Collection; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -37,7 +38,15 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; final class DocGeneratorTemplateController extends AbstractController { - public function __construct(private readonly ContextManager $contextManager, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly GeneratorInterface $generator, private readonly MessageBusInterface $messageBus, private readonly PaginatorFactory $paginatorFactory, private readonly EntityManagerInterface $entityManager) {} + public function __construct( + private readonly ContextManager $contextManager, + private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, + private readonly GeneratorInterface $generator, + private readonly MessageBusInterface $messageBus, + private readonly PaginatorFactory $paginatorFactory, + private readonly EntityManagerInterface $entityManager, + private readonly ChillSecurity $security + ) {} /** * @Route( @@ -217,7 +226,7 @@ final class DocGeneratorTemplateController extends AbstractController : []; // if is test, render the data or generate the doc - if ($isTest && isset($form) && $form['show_data']->getData()) { + if ($isTest && isset($form) && true === $form['show_data']->getData()) { return $this->render('@ChillDocGenerator/Generator/debug_value.html.twig', [ 'datas' => json_encode($context->getData($template, $entity, $contextGenerationData), \JSON_PRETTY_PRINT), ]); @@ -265,7 +274,7 @@ final class DocGeneratorTemplateController extends AbstractController $this->messageBus->dispatch( new RequestGenerationMessage( - $this->getUser(), + $this->security->getUser(), $template, $entityId, $storedObject, diff --git a/src/Bundle/ChillMainBundle/Controller/AbsenceController.php b/src/Bundle/ChillMainBundle/Controller/AbsenceController.php index 809b7b901..8664dbde5 100644 --- a/src/Bundle/ChillMainBundle/Controller/AbsenceController.php +++ b/src/Bundle/ChillMainBundle/Controller/AbsenceController.php @@ -12,12 +12,15 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; use Chill\MainBundle\Form\AbsenceType; +use Chill\MainBundle\Security\ChillSecurity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class AbsenceController extends AbstractController { + public function __construct(private readonly ChillSecurity $security) {} + /** * @Route( * "/{_locale}/absence", @@ -27,7 +30,7 @@ class AbsenceController extends AbstractController */ public function setAbsence(Request $request) { - $user = $this->getUser(); + $user = $this->security->getUser(); $form = $this->createForm(AbsenceType::class, $user); $form->handleRequest($request); @@ -54,7 +57,7 @@ class AbsenceController extends AbstractController */ public function unsetAbsence(Request $request) { - $user = $this->getUser(); + $user = $this->security->getUser(); $user->setAbsenceStart(null); $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 4131ba714..37b715ebd 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -13,7 +13,6 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\NotificationComment; -use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\NotificationCommentType; use Chill\MainBundle\Form\NotificationType; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; @@ -22,6 +21,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\NotificationRepository; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Security\Authorization\NotificationVoter; +use Chill\MainBundle\Security\ChillSecurity; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -32,7 +32,6 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; @@ -41,7 +40,7 @@ use function in_array; */ class NotificationController extends AbstractController { - public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly Security $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository) {} + public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly ChillSecurity $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository) {} /** * @Route("/create", name="chill_main_notification_create") @@ -50,10 +49,6 @@ class NotificationController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - if (!$this->security->getUser() instanceof User) { - throw new AccessDeniedHttpException('You must be authenticated and a user to create a notification'); - } - if (!$request->query->has('entityClass')) { throw new BadRequestHttpException('Missing entityClass parameter'); } @@ -68,13 +63,13 @@ class NotificationController extends AbstractController ->setRelatedEntityId($request->query->getInt('entityId')) ->setSender($this->security->getUser()); - if ($request->query->has('tos')) { - foreach ($request->query->get('tos') as $toId) { - if (null === $to = $this->userRepository->find($toId)) { - throw new NotFoundHttpException("user with id {$toId} is not found"); - } - $notification->addAddressee($to); + $tos = $request->query->all('tos'); + + foreach ($tos as $toId) { + if (null === $to = $this->userRepository->find($toId)) { + throw new NotFoundHttpException("user with id {$toId} is not found"); } + $notification->addAddressee($to); } try { @@ -144,10 +139,6 @@ class NotificationController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - if (!$this->security->getUser() instanceof User) { - throw new AccessDeniedHttpException('You must be authenticated and a user to create a notification'); - } - foreach (['accessKey'/* , 'email' */] as $param) { if (!$request->query->has($param)) { throw new BadRequestHttpException("Missing {$param} parameter"); @@ -308,8 +299,8 @@ class NotificationController extends AbstractController ]); // we mark the notification as read after having computed the response - if ($this->getUser() instanceof User && !$notification->isReadBy($this->getUser())) { - $notification->markAsReadBy($this->getUser()); + if (!$notification->isReadBy($this->security->getUser())) { + $notification->markAsReadBy($this->security->getUser()); $this->em->flush(); } diff --git a/src/Bundle/ChillMainBundle/Controller/PasswordController.php b/src/Bundle/ChillMainBundle/Controller/PasswordController.php index 04ec22977..c6815f2cf 100644 --- a/src/Bundle/ChillMainBundle/Controller/PasswordController.php +++ b/src/Bundle/ChillMainBundle/Controller/PasswordController.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\UserPasswordType; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Security\PasswordRecover\PasswordRecoverEvent; use Chill\MainBundle\Security\PasswordRecover\PasswordRecoverVoter; use Chill\MainBundle\Security\PasswordRecover\RecoverPasswordHelper; @@ -24,6 +25,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Constraints\Callback; @@ -33,56 +35,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * Class PasswordController. */ -class PasswordController extends AbstractController +final class PasswordController extends AbstractController { - /** - * @var LoggerInterface - */ - protected $chillLogger; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @var UserPasswordEncoderInterface - */ - protected $passwordEncoder; - - /** - * @var RecoverPasswordHelper - */ - protected $recoverPasswordHelper; - - /** - * @var TokenManager - */ - protected $tokenManager; - - /** - * @var TranslatorInterface - */ - protected $translator; - /** * PasswordController constructor. */ - public function __construct( - LoggerInterface $chillLogger, - UserPasswordEncoderInterface $passwordEncoder, - RecoverPasswordHelper $recoverPasswordHelper, - TokenManager $tokenManager, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher - ) { - $this->chillLogger = $chillLogger; - $this->passwordEncoder = $passwordEncoder; - $this->translator = $translator; - $this->tokenManager = $tokenManager; - $this->recoverPasswordHelper = $recoverPasswordHelper; - $this->eventDispatcher = $eventDispatcher; - } + public function __construct(private readonly LoggerInterface $chillLogger, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly RecoverPasswordHelper $recoverPasswordHelper, private readonly TokenManager $tokenManager, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly ChillSecurity $security) {} /** * @return Response @@ -250,8 +208,11 @@ class PasswordController extends AbstractController */ public function UserPasswordAction(Request $request) { + if (!$this->security->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } // get authentified user - $user = $this->getUser(); + $user = $this->security->getUser(); // create a form for password_encoder $form = $this->passwordForm($user); @@ -269,7 +230,7 @@ class PasswordController extends AbstractController 'update password for an user', [ 'method' => $request->getMethod(), - 'user' => $user->getUsername(), + 'user' => $user->getUserIdentifier(), ] ); diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 6324561cc..e81e3d9dc 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -199,7 +199,7 @@ class SearchController extends AbstractController { // TODO this is an incomplete implementation $query = $request->query->get('q', ''); - $types = $request->query->get('type', []); + $types = $request->query->all('type'); if (0 === \count($types)) { throw new BadRequestHttpException('The request must contains at one type'); diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index 6809d3289..ae764c9d2 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -13,13 +13,17 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Pagination\PaginatorInterface; +use Chill\MainBundle\Security\ChillSecurity; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; class UserApiController extends ApiController { + public function __construct(private readonly ChillSecurity $security) {} + /** * @Route( * "/api/1.0/main/user-current-location.{_format}", @@ -31,8 +35,12 @@ class UserApiController extends ApiController */ public function currentLocation(mixed $_format): JsonResponse { + if (!$this->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } + return $this->json( - $this->getUser()->getCurrentLocation(), + $this->security->getUser()->getCurrentLocation(), JsonResponse::HTTP_OK, [], ['groups' => ['read']] diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 1a25c4ad4..8e0e8ad1b 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -20,6 +20,7 @@ use Chill\MainBundle\Form\UserPasswordType; use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Pagination\PaginatorInterface; use Chill\MainBundle\Repository\UserRepository; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; @@ -38,7 +39,15 @@ class UserController extends CRUDController { final public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; - public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag, private readonly TranslatorInterface $translator) {} + public function __construct( + private readonly LoggerInterface $logger, + private readonly ValidatorInterface $validator, + private readonly UserPasswordEncoderInterface $passwordEncoder, + private readonly UserRepository $userRepository, + protected ParameterBagInterface $parameterBag, + private readonly TranslatorInterface $translator, + private readonly ChillSecurity $security + ) {} /** * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter", @@ -197,7 +206,7 @@ class UserController extends CRUDController */ public function editCurrentLocationAction(Request $request) { - $user = $this->getUser(); + $user = $this->security->getUser(); $form = $this->createForm(UserCurrentLocationType::class, $user) ->add('submit', SubmitType::class, ['label' => 'Save']) ->handleRequest($request); diff --git a/src/Bundle/ChillMainBundle/Controller/UserProfileController.php b/src/Bundle/ChillMainBundle/Controller/UserProfileController.php index 52aba1a48..0867bf2cd 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserProfileController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserProfileController.php @@ -12,18 +12,21 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; use Chill\MainBundle\Form\UserPhonenumberType; +use Chill\MainBundle\Security\ChillSecurity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Routing\Annotation\Route; -class UserProfileController extends AbstractController +final class UserProfileController extends AbstractController { public function __construct( private readonly TranslatorInterface $translator, + private readonly ChillSecurity $security, ) {} /** @@ -33,7 +36,11 @@ class UserProfileController extends AbstractController */ public function __invoke(Request $request) { - $user = $this->getUser(); + if (!$this->security->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } + + $user = $this->security->getUser(); $editForm = $this->createPhonenumberEditForm($user); $editForm->handleRequest($request); diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index b641ed46a..1e93d6f49 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -20,6 +20,7 @@ use Chill\MainBundle\Form\WorkflowStepType; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter; +use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Workflow\EntityWorkflowManager; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -27,10 +28,9 @@ use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; -use Symfony\Component\Security\Core\Security; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\TransitionBlocker; @@ -38,7 +38,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class WorkflowController extends AbstractController { - public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly Security $security) {} + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly ChillSecurity $security) {} /** * @Route("/{_locale}/main/workflow/create", name="chill_main_workflow_create") @@ -62,7 +62,7 @@ class WorkflowController extends AbstractController ->setRelatedEntityClass($request->query->get('entityClass')) ->setRelatedEntityId($request->query->getInt('entityId')) ->setWorkflowName($request->query->get('workflow')) - ->addSubscriberToFinal($this->getUser()); + ->addSubscriberToFinal($this->security->getUser()); $errors = $this->validator->validate($entityWorkflow, null, ['creation']); @@ -123,17 +123,17 @@ class WorkflowController extends AbstractController } if (!$this->getUser() instanceof User) { - throw new AccessDeniedException('Not a valid user'); + throw new AccessDeniedHttpException('Not a valid user'); } if ($entityWorkflowStep->getAccessKey() !== $accessKey) { - throw new AccessDeniedException('Access key is invalid'); + throw new AccessDeniedHttpException('Access key is invalid'); } if (!$entityWorkflowStep->isWaitingForTransition()) { $this->addFlash('error', $this->translator->trans('workflow.Steps is not waiting for transition. Maybe someone apply the transition before you ?')); } else { - $entityWorkflowStep->addDestUserByAccessKey($this->getUser()); + $entityWorkflowStep->addDestUserByAccessKey($this->security->getUser()); $this->entityManager->flush(); $this->addFlash('success', $this->translator->trans('workflow.You get access to this step')); } @@ -150,11 +150,11 @@ class WorkflowController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - $total = $this->entityWorkflowRepository->countByPreviousTransitionned($this->getUser()); + $total = $this->entityWorkflowRepository->countByPreviousTransitionned($this->security->getUser()); $paginator = $this->paginatorFactory->create($total); $workflows = $this->entityWorkflowRepository->findByPreviousTransitionned( - $this->getUser(), + $this->security->getUser(), ['createdAt' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() @@ -180,11 +180,11 @@ class WorkflowController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - $total = $this->entityWorkflowRepository->countByPreviousDestWithoutReaction($this->getUser()); + $total = $this->entityWorkflowRepository->countByPreviousDestWithoutReaction($this->security->getUser()); $paginator = $this->paginatorFactory->create($total); $workflows = $this->entityWorkflowRepository->findByPreviousDestWithoutReaction( - $this->getUser(), + $this->security->getUser(), ['createdAt' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() @@ -208,11 +208,11 @@ class WorkflowController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - $total = $this->entityWorkflowRepository->countByDest($this->getUser()); + $total = $this->entityWorkflowRepository->countByDest($this->security->getUser()); $paginator = $this->paginatorFactory->create($total); $workflows = $this->entityWorkflowRepository->findByCc( - $this->getUser(), + $this->security->getUser(), ['createdAt' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() @@ -235,11 +235,11 @@ class WorkflowController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - $total = $this->entityWorkflowRepository->countByDest($this->getUser()); + $total = $this->entityWorkflowRepository->countByDest($this->security->getUser()); $paginator = $this->paginatorFactory->create($total); $workflows = $this->entityWorkflowRepository->findByDest( - $this->getUser(), + $this->security->getUser(), ['createdAt' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() @@ -262,11 +262,11 @@ class WorkflowController extends AbstractController { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); - $total = $this->entityWorkflowRepository->countBySubscriber($this->getUser()); + $total = $this->entityWorkflowRepository->countBySubscriber($this->security->getUser()); $paginator = $this->paginatorFactory->create($total); $workflows = $this->entityWorkflowRepository->findBySubscriber( - $this->getUser(), + $this->security->getUser(), ['createdAt' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index fe1489337..d0debee73 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -364,6 +364,11 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter return $this->username; } + public function getUserIdentifier(): string + { + return $this->username; + } + /** * @return string */ diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index af4da0bae..870f07cb4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -12,32 +12,41 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; +use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** * Class AccompanyingCourseController. */ -class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController +final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { - public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator) {} + public function __construct( + private readonly ValidatorInterface $validator, + private readonly AccompanyingPeriodWorkRepository $workRepository, + private readonly Registry $registry, + private readonly TranslatorInterface $translator, + private readonly Security $security, + private readonly PersonRepository $personRepository, + ) {} /** * @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close") @@ -223,26 +232,29 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr */ public function newAction(Request $request): Response { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + $period = new AccompanyingPeriod(); $em = $this->getDoctrine()->getManager(); - if ($request->query->has('person_id')) { - $personIds = $request->query->get('person_id'); + $personIds = $request->query->all('person_id'); - if (false === \is_array($personIds)) { - throw new BadRequestHttpException('person_id parameter should be an array'); - } + foreach ($personIds as $personId) { + $person = $this->personRepository->find($personId); - foreach ($personIds as $personId) { - $person = $em->getRepository(Person::class)->find($personId); - - if (null !== $person) { - $period->addPerson($person); + if (null !== $person) { + if (!$this->isGranted(PersonVoter::SEE, $person)) { + throw new AccessDeniedHttpException(sprintf('person with id %d cannot be seen', $person->getId())); } + $period->addPerson($person); } } - $userLocation = $this->getUser()->getCurrentLocation(); + $userLocation = $user->getCurrentLocation(); $period->setAdministrativeLocation($userLocation); $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period); @@ -260,6 +272,12 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr */ public function newHouseholdParcoursAction(Request $request): Response { + $user = $this->getUser(); + + if (!$user instanceof User || !$this->security->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } + $period = new AccompanyingPeriod(); $em = $this->getDoctrine()->getManager(); @@ -276,8 +294,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr } } - $userLocation = $this->getUser()->getCurrentLocation(); - $period->setAdministrativeLocation($userLocation); + $period->setAdministrativeLocation($user->getCurrentLocation()); $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php index 2a9e4e9da..9999257a3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php @@ -12,28 +12,40 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Serializer\Model\Collection; use Chill\MainBundle\Serializer\Model\Counter; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Security; class AccompanyingCourseWorkApiController extends ApiController { - public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) {} + public function __construct( + private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, + private readonly Security $security, + ) {} /** * @Route("/api/1.0/person/accompanying-period/work/my-near-end") */ public function myWorksNearEndDate(Request $request): JsonResponse { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + $since = (new \DateTimeImmutable('now')) ->sub(new \DateInterval('P'.$request->query->getInt('since', 15).'D')); $until = (new \DateTimeImmutable('now')) ->add(new \DateInterval('P'.$request->query->getInt('since', 15).'D')); $total = $this->accompanyingPeriodWorkRepository - ->countNearEndDateByUser($this->getUser(), $since, $until); + ->countNearEndDateByUser($user, $since, $until); if ($request->query->getBoolean('countOnly', false)) { return $this->json( @@ -46,7 +58,7 @@ class AccompanyingCourseWorkApiController extends ApiController $paginator = $this->getPaginatorFactory()->create($total); $works = $this->accompanyingPeriodWorkRepository - ->findNearEndDateByUser($this->getUser(), $since, $until, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); + ->findNearEndDateByUser($user, $since, $until, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); $collection = new Collection($works, $paginator); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index 7f895d478..0b7326636 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -14,23 +14,37 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdMember; -use Chill\PersonBundle\Entity\Household\Position; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\HouseholdMemberType; use Chill\PersonBundle\Household\MembersEditor; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Repository\Household\HouseholdRepository; +use Chill\PersonBundle\Repository\Household\PositionRepository; +use Chill\PersonBundle\Repository\PersonRepository; +use Chill\PersonBundle\Security\Authorization\HouseholdVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\Exception; use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdMemberController extends ApiController { - public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly AccompanyingPeriodRepository $periodRepository) {} + public function __construct( + private readonly UrlGeneratorInterface $generator, + private readonly TranslatorInterface $translator, + private readonly AccompanyingPeriodRepository $periodRepository, + private readonly PersonRepository $personRepository, + private readonly HouseholdRepository $householdRepository, + private readonly Security $security, + private readonly PositionRepository $positionRepository, + ) {} /** * @Route( @@ -83,43 +97,50 @@ class HouseholdMemberController extends ApiController */ public function editor(Request $request) { - $em = $this->getDoctrine()->getManager(); + $ids = $request->query->all('persons'); - if ($request->query->has('persons')) { - $ids = $request->query->get('persons', []); + if ([] !== $ids) { + $persons = []; - if (0 === \count($ids)) { - throw new BadRequestHttpException('parameters persons in query is not an array or empty'); - } + foreach ($ids as $id) { + if (!is_numeric($id)) { + throw new BadRequestHttpException(sprintf('persons with id %s is not numeric', $id)); + } - $persons = $em->getRepository(Person::class) - ->findById($ids); + $person = $this->personRepository->find((int) $id); + + if (null === $person) { + throw new NotFoundHttpException(sprintf('person with id %d not found', $id)); + } - foreach ($persons as $person) { $this->denyAccessUnlessGranted( PersonVoter::SEE, $person, "You are not allowed to see person with id {$person->getId()}" ); + + $persons[] = $person; } } if ($request->query->has('household')) { $householdId = $request->query->get('household', false); - $household = $em->getRepository(Household::class) + $household = $this->householdRepository ->find($householdId); $allowHouseholdCreate = false; $allowHouseholdSearch = false; $allowLeaveWithoutHousehold = false; if (null === $household) { - throw $this->createNotFoundException('household not found'); + throw new NotFoundHttpException('household not found'); + } + + if (!$this->security->isGranted(HouseholdVoter::EDIT, $household)) { + throw new AccessDeniedHttpException('not allowed to edit this household'); } - // TODO ACL on household } - $positions = $this->getDoctrine()->getManager() - ->getRepository(Position::class) + $positions = $this->positionRepository ->findAll(); $data = [ @@ -140,10 +161,8 @@ class HouseholdMemberController extends ApiController ); if (null === $period) { - throw $this->createNotFoundException('period not found'); + throw new NotFoundHttpException('accompanying period not found'); } - - // TODO add acl on accompanying Course } return $this->render('@ChillPerson/Household/members_editor.html.twig', [ diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 3b7188513..7444dce5a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\EventBundle\Entity\Participation; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Actions\Remove\PersonMove; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\PersonNotDuplicate; @@ -24,15 +25,21 @@ use Chill\PersonBundle\Repository\PersonNotDuplicateRepository; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Search\SimilarPersonMatcher; use Chill\TaskBundle\Entity\SingleTask; -use http\Exception\InvalidArgumentException; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\Security\Core\Security; use function count; class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { - public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher) {} + public function __construct( + private readonly SimilarPersonMatcher $similarPersonMatcher, + private readonly PersonRepository $personRepository, + private readonly PersonMove $personMove, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly Security $security, + ) {} /** * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm", name="chill_person_duplicate_confirm") @@ -40,7 +47,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll public function confirmAction(mixed $person1_id, mixed $person2_id, Request $request) { if ($person1_id === $person2_id) { - throw new InvalidArgumentException('Can not merge same person'); + throw new \InvalidArgumentException('Can not merge same person'); } $person1 = $this->_getPerson($person1_id); @@ -152,6 +159,12 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll */ public function notDuplicateAction(mixed $person1_id, mixed $person2_id) { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + [$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id); $this->denyAccessUnlessGranted( @@ -167,7 +180,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll $personNotDuplicate = new PersonNotDuplicate(); $personNotDuplicate->setPerson1($person1); $personNotDuplicate->setPerson2($person2); - $personNotDuplicate->setUser($this->getUser()); + $personNotDuplicate->setUser($user); $this->getDoctrine()->getManager()->persist($personNotDuplicate); $this->getDoctrine()->getManager()->flush(); @@ -259,7 +272,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll private function _getPersonsByPriority($person1_id, $person2_id) { if ($person1_id === $person2_id) { - throw new InvalidArgumentException('Can not merge same person'); + throw new \InvalidArgumentException('Can not merge same person'); } if ($person1_id > $person2_id) { diff --git a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php index ab36e3e9b..d2a7aba55 100644 --- a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php +++ b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php @@ -19,7 +19,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException; class PersonAltNameDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, iterable $forms) + public function mapDataToForms($viewData, iterable $forms): void { if (null === $viewData) { return; @@ -43,11 +43,7 @@ class PersonAltNameDataMapper implements DataMapperInterface } } - /** - * @param FormInterface[] $forms - * @param Collection $viewData - */ - public function mapFormsToData(iterable $forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData): void { $mapIndexToKey = []; diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index d29b4cd41..f8086369f 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Form\Type; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\GroupCenter; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\ChoiceLoader\PersonChoiceLoader; @@ -25,7 +26,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -41,46 +41,15 @@ use Symfony\Contracts\Translation\TranslatorInterface; * - with the `role` option, only the people belonging to the reachable center for the * given role are displayed. */ -class PickPersonType extends AbstractType +final class PickPersonType extends AbstractType { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var PersonRepository - */ - protected $personRepository; - - /** - * @var TranslatorInterface - */ - protected $translator; - - /** - * @var UrlGeneratorInterface - */ - protected $urlGenerator; - - /** - * @var \Chill\MainBundle\Entity\User - */ - protected $user; - public function __construct( - PersonRepository $personRepository, - TokenStorageInterface $tokenStorage, - AuthorizationHelper $authorizationHelper, - UrlGeneratorInterface $urlGenerator, - TranslatorInterface $translator - ) { - $this->personRepository = $personRepository; - $this->user = $tokenStorage->getToken()->getUser(); - $this->authorizationHelper = $authorizationHelper; - $this->urlGenerator = $urlGenerator; - $this->translator = $translator; - } + private readonly PersonRepository $personRepository, + private readonly TokenStorageInterface $tokenStorage, + private readonly AuthorizationHelper $authorizationHelper, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly TranslatorInterface $translator + ) {} public function buildView(\Symfony\Component\Form\FormView $view, \Symfony\Component\Form\FormInterface $form, array $options) { @@ -130,11 +99,16 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { + $user = $this->tokenStorage->getToken()->getUser(); + if (!$user instanceof User) { + throw new \UnexpectedValueException('user should be an instance of '.User::class); + } + if (null === $options['role']) { - $centers = array_map(static fn (GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); + $centers = array_map(static fn (GroupCenter $g) => $g->getCenter(), $user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper - ->getReachableCenters($this->user, $options['role']->getRole()); + ->getReachableCenters($user, $options['role']->getRole()); } if (null === $options['centers']) { diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index 88eb2b172..00ffa47f5 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -31,31 +31,21 @@ namespace Chill\PersonBundle\Privacy; * along with this program. If not, see . */ +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -class PrivacyEventSubscriber implements EventSubscriberInterface +final readonly class PrivacyEventSubscriber implements EventSubscriberInterface { - /** - * @var LoggerInterface - */ - protected $logger; - - /** - * @var TokenStorageInterface - */ - protected $token; - /** * PrivacyEventSubscriber constructor. */ - public function __construct(LoggerInterface $logger, TokenStorageInterface $token) - { - $this->logger = $logger; - $this->token = $token; - } + public function __construct( + private LoggerInterface $logger, + private TokenStorageInterface $token + ) {} public static function getSubscribedEvents() { @@ -109,11 +99,20 @@ class PrivacyEventSubscriber implements EventSubscriberInterface ); } - protected function getInvolved(): array + private function getInvolved(): array { + $user = $this->token->getToken()->getUser(); + + if ($user instanceof User) { + return [ + 'by_user' => $user->getUserIdentifier(), + 'by_user_id' => $user->getId(), + ]; + } + return [ - 'by_user' => $this->token->getToken()->getUser()->getUsername(), - 'by_user_id' => $this->token->getToken()->getUser()->getId(), + 'by_user' => $user->getUsername(), + 'by_user_id' => $user->getUserIdentifier(), ]; } } diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml index 434d1ea08..9691db298 100644 --- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml @@ -26,12 +26,6 @@ services: Chill\PersonBundle\Controller\AdminController: ~ Chill\PersonBundle\Controller\PersonDuplicateController: - arguments: - $similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher' - $translator: '@Symfony\Contracts\Translation\TranslatorInterface' - $personRepository: '@Chill\PersonBundle\Repository\PersonRepository' - $personMove: '@Chill\PersonBundle\Actions\Remove\PersonMove' - $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface' tags: ['controller.service_arguments'] Chill\PersonBundle\Controller\AccompanyingCourseController: diff --git a/src/Bundle/ChillReportBundle/Form/ReportType.php b/src/Bundle/ChillReportBundle/Form/ReportType.php index 8d6551443..9d979458a 100644 --- a/src/Bundle/ChillReportBundle/Form/ReportType.php +++ b/src/Bundle/ChillReportBundle/Form/ReportType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\ReportBundle\Form; use Chill\CustomFieldsBundle\Form\Type\CustomFieldType; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -22,41 +23,16 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -class ReportType extends AbstractType +final class ReportType extends AbstractType { use AppendScopeChoiceTypeTrait; - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var \Doctrine\Persistence\ObjectManager - */ - protected $om; - - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; - - /** - * @var \Chill\MainBundle\Entity\User - */ - protected $user; - public function __construct( - AuthorizationHelper $helper, - TokenStorageInterface $tokenStorage, - TranslatableStringHelper $translatableStringHelper, - ObjectManager $om - ) { - $this->authorizationHelper = $helper; - $this->user = $tokenStorage->getToken()->getUser(); - $this->translatableStringHelper = $translatableStringHelper; - $this->om = $om; - } + private readonly AuthorizationHelper $authorizationHelper, + private readonly TokenStorageInterface $tokenStorage, + private readonly TranslatableStringHelper $translatableStringHelper, + private readonly ObjectManager $om + ) {} public function buildForm(FormBuilderInterface $builder, array $options) { @@ -74,11 +50,17 @@ class ReportType extends AbstractType 'group' => $options['cFGroup'], ] ); + $user = $this->tokenStorage->getToken()->getUser(); + + if (!$user instanceof User) { + throw new \RuntimeException('user must be a regular user'); + } + $this->appendScopeChoices( $builder, $options['role'], $options['center'], - $this->user, + $user, $this->authorizationHelper, $this->translatableStringHelper, $this->om diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 16c520c75..4c1687b5f 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\TaskBundle\Controller; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\MainBundle\Serializer\Model\Collection; @@ -38,8 +39,10 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; final class SingleTaskController extends AbstractController @@ -55,6 +58,7 @@ final class SingleTaskController extends AbstractController private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private readonly SingleTaskStateRepository $singleTaskStateRepository, private readonly SingleTaskRepository $singleTaskRepository, + private readonly Security $security, ) {} /** @@ -487,8 +491,14 @@ final class SingleTaskController extends AbstractController */ public function newAction(Request $request) { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + $task = (new SingleTask()) - ->setAssignee($this->getUser()) + ->setAssignee($user) ->setType('task_default'); $entityType = $this->getEntityContext($request); diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index e5d060de7..5ffc202de 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -66,7 +66,7 @@ class TaskController extends AbstractController 'chill_task_single_task_show', [ 'id' => $task->getId(), - 'list_params' => $request->query->get('list_params', []), + 'list_params' => $request->query->all('list_params'), ] ); null === $task->getCourse() ? $defaultTemplate = '@ChillTask/SingleTask/Person/transition.html.twig' : $defaultTemplate = '@ChillTask/SingleTask/AccompanyingCourse/transition.html.twig'; @@ -134,8 +134,6 @@ class TaskController extends AbstractController } /** - * @param \Chill\TaskBundle\Controller\AbstractTask $task - * * @return \Symfony\Component\Form\FormInterface */ protected function createTransitionForm(AbstractTask $task) diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index e744ddb24..7f1f8fde8 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -26,8 +26,7 @@ final readonly class UserMenuBuilder implements LocalMenuBuilderInterface private TokenStorageInterface $tokenStorage, private TranslatorInterface $translator, private AuthorizationCheckerInterface $authorizationChecker - ) { - } + ) {} public function buildMenu($menuId, MenuItem $menu, array $parameters) { From de6277494a5ffc853cf58a52e4b7b35bb08ccfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 12 Dec 2023 23:06:42 +0100 Subject: [PATCH 026/132] update configuration of app for internal testing app --- .env.test | 2 + tests/app/config/packages/framework.yaml | 21 +++++++-- tests/app/config/packages/security.yaml | 46 +++++++++++++++++--- tests/app/config/packages/test/security.yaml | 11 ++--- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/.env.test b/.env.test index 9245579c0..f84920e54 100644 --- a/.env.test +++ b/.env.test @@ -4,6 +4,8 @@ KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' +TRUSTED_HOSTS= + ADMIN_PASSWORD=password LOCALE=fr diff --git a/tests/app/config/packages/framework.yaml b/tests/app/config/packages/framework.yaml index 01c554356..011f5760c 100644 --- a/tests/app/config/packages/framework.yaml +++ b/tests/app/config/packages/framework.yaml @@ -2,13 +2,17 @@ framework: secret: '%env(APP_SECRET)%' - # DIRTY FIX un bug dans symfony4 empêche de récupérer un tableau de variables depuis .env - # cfr. https://github.com/symfony/symfony/issues/28599 + http_client: + default_options: + verify_peer: false + verify_host: false + trusted_hosts: - - '^(localhost|127.0.0.1)$' + - '^(localhost|127.0.0.1|web)$' + - '%env(resolve:TRUSTED_HOSTS)%' #csrf_protection: true - #http_method_override: true + http_method_override: false # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. @@ -16,12 +20,21 @@ framework: handler_id: null cookie_secure: auto cookie_samesite: lax + storage_factory_id: session.storage.factory.native #esi: true #fragments: true php_errors: log: true + #error_controller: App\Controller\ErrorController::show + ## sf4 check: ou à déplacer dans un chill.yaml assets: json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + +when@test: + framework: + test: true + session: + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/app/config/packages/security.yaml b/tests/app/config/packages/security.yaml index f93eb04c3..b028b50e5 100644 --- a/tests/app/config/packages/security.yaml +++ b/tests/app/config/packages/security.yaml @@ -1,6 +1,14 @@ security: - # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers + access_decision_manager: + strategy: unanimous + allow_if_all_abstain: false + + enable_authenticator_manager: true + # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords + password_hashers: + Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' + # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider providers: chain_provider: @@ -9,12 +17,11 @@ security: in_memory: memory: users: - admin: { password: '%env(resolve:ADMIN_PASSWORD)%', roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'] } + admin: { password: '%env(resolve:ADMIN_PASSWORD)%', roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH', 'ROLE_USER'] } users: id: chill.main.user_provider encoders: - Chill\MainBundle\Entity\User: algorithm: bcrypt Symfony\Component\Security\Core\User\User: plaintext @@ -25,19 +32,30 @@ security: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false + wopi: + pattern: ^/wopi + provider: chain_provider + stateless: true + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + default: - anonymous: ~ + # remove during upgrade from symfony 4 to symfony 5 TODO check this + #anonymous: ~ provider: chain_provider form_login: csrf_parameter: _csrf_token csrf_token_id: authenticate #csrf_provider: security.csrf.token_manager - logout_on_user_change: true - logout: ~ + # remove during upgrade from symfony 4 to symfony 5 TODO check this + # logout_on_user_change: true + logout: + path: /logout # uncomment to enable impersonate mode in Chill # https://symfony.com/doc/current/security/impersonating_user.html - # switch_user: true + switch_user: true # activate different ways to authenticate # https://symfony.com/doc/current/security.html#firewalls-authentication @@ -47,6 +65,7 @@ security: access_control: - { path: ^/(login|logout), roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/public, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/wopi, roles: IS_AUTHENTICATED_FULLY } # access for homepage, the homepage redirect admin to admin section - { path: ^/$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } - { path: ^/homepage$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } @@ -56,3 +75,16 @@ security: - { path: ^/([a-z]+/)?admin, roles: ROLE_ADMIN } # other pages, only for regular user (no admin) - { path: ^/, roles: ROLE_USER } + +when@test: + security: + password_hashers: + # By default, password hashers are resource intensive and take time. This is + # important to generate secure password hashes. In tests however, secure hashes + # are not important, waste resources and increase test times. The following + # reduces the work factor to the lowest possible values. + Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: + algorithm: auto + cost: 4 # Lowest possible value for bcrypt + time_cost: 3 # Lowest possible value for argon + memory_cost: 10 # Lowest possible value for argon diff --git a/tests/app/config/packages/test/security.yaml b/tests/app/config/packages/test/security.yaml index 4ff914485..5aaa34ce0 100644 --- a/tests/app/config/packages/test/security.yaml +++ b/tests/app/config/packages/test/security.yaml @@ -1,8 +1,9 @@ --- # config/packages/test/security.yaml security: - firewalls: - default: - http_basic: ~ - role_hierarchy: - CHILL_MASTER_ROLE: [CHILL_INHERITED_ROLE_1] + firewalls: + default: + entry_point: http_basic + http_basic: ~ + role_hierarchy: + CHILL_MASTER_ROLE: [ CHILL_INHERITED_ROLE_1 ] From b4063bf1df5a320095cf046094d430909bf7622e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 13 Dec 2023 15:27:27 +0100 Subject: [PATCH 027/132] Update path for Symfony container XML in rector.php The path for Symfony container XML in the rector configuration file has been updated. This adjustment specifically refers to the internal testing application. By updating this path, consistency and efficiency within the testing process will be promoted. --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 72a7cb9f5..a40000b1e 100644 --- a/rector.php +++ b/rector.php @@ -19,7 +19,7 @@ return static function (RectorConfig $rectorConfig): void { __DIR__ . '/src', ]); - $rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/testsApp_KernelDevDebugContainer.xml'); + $rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/test/App_KernelTestDebugContainer.xml '); $rectorConfig->symfonyContainerPhp(__DIR__ . '/tests/symfony-container.php'); //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); From 8c2dc490d04f1639be5af0c00bd5732021071a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 13 Dec 2023 15:47:38 +0100 Subject: [PATCH 028/132] re-configure test app with new scripts (wip) --- .env | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/Kernel.php | 38 +++----------------- tests/console | 39 ++++---------------- 3 files changed, 105 insertions(+), 66 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 000000000..1714966d4 --- /dev/null +++ b/.env @@ -0,0 +1,94 @@ +# * .env contains default values for the environment variables needed by the app +# * .env.local uncommitted file with local overrides +# * .env.$APP_ENV committed environment-specific defaults +# * .env.$APP_ENV.local uncommitted environment-specific overrides +# +# Real environment variables win over .env files. +# +# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. +# https://symfony.com/doc/current/configuration/secrets.html +# +# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). +# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration + +## Locale +LOCALE=fr + +###> symfony/framework-bundle ### +# this should be set in docker-compose.yml file +APP_ENV=prod +APP_SECRET=ChangeItf2b58287ef7f9976409d3f6c72529e99ChangeIt +TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 +TRUSTED_HOSTS='^(localhost|example\.com|nginx)$' +###< symfony/framework-bundle ### + +## Wopi server for editing documents online +WOPI_SERVER=http://collabora:9980 + +# must be manually set in .env.local +# ADMIN_PASSWORD= + +###> symfony/mailer ### +# MAILER_DSN=null://null +###< symfony/mailer ### + +## Notifications +NOTIFICATION_HOST=localhost:8001 +NOTIFICATION_FROM_EMAIL=admin@chill.social +NOTIFICATION_FROM_NAME="Chill " + +## Pgadmin credential +PGADMIN_DEFAULT_EMAIL= +PGADMIN_DEFAULT_PASSWORD= + +## OVH OpenStack Storage Container +ASYNC_UPLOAD_TEMP_URL_KEY= +ASYNC_UPLOAD_TEMP_URL_BASE_PATH= +ASYNC_UPLOAD_TEMP_URL_CONTAINER= + +## Redis Cache +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} + +## Twilio +TWILIO_SID=~ +TWILIO_SECRET=~ +DEFAULT_CARRIER_CODE=BE + +ADD_ADDRESS_DEFAULT_COUNTRY=BE + +ADD_ADDRESS_MAP_CENTER_X=50.8443 +ADD_ADDRESS_MAP_CENTER_Y=4.3523 +ADD_ADDRESS_MAP_CENTER_Z=15 + +SHORT_MESSAGE_DSN=null://null + +## DOCKER IMAGES REGISTRY +#IMAGE_PHP= +#IMAGE_NGINX= + +## DOCKER IMAGES TAG +#VERSION=test +#VERSION=prod + +###> symfony/messenger ### +# Choose one of the transports below +# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages +# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages +MESSENGER_TRANSPORT_DSN=sync:// +MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 +###< symfony/messenger ### + +###> doctrine/doctrine-bundle ### +# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml +# +DATABASE_URL="postgresql://postgres:postgres@db:5432/postgres?serverVersion=14&charset=utf8" +###< doctrine/doctrine-bundle ### + +###> lexik/jwt-authentication-bundle ### +JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem +JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem +JWT_PASSPHRASE=2a30f6ba26521a2613821da35f28386e +###< lexik/jwt-authentication-bundle ### diff --git a/tests/Kernel.php b/tests/Kernel.php index a0ede51ac..fab37c6dd 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -22,43 +22,13 @@ class Kernel extends BaseKernel { use MicroKernelTrait; - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - - public function registerBundles(): iterable + private function getBundlesPath(): string { - $contents = require __DIR__ . '/app/config/bundles.php'; - - foreach ($contents as $class => $envs) { - if ($envs[$this->environment] ?? $envs['all'] ?? false) { - yield new $class(); - } - } + return $this->getConfigDir().'/bundles.php'; } - public function getProjectDir() + private function getConfigDir(): string { - return \dirname(__DIR__); - } - - protected function configureRoutes(RouteCollectionBuilder $routes) - { - $confDir = $this->getProjectDir().'/tests/app/config'; - - $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) - { - $container->addResource(new FileResource($this->getProjectDir().'/tests/app/config/bundles.php')); - $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); - $container->setParameter('container.dumper.inline_factories', true); - $confDir = $this->getProjectDir().'/tests/app/config'; - - $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); + return $this->getProjectDir().'/tests/app/config'; } } diff --git a/tests/console b/tests/console index 264e064a1..c933dc535 100755 --- a/tests/console +++ b/tests/console @@ -3,40 +3,15 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\ErrorHandler\Debug; -if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { - echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; +if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } -set_time_limit(0); +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; -require dirname(__DIR__).'/vendor/autoload.php'; +return function (array $context) { + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); -if (!class_exists(Application::class)) { - throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.'); -} - -$input = new ArgvInput(); -if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -require dirname(__DIR__).'/tests/app/config/bootstrap.php'; - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists(Debug::class)) { - Debug::enable(); - } -} - -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Application($kernel); -$application->run($input); + return new Application($kernel); +}; From 9c17261175cb746701c5106ddd1e9032e7961efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 13 Dec 2023 15:54:33 +0100 Subject: [PATCH 029/132] update phpunit configuration file --- phpunit.xml.dist | 116 +++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 64 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa519e376..cb9d70a8a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,85 +1,73 @@ - - - - - - - - - - - - - - src/Bundle/ChillAsideActivityBundle/src/Tests/ - - - src/Bundle/ChillBudgetBundle/Tests/ - - - src/Bundle/ChillCalendarBundle/Tests/ - - - - src/Bundle/ChillDocGeneratorBundle/tests/ - - - src/Bundle/ChillDocStoreBundle/Tests/ - - + + src/Bundle/ChillDocGeneratorBundle/tests/ + + + src/Bundle/ChillDocStoreBundle/Tests/ + + - - src/Bundle/ChillMainBundle/Tests/ - - - src/Bundle/ChillPersonBundle/Tests/ - - src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php - - src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php - - src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php - - src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php - - + src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php + + src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php + + src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php + + src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php + + - - - src/Bundle/ChillThirdPartyBundle/Tests - - - src/Bundle/ChillWopiBundle/tests/ - - - - - - - - - + - + From e5e9ba6d31fd750fbe731aed6f2906cc7c13fb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 4 Apr 2024 22:46:13 +0200 Subject: [PATCH 071/132] make static required method in AbstractExportTests --- .../WithEvaluationBetweenDatesFilterTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php index e8d13eb1e..b2dc7c217 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php @@ -38,7 +38,7 @@ final class WithEvaluationBetweenDatesFilterTest extends AbstractFilterTest return $this->filter; } - public function getFormData() + public static function getFormData(): array { return [ [ @@ -48,7 +48,7 @@ final class WithEvaluationBetweenDatesFilterTest extends AbstractFilterTest ]; } - public function getQueryBuilders() + public static function getQueryBuilders() { self::bootKernel(); From 1ee3b9e2f0f23f01e163a70832892f0195cd9c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 4 Apr 2024 23:00:27 +0200 Subject: [PATCH 072/132] Remove the tearDown method, because we are not able to delete entities linked with materialized views --- .../Controller/HouseholdApiControllerTest.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 03b5a5576..acc2a09e9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Controller; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\AddressReference; use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Test\PrepareClientTrait; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdMember; @@ -33,22 +34,6 @@ final class HouseholdApiControllerTest extends WebTestCase private static array $toDelete = []; - protected function tearDown(): void - { - self::bootKernel(); - - $em = self::getContainer()->get(EntityManagerInterface::class); - - foreach (self::$toDelete as [$class, $id]) { - $obj = $em->getRepository($class)->find($id); - $em->remove($obj); - } - - $em->flush(); - self::$toDelete = []; - self::ensureKernelShutdown(); - } - public static function generateHouseholdAssociatedWithAddressReference() { self::bootKernel(); From 579bd829f86bafae8fb10cbffc92d31e4a3cb86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 4 Apr 2024 23:30:25 +0200 Subject: [PATCH 073/132] Apply rector rules: symfony up to 54 --- rector.php | 9 +- .../Controller/ActivityController.php | 21 +-- .../ActivityReasonCategoryController.php | 18 +- .../Controller/ActivityReasonController.php | 18 +- .../Controller/AdminController.php | 10 +- .../ChillActivityBundle/Entity/Activity.php | 70 +++----- .../Entity/ActivityPresence.php | 6 +- .../Entity/ActivityType.php | 22 +-- .../src/Controller/AdminController.php | 4 +- .../src/Entity/AsideActivity.php | 3 +- .../src/Entity/AsideActivityCategory.php | 4 +- .../Controller/Admin/AdminController.php | 4 +- .../Controller/ChargeController.php | 15 +- .../Controller/ElementController.php | 8 +- .../Controller/ResourceController.php | 18 +- .../Entity/AbstractElement.php | 19 +-- .../ChillBudgetBundle/Entity/ChargeKind.php | 9 +- .../ChillBudgetBundle/Entity/ResourceKind.php | 11 +- .../AzureGrantAdminConsentAndAcquireToken.php | 4 +- .../MapAndSubscribeUserCalendarCommand.php | 5 +- .../SendShortMessageOnEligibleCalendar.php | 2 +- .../SendTestShortMessageOnCalendarCommand.php | 9 +- .../Controller/AdminController.php | 3 +- .../Controller/CalendarAPIController.php | 7 +- .../Controller/CalendarController.php | 26 +-- .../Controller/CalendarDocController.php | 12 +- .../Controller/CalendarRangeAPIController.php | 7 +- .../Controller/InviteApiController.php | 3 +- .../RemoteCalendarConnectAzureController.php | 8 +- .../RemoteCalendarMSGraphSyncController.php | 5 +- .../RemoteCalendarProxyController.php | 4 +- .../ChillCalendarBundle/Entity/Calendar.php | 72 +++----- .../CalendarDoc/CalendarDocCreateDTO.php | 14 +- .../Entity/CalendarDoc/CalendarDocEditDTO.php | 11 +- .../Entity/CalendarRange.php | 27 +-- .../ChillCalendarBundle/Entity/Invite.php | 9 +- .../RemoteCalendar/Model/RemoteEvent.php | 20 +-- .../Command/CreateFieldsOnGroupCommand.php | 4 +- .../Controller/AdminController.php | 4 +- .../Controller/CustomFieldController.php | 12 +- .../CustomFieldsGroupController.php | 21 +-- .../AdminDocGeneratorTemplateController.php | 4 +- .../DocGeneratorTemplateController.php | 27 +-- .../Entity/DocGeneratorTemplate.php | 14 +- .../Normalizer/DocGenObjectNormalizerTest.php | 27 +-- ...ConfigureOpenstackObjectStorageCommand.php | 5 +- .../AsyncUpload/SignedUrl.php | 13 +- .../AsyncUpload/SignedUrlPost.php | 30 +--- .../Controller/AdminController.php | 6 +- .../Controller/AsyncUploadController.php | 5 +- .../DocumentAccompanyingCourseController.php | 20 +-- .../Controller/DocumentCategoryController.php | 25 +-- .../Controller/DocumentPersonController.php | 21 +-- ...ericDocForAccompanyingPeriodController.php | 3 +- .../Controller/GenericDocForPerson.php | 3 +- .../Controller/StoredObjectApiController.php | 4 +- .../ChillDocStoreBundle/Entity/Document.php | 13 +- .../Entity/StoredObject.php | 37 ++--- .../Controller/AdminController.php | 3 +- .../Controller/EventController.php | 22 +-- .../Controller/EventListController.php | 4 +- .../Controller/EventTypeController.php | 21 +-- .../Controller/ParticipationController.php | 22 +-- .../Controller/RoleController.php | 21 +-- .../Controller/StatusController.php | 21 +-- src/Bundle/ChillEventBundle/Entity/Event.php | 9 +- .../ChillEventBundle/Entity/Participation.php | 11 +- .../Command/ChillImportUsersCommand.php | 9 +- .../ChillUserSendRenewPasswordCodeCommand.php | 4 +- .../Command/ExecuteCronJobCommand.php | 7 +- .../LoadAddressesBEFromBestAddressCommand.php | 7 +- .../LoadAddressesFRFromBANOCommand.php | 7 +- .../Command/LoadAndUpdateLanguagesCommand.php | 4 +- .../Command/LoadCountriesCommand.php | 6 +- .../Command/LoadPostalCodeFR.php | 7 +- .../Command/LoadPostalCodesCommand.php | 5 +- .../Command/SetPasswordCommand.php | 8 +- .../SynchronizeEntityInfoViewsCommand.php | 10 +- .../Controller/AbsenceController.php | 16 +- .../Controller/AddressApiController.php | 4 +- .../AddressReferenceAPIController.php | 4 +- .../AddressToReferenceMatcherController.php | 11 +- .../Controller/AdminController.php | 20 +-- .../Controller/DashboardApiController.php | 3 +- .../Controller/DefaultController.php | 8 +- .../Controller/ExportController.php | 23 +-- ...GeographicalUnitByAddressApiController.php | 4 +- .../Controller/LoginController.php | 2 + .../Controller/NewsItemApiController.php | 3 +- .../Controller/NewsItemHistoryController.php | 8 +- .../Controller/NotificationApiController.php | 16 +- .../Controller/NotificationController.php | 28 +--- .../Controller/PasswordController.php | 22 +-- .../Controller/PermissionApiController.php | 3 +- .../Controller/PermissionsGroupController.php | 25 +-- .../Controller/PostalCodeAPIController.php | 4 +- .../Controller/PostalCodeController.php | 5 +- .../Controller/SavedExportController.php | 12 +- .../Controller/ScopeController.php | 12 +- .../Controller/SearchController.php | 16 +- .../Controller/TimelineCenterController.php | 7 +- .../Controller/UserApiController.php | 20 +-- .../Controller/UserController.php | 23 +-- .../Controller/UserExportController.php | 6 +- .../UserJobScopeHistoriesController.php | 4 +- .../Controller/UserProfileController.php | 3 +- .../Controller/WorkflowApiController.php | 14 +- .../Controller/WorkflowController.php | 34 +--- .../DataFixtures/ORM/LoadUsers.php | 3 +- .../Doctrine/Model/TrackCreationTrait.php | 6 +- .../Doctrine/Model/TrackUpdateTrait.php | 6 +- src/Bundle/ChillMainBundle/Entity/Address.php | 54 ++---- .../Entity/AddressReference.php | 33 ++-- src/Bundle/ChillMainBundle/Entity/Center.php | 6 +- .../ChillMainBundle/Entity/Civility.php | 15 +- src/Bundle/ChillMainBundle/Entity/Country.php | 9 +- .../Entity/DashboardConfigItem.php | 18 +- .../SimpleGeographicalUnitDTO.php | 12 +- .../Entity/GeographicalUnitLayer.php | 9 +- .../ChillMainBundle/Entity/Language.php | 6 +- .../ChillMainBundle/Entity/Location.php | 44 ++--- .../ChillMainBundle/Entity/LocationType.php | 32 ++-- .../ChillMainBundle/Entity/NewsItem.php | 33 ++-- .../ChillMainBundle/Entity/Notification.php | 6 +- .../Entity/NotificationComment.php | 3 +- .../ChillMainBundle/Entity/PostalCode.php | 24 +-- .../ChillMainBundle/Entity/SavedExport.php | 6 +- src/Bundle/ChillMainBundle/Entity/Scope.php | 11 +- src/Bundle/ChillMainBundle/Entity/User.php | 5 +- src/Bundle/ChillMainBundle/Entity/UserJob.php | 11 +- .../Entity/Workflow/EntityWorkflow.php | 8 +- .../Entity/Workflow/EntityWorkflowStep.php | 4 +- .../Form/DataMapper/AddressDataMapper.php | 4 +- .../DataMapper/ExportPickCenterDataMapper.php | 4 +- .../DataMapper/PrivateCommentDataMapper.php | 4 +- .../Form/DataMapper/RollingDateDataMapper.php | 4 +- .../Form/DataMapper/ScopePickerDataMapper.php | 4 +- .../ChillMainBundle/Form/UserPasswordType.php | 5 +- .../Search/SearchApiResult.php | 8 +- .../Security/UserProvider/UserProvider.php | 5 +- .../Tests/Controller/UserControllerTest.php | 7 +- .../Command/ChillPersonMoveCommand.php | 5 +- .../Command/ImportSocialWorkMetadata.php | 1 - ...emoveOldDraftAccompanyingPeriodCommand.php | 5 +- .../AccompanyingCourseApiController.php | 16 +- .../AccompanyingCourseCommentController.php | 17 +- .../AccompanyingCourseController.php | 27 +-- .../AccompanyingCourseWorkApiController.php | 4 +- .../AccompanyingCourseWorkController.php | 41 +---- ...CourseWorkEvaluationDocumentController.php | 8 +- .../AccompanyingPeriodController.php | 23 +-- ...mpanyingPeriodRegulationListController.php | 4 +- ...nyingPeriodWorkEvaluationApiController.php | 9 +- .../Controller/AdminController.php | 19 +-- .../Controller/HouseholdApiController.php | 16 +- .../HouseholdCompositionController.php | 12 +- .../Controller/HouseholdController.php | 60 +------ .../Controller/HouseholdMemberController.php | 20 +-- .../Controller/PersonAddressController.php | 20 +-- .../Controller/PersonApiController.php | 23 +-- .../Controller/PersonController.php | 20 +-- .../Controller/PersonDuplicateController.php | 20 +-- .../Controller/PersonResourceController.php | 16 +- .../ReassignAccompanyingPeriodController.php | 4 +- .../ResidentialAddressController.php | 16 +- .../SocialWorkEvaluationApiController.php | 8 +- .../Controller/TimelinePersonController.php | 4 +- .../UserAccompanyingPeriodController.php | 8 +- .../Entity/AccompanyingPeriod.php | 154 ++++++------------ .../AccompanyingPeriodWork.php | 91 +++-------- .../AccompanyingPeriodWorkEvaluation.php | 69 ++------ ...companyingPeriodWorkEvaluationDocument.php | 31 +--- .../AccompanyingPeriodWorkGoal.php | 23 +-- .../AccompanyingPeriod/ClosingMotive.php | 6 +- .../Entity/AccompanyingPeriod/Comment.php | 29 +--- .../Entity/AccompanyingPeriod/Origin.php | 16 +- .../Entity/AccompanyingPeriod/Resource.php | 25 ++- .../AccompanyingPeriodParticipation.php | 25 +-- .../Entity/Household/Household.php | 53 ++---- .../Entity/Household/HouseholdComposition.php | 32 ++-- .../Household/HouseholdCompositionType.php | 11 +- .../Entity/Household/HouseholdMember.php | 47 ++---- .../Entity/Household/Position.php | 20 +-- .../ChillPersonBundle/Entity/Person.php | 63 +++---- .../Entity/Person/PersonResource.php | 34 ++-- .../Entity/Person/PersonResourceKind.php | 6 +- .../Entity/Person/ResidentialAddress.php | 15 +- .../Entity/PersonAltName.php | 6 +- .../Entity/Relationships/Relation.php | 17 +- .../Entity/Relationships/Relationship.php | 35 ++-- .../Entity/SocialWork/Evaluation.php | 20 +-- .../Entity/SocialWork/Goal.php | 14 +- .../Entity/SocialWork/Result.php | 14 +- .../Entity/SocialWork/SocialAction.php | 8 +- .../Entity/SocialWork/SocialIssue.php | 8 +- .../DataMapper/PersonAltNameDataMapper.php | 4 +- .../Controller/SingleTaskController.php | 58 +------ .../Controller/TaskController.php | 6 +- .../ChillTaskBundle/Entity/AbstractTask.php | 32 ++-- .../ChillTaskBundle/Entity/SingleTask.php | 38 ++--- .../Controller/AdminController.php | 3 +- .../Entity/ThirdParty.php | 70 +++----- .../Entity/ThirdPartyCategory.php | 6 +- .../Entity/ThirdPartyProfession.php | 13 +- 204 files changed, 974 insertions(+), 2346 deletions(-) diff --git a/rector.php b/rector.php index 836202495..ec3020ddf 100644 --- a/rector.php +++ b/rector.php @@ -35,10 +35,13 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_82, - \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_50, + \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\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, - \Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90, ]); // migrate for phpunit diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 7098f283e..2248c54d3 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -73,9 +73,8 @@ final class ActivityController extends AbstractController /** * Deletes a Activity entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/delete", name="chill_activity_activity_delete", methods={"GET", "POST", "DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/{id}/delete', name: 'chill_activity_activity_delete', methods: ['GET', 'POST', 'DELETE'])] public function deleteAction(Request $request, mixed $id) { $view = null; @@ -143,9 +142,8 @@ final class ActivityController extends AbstractController /** * Displays a form to edit an existing Activity entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/edit", name="chill_activity_activity_edit", methods={"GET", "POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/{id}/edit', name: 'chill_activity_activity_edit', methods: ['GET', 'POST', 'PUT'])] public function editAction(int $id, Request $request): Response { $view = null; @@ -238,9 +236,8 @@ final class ActivityController extends AbstractController /** * Lists all Activity entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/", name="chill_activity_activity_list") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/', name: 'chill_activity_activity_list')] public function listAction(Request $request): Response { $view = null; @@ -344,9 +341,7 @@ final class ActivityController extends AbstractController return $filterBuilder->build(); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/new", name="chill_activity_activity_new", methods={"POST", "GET"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/new', name: 'chill_activity_activity_new', methods: ['POST', 'GET'])] public function newAction(Request $request): Response { $view = null; @@ -527,9 +522,7 @@ final class ActivityController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/select-type", name="chill_activity_activity_select_type") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/select-type', name: 'chill_activity_activity_select_type')] public function selectTypeAction(Request $request): Response { $view = null; @@ -574,9 +567,7 @@ final class ActivityController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/show", name="chill_activity_activity_show") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/activity/{id}/show', name: 'chill_activity_activity_show')] public function showAction(Request $request, int $id): Response { $entity = $this->activityRepository->find($id); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php index 67f65d994..0d337416b 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php @@ -26,9 +26,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Creates a new ActivityReasonCategory entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/create", name="chill_activity_activityreasoncategory_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/create', name: 'chill_activity_activityreasoncategory_create', methods: ['POST'])] public function createAction(Request $request) { $entity = new ActivityReasonCategory(); @@ -51,9 +50,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Displays a form to edit an existing ActivityReasonCategory entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/edit", name="chill_activity_activityreasoncategory_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/{id}/edit', name: 'chill_activity_activityreasoncategory_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -74,9 +72,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Lists all ActivityReasonCategory entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/", name="chill_activity_activityreasoncategory") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/', name: 'chill_activity_activityreasoncategory')] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -90,9 +87,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Displays a form to create a new ActivityReasonCategory entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/new", name="chill_activity_activityreasoncategory_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/new', name: 'chill_activity_activityreasoncategory_new')] public function newAction() { $entity = new ActivityReasonCategory(); @@ -106,9 +102,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Finds and displays a ActivityReasonCategory entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/show", name="chill_activity_activityreasoncategory_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/{id}/show', name: 'chill_activity_activityreasoncategory_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -126,9 +121,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Edits an existing ActivityReasonCategory entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/update", name="chill_activity_activityreasoncategory_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreasoncategory/{id}/update', name: 'chill_activity_activityreasoncategory_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php index cb6514656..37d04d367 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php @@ -28,9 +28,8 @@ class ActivityReasonController extends AbstractController /** * Creates a new ActivityReason entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/create", name="chill_activity_activityreason_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/create', name: 'chill_activity_activityreason_create', methods: ['POST'])] public function createAction(Request $request) { $entity = new ActivityReason(); @@ -53,9 +52,8 @@ class ActivityReasonController extends AbstractController /** * Displays a form to edit an existing ActivityReason entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/edit", name="chill_activity_activityreason_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/{id}/edit', name: 'chill_activity_activityreason_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -76,9 +74,8 @@ class ActivityReasonController extends AbstractController /** * Lists all ActivityReason entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/", name="chill_activity_activityreason") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/', name: 'chill_activity_activityreason')] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -92,9 +89,8 @@ class ActivityReasonController extends AbstractController /** * Displays a form to create a new ActivityReason entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/new", name="chill_activity_activityreason_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/new', name: 'chill_activity_activityreason_new')] public function newAction() { $entity = new ActivityReason(); @@ -108,9 +104,8 @@ class ActivityReasonController extends AbstractController /** * Finds and displays a ActivityReason entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/show", name="chill_activity_activityreason_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/{id}/show', name: 'chill_activity_activityreason_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -128,9 +123,8 @@ class ActivityReasonController extends AbstractController /** * Edits an existing ActivityReason entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/update", name="chill_activity_activityreason_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activityreason/{id}/update', name: 'chill_activity_activityreason_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminController.php b/src/Bundle/ChillActivityBundle/Controller/AdminController.php index deca96bd7..39438eb8d 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminController.php @@ -18,18 +18,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; */ class AdminController extends AbstractController { - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activity", name="chill_activity_admin_index") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activity', name: 'chill_activity_admin_index')] public function indexActivityAction() { return $this->render('@ChillActivity/Admin/layout_activity.html.twig'); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activity_redirect_to_main", name="chill_admin_aside_activity_redirect_to_admin_index", options={null}) - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activity_redirect_to_main", name="chill_admin_activity_redirect_to_admin_index") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activity_redirect_to_main', name: 'chill_admin_aside_activity_redirect_to_admin_index', options: [null])] + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/activity_redirect_to_main', name: 'chill_admin_activity_redirect_to_admin_index')] public function redirectToAdminIndexAction() { return $this->redirectToRoute('chill_main_admin_central'); diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 9407aecbe..ec1ae23e2 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -50,10 +50,6 @@ use Symfony\Component\Validator\Constraints as Assert; * * @ORM\HasLifecycleCallbacks * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "activity": Activity::class - * }) - * * @ActivityValidator\ActivityValidity * * TODO see if necessary @@ -62,6 +58,7 @@ use Symfony\Component\Validator\Constraints as Assert; * getUserFunction="getUser", * path="scope") */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['activity' => Activity::class])] class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, HasCentersInterface, HasScopesInterface, TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -74,50 +71,43 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?AccompanyingPeriod $accompanyingPeriod = null; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") * - * @Groups({"read", "docgen:read"}) - * - * @SerializedName("activityType") - * * @ORM\JoinColumn(name="type_id") */ + #[Groups(['read', 'docgen:read'])] + #[SerializedName('activityType')] private ActivityType $activityType; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?ActivityPresence $attendee = null; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private CommentEmbeddable $comment; /** * @ORM\Column(type="datetime") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private \DateTime $date; /** * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"}) * - * @Assert\Valid(traverse=true) - * * @var Collection */ + #[Assert\Valid(traverse: true)] private Collection $documents; /** @@ -127,9 +117,8 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private bool $emergency = false; /** @@ -138,16 +127,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - * - * @groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?Location $location = null; /** @@ -158,10 +145,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") * - * @Groups({"read", "docgen:read"}) - * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $persons; /** @@ -172,24 +158,21 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") * - * @Groups({"docgen:read"}) - * * @var Collection */ + #[Groups(['docgen:read'])] private Collection $reasons; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?Scope $scope = null; /** * @ORM\Column(type="string", options={"default": ""}) - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private string $sentReceived = ''; /** @@ -197,10 +180,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") * - * @Groups({"read", "docgen:read"}) - * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $socialActions; /** @@ -208,19 +190,17 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") * - * @Groups({"read", "docgen:read"}) - * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $socialIssues; /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * - * @Groups({"read", "docgen:read"}) - * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $thirdParties; /** @@ -230,18 +210,16 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?User $user = null; /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") * - * @Groups({"read", "docgen:read"}) - * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $users; public function __construct() @@ -385,9 +363,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this->documents; } - /** - * @Groups({"docgen:read"}) - */ + #[Groups(['docgen:read'])] public function getDurationMinute(): int { if (null === $this->durationTime) { @@ -515,9 +491,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this->travelTime; } - /** - * @Groups({"docgen:read"}) - */ + #[Groups(['docgen:read'])] public function getTravelTimeMinute(): int { if (null === $this->travelTime) { diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index c181b7c6b..0a558c51b 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -36,18 +36,16 @@ class ActivityPresence * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private array $name = []; /** diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 96c369b39..404cda36c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -50,9 +50,8 @@ class ActivityType /** * @ORM\Column(type="boolean") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private bool $active = true; /** @@ -126,9 +125,8 @@ class ActivityType * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?int $id = null; /** @@ -144,10 +142,9 @@ class ActivityType /** * @ORM\Column(type="json") * - * @Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private array $name = []; /** @@ -167,9 +164,8 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private int $personsVisible = self::FIELD_OPTIONAL; /** @@ -248,9 +244,8 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private int $thirdPartiesVisible = self::FIELD_INVISIBLE; /** @@ -275,9 +270,8 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private int $usersVisible = self::FIELD_OPTIONAL; /** @@ -285,9 +279,7 @@ class ActivityType */ private int $userVisible = self::FIELD_REQUIRED; - /** - * @Assert\Callback - */ + #[Assert\Callback] public function checkSocialActionsVisibility(ExecutionContextInterface $context, mixed $payload) { if ($this->socialIssuesVisible !== $this->socialActionsVisible) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php index cbf0ba9ec..08af67639 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php @@ -19,9 +19,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class AdminController extends AbstractController { - /** - * @Route("/{_locale}/admin/aside-activity", name="chill_aside_activity_admin") - */ + #[Route(path: '/{_locale}/admin/aside-activity', name: 'chill_aside_activity_admin')] public function indexAdminAction() { return $this->render('@ChillAsideActivity/Admin/index.html.twig'); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index f43a0fdfb..02da401bc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -29,9 +29,8 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=false) - * - * @Assert\NotBlank */ + #[Assert\NotBlank] private User $agent; /** diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index be71d73f9..e5eb044d9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -117,9 +117,7 @@ class AsideActivityCategory return null !== $this->parent; } - /** - * @Assert\Callback - */ + #[Assert\Callback] public function preventRecursiveParent(ExecutionContextInterface $context, mixed $payload) { if (!$this->hasParent()) { diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php index 998775fbe..3bb696757 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php @@ -16,9 +16,7 @@ use Symfony\Component\Routing\Annotation\Route; class AdminController extends AbstractController { - /** - * @Route("/{_locale}/admin/budget", name="chill_admin_budget") - */ + #[Route(path: '/{_locale}/admin/budget', name: 'chill_admin_budget')] public function indexAdminAction() { return $this->render('@ChillBudget/Admin/index.html.twig'); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php index 39e96d4a8..480e2c645 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php @@ -21,9 +21,8 @@ class ChargeController extends AbstractElementController { /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/delete", name="chill_budget_charge_delete") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/charge/{id}/delete', name: 'chill_budget_charge_delete')] public function deleteAction(Request $request, Charge $charge) { return $this->_delete( @@ -36,9 +35,8 @@ class ChargeController extends AbstractElementController /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/edit", name="chill_budget_charge_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/charge/{id}/edit', name: 'chill_budget_charge_edit')] public function editAction(Request $request, Charge $charge) { return $this->_edit( @@ -51,9 +49,8 @@ class ChargeController extends AbstractElementController /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/by-person/{id}/new", name="chill_budget_charge_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/charge/by-person/{id}/new', name: 'chill_budget_charge_new')] public function newAction(Request $request, Person $person) { return $this->_new( @@ -66,9 +63,8 @@ class ChargeController extends AbstractElementController /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/by-household/{id}/new", name="chill_budget_charge_household_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/charge/by-household/{id}/new', name: 'chill_budget_charge_household_new')] public function newHouseholdAction(Request $request, Household $household) { return $this->_new( @@ -81,9 +77,8 @@ class ChargeController extends AbstractElementController /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/view", name="chill_budget_charge_view") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/charge/{id}/view', name: 'chill_budget_charge_view')] public function viewAction(Charge $charge) { return $this->_view($charge, '@ChillBudget/Charge/view.html.twig'); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php index 26acbf8a5..48f86dedd 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php @@ -23,9 +23,7 @@ class ElementController extends AbstractController { public function __construct(private readonly CalculatorManager $calculator, private readonly ResourceRepository $resourceRepository, private readonly ChargeRepository $chargeRepository) {} - /** - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/elements/by-person/{id}", name="chill_budget_elements_index") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/elements/by-person/{id}', name: 'chill_budget_elements_index')] public function indexAction(Person $person) { $this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $person); @@ -47,9 +45,7 @@ class ElementController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/elements/by-household/{id}", name="chill_budget_elements_household_index") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/elements/by-household/{id}', name: 'chill_budget_elements_household_index')] public function indexHouseholdAction(Household $household) { $this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $household); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php index f67d92a43..fd9dc9f63 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php @@ -20,9 +20,7 @@ use Symfony\Component\HttpFoundation\Response; class ResourceController extends AbstractElementController { - /** - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/resource/{id}/delete", name="chill_budget_resource_delete") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/resource/{id}/delete', name: 'chill_budget_resource_delete')] public function deleteAction(Request $request, Resource $resource) { return $this->_delete( @@ -33,9 +31,7 @@ class ResourceController extends AbstractElementController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/resource/{id}/edit", name="chill_budget_resource_edit") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/resource/{id}/edit', name: 'chill_budget_resource_edit')] public function editAction(Request $request, Resource $resource): Response { return $this->_edit( @@ -48,9 +44,8 @@ class ResourceController extends AbstractElementController /** * Create a new budget element for a person. - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/resource/by-person/{id}/new", name="chill_budget_resource_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/resource/by-person/{id}/new', name: 'chill_budget_resource_new')] public function newAction(Request $request, Person $person): Response { return $this->_new( @@ -63,9 +58,8 @@ class ResourceController extends AbstractElementController /** * Create new budget element for a household. - * - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/resource/by-household/{id}/new", name="chill_budget_resource_household_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/resource/by-household/{id}/new', name: 'chill_budget_resource_household_new')] public function newHouseholdAction(Request $request, Household $household): Response { return $this->_new( @@ -76,9 +70,7 @@ class ResourceController extends AbstractElementController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/resource/{id}/view", name="chill_budget_resource_view") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/resource/{id}/view', name: 'chill_budget_resource_view')] public function viewAction(Resource $resource): Response { return $this->_view($resource, '@ChillBudget/Resource/view.html.twig'); diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index 85420e670..e57438f0f 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -27,15 +27,9 @@ abstract class AbstractElement { /** * @ORM\Column(name="amount", type="decimal", precision=10, scale=2) - * - * @Assert\GreaterThan( - * value=0 - * ) - * - * @Assert\NotNull( - * message="The amount cannot be empty" - * ) */ + #[Assert\GreaterThan(value: 0)] + #[Assert\NotNull(message: 'The amount cannot be empty')] private string $amount; /** @@ -45,12 +39,8 @@ abstract class AbstractElement /** * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) - * - * @Assert\GreaterThan( - * propertyPath="startDate", - * message="The budget element's end date must be after the start date" - * ) */ + #[Assert\GreaterThan(propertyPath: 'startDate', message: "The budget element's end date must be after the start date")] private ?\DateTimeImmutable $endDate = null; /** @@ -69,9 +59,8 @@ abstract class AbstractElement /** * @ORM\Column(name="startDate", type="datetime_immutable") - * - * @Assert\Date */ + #[Assert\Date] private \DateTimeImmutable $startDate; /** diff --git a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php index 2196a0e99..4150d09cc 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php @@ -23,9 +23,8 @@ use Symfony\Component\Validator\Constraints as Assert; * ) * * @ORM\Entity - * - * @UniqueEntity(fields={"kind"}) */ +#[UniqueEntity(fields: ['kind'])] class ChargeKind { /** @@ -44,11 +43,9 @@ class ChargeKind /** * @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false) - * - * @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric") - * - * @Assert\Length(min=3) */ + #[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')] + #[Assert\Length(min: 3)] private string $kind = ''; /** diff --git a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php index 78e0e6a32..2e0e360d9 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php @@ -22,11 +22,12 @@ use Symfony\Component\Validator\Constraints as Assert; * * @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"}) * }) + * @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"}) + * }) * * @ORM\Entity - * - * @UniqueEntity(fields={"kind"}) */ +#[UniqueEntity(fields: ['kind'])] class ResourceKind { /** @@ -45,11 +46,9 @@ class ResourceKind /** * @ORM\Column(type="string", length=255, nullable=false, options={"default": ""}) - * - * @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric") - * - * @Assert\Length(min=3) */ + #[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')] + #[Assert\Length(min: 3)] private string $kind = ''; /** diff --git a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php index c9bf020b1..f98ca2418 100644 --- a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php +++ b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php @@ -56,7 +56,7 @@ class AzureGrantAdminConsentAndAcquireToken extends Command $messages = ['No problem, we will wait for you', 'Grant access and come back here']; $output->writeln($formatter->formatBlock($messages, 'warning')); - return 0; + return Command::SUCCESS; } $token = $this->machineTokenStorage->getToken(); @@ -69,6 +69,6 @@ class AzureGrantAdminConsentAndAcquireToken extends Command $output->writeln('Expires at: '.$token->getExpires()); $output->writeln('To inspect the token content, go to https://jwt.ms/#access_token='.urlencode($token->getToken())); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 4964f0064..41830cd44 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -32,6 +32,8 @@ use Symfony\Component\Console\Output\OutputInterface; final class MapAndSubscribeUserCalendarCommand extends Command { + protected static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence'; + public function __construct( private readonly EntityManagerInterface $em, private readonly EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, @@ -154,7 +156,7 @@ final class MapAndSubscribeUserCalendarCommand extends Command $output->writeln('users synchronized'); - return 0; + return Command::SUCCESS; } protected function configure() @@ -162,7 +164,6 @@ final class MapAndSubscribeUserCalendarCommand extends Command parent::configure(); $this - ->setDescription('MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence') ->addOption( 'renew-before-end-interval', 'r', diff --git a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php index 6c1b31b9e..7d0426a24 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php @@ -34,6 +34,6 @@ class SendShortMessageOnEligibleCalendar extends Command { $this->messageSender->sendBulkMessageToEligibleCalendars(); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index 225b540df..1b76f25fa 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -39,6 +39,8 @@ use Symfony\Component\Console\Question\Question; class SendTestShortMessageOnCalendarCommand extends Command { + protected static $defaultDescription = 'Test sending a SMS for a dummy calendar appointment'; + public function __construct( private readonly PersonRepository $personRepository, private readonly PhoneNumberUtil $phoneNumberUtil, @@ -50,10 +52,7 @@ class SendTestShortMessageOnCalendarCommand extends Command parent::__construct('chill:calendar:test-send-short-message'); } - protected function configure() - { - $this->setDescription('Test sending a SMS for a dummy calendar appointment'); - } + protected function configure() {} protected function execute(InputInterface $input, OutputInterface $output): int { @@ -174,6 +173,6 @@ class SendTestShortMessageOnCalendarCommand extends Command } } - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillCalendarBundle/Controller/AdminController.php b/src/Bundle/ChillCalendarBundle/Controller/AdminController.php index fceddf45a..0ba21c94f 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/AdminController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/AdminController.php @@ -18,9 +18,8 @@ class AdminController extends AbstractController { /** * Calendar admin. - * - * @Route("/{_locale}/admin/calendar", name="chill_calendar_admin_index") */ + #[Route(path: '/{_locale}/admin/calendar', name: 'chill_calendar_admin_index')] public function indexAdminAction() { return $this->render('@ChillCalendar/Admin/index.html.twig'); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php index 1729c215b..eb5812b4d 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php @@ -25,12 +25,7 @@ class CalendarAPIController extends ApiController { public function __construct(private readonly CalendarRepository $calendarRepository) {} - /** - * @Route("/api/1.0/calendar/calendar/by-user/{id}.{_format}", - * name="chill_api_single_calendar_list_by-user", - * requirements={"_format": "json"} - * ) - */ + #[Route(path: '/api/1.0/calendar/calendar/by-user/{id}.{_format}', name: 'chill_api_single_calendar_list_by-user', requirements: ['_format' => 'json'])] public function listByUser(User $user, Request $request, string $_format): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 0797f2f56..328b8788f 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -64,9 +64,8 @@ class CalendarController extends AbstractController /** * Delete a calendar item. - * - * @Route("/{_locale}/calendar/{id}/delete", name="chill_calendar_calendar_delete") */ + #[Route(path: '/{_locale}/calendar/{id}/delete', name: 'chill_calendar_calendar_delete')] public function deleteAction(Request $request, Calendar $entity) { $em = $this->managerRegistry->getManager(); @@ -114,9 +113,8 @@ class CalendarController extends AbstractController /** * Edit a calendar item. - * - * @Route("/{_locale}/calendar/calendar/{id}/edit", name="chill_calendar_calendar_edit") */ + #[Route(path: '/{_locale}/calendar/calendar/{id}/edit', name: 'chill_calendar_calendar_edit')] public function editAction(Calendar $entity, Request $request): Response { $this->denyAccessUnlessGranted(CalendarVoter::EDIT, $entity); @@ -194,9 +192,8 @@ class CalendarController extends AbstractController /** * Lists all Calendar entities. - * - * @Route("/{_locale}/calendar/calendar/by-period/{id}", name="chill_calendar_calendar_list_by_period") */ + #[Route(path: '/{_locale}/calendar/calendar/by-period/{id}', name: 'chill_calendar_calendar_list_by_period')] public function listActionByCourse(AccompanyingPeriod $accompanyingPeriod): Response { $this->denyAccessUnlessGranted(CalendarVoter::SEE, $accompanyingPeriod); @@ -228,9 +225,8 @@ class CalendarController extends AbstractController /** * Lists all Calendar entities on a person. - * - * @Route("/{_locale}/calendar/calendar/by-person/{id}", name="chill_calendar_calendar_list_by_person") */ + #[Route(path: '/{_locale}/calendar/calendar/by-person/{id}', name: 'chill_calendar_calendar_list_by_person')] public function listActionByPerson(Person $person): Response { $this->denyAccessUnlessGranted(CalendarVoter::SEE, $person); @@ -260,9 +256,7 @@ class CalendarController extends AbstractController ]); } - /** - * @Route("/{_locale}/calendar/calendar/my", name="chill_calendar_calendar_list_my") - */ + #[Route(path: '/{_locale}/calendar/calendar/my', name: 'chill_calendar_calendar_list_my')] public function myCalendar(Request $request): Response { $this->denyAccessUnlessGranted('ROLE_USER'); @@ -284,9 +278,8 @@ class CalendarController extends AbstractController /** * Create a new calendar item. - * - * @Route("/{_locale}/calendar/calendar/new", name="chill_calendar_calendar_new") */ + #[Route(path: '/{_locale}/calendar/calendar/new', name: 'chill_calendar_calendar_new')] public function newAction(Request $request): Response { if (!$this->remoteCalendarConnector->isReady()) { @@ -385,9 +378,8 @@ class CalendarController extends AbstractController /** * Show a calendar item. - * - * @Route("/{_locale}/calendar/calendar/{id}/show", name="chill_calendar_calendar_show") */ + #[Route(path: '/{_locale}/calendar/calendar/{id}/show', name: 'chill_calendar_calendar_show')] public function showAction(Request $request, int $id): Response { throw new \Exception('not implemented'); @@ -455,9 +447,7 @@ class CalendarController extends AbstractController ]); } - /** - * @Route("/{_locale}/calendar/calendar/{id}/to-activity", name="chill_calendar_calendar_to_activity") - */ + #[Route(path: '/{_locale}/calendar/calendar/{id}/to-activity', name: 'chill_calendar_calendar_to_activity')] public function toActivity(Request $request, Calendar $calendar): RedirectResponse { $this->denyAccessUnlessGranted(CalendarVoter::SEE, $calendar); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index d0f5e623d..3afe0915d 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -37,9 +37,7 @@ final readonly class CalendarDocController private UrlGeneratorInterface $urlGenerator, ) {} - /** - * @Route("/{_locale}/calendar/calendar-doc/{id}/new", name="chill_calendar_calendardoc_new") - */ + #[Route(path: '/{_locale}/calendar/calendar-doc/{id}/new', name: 'chill_calendar_calendardoc_new')] public function create(Calendar $calendar, Request $request): Response { $calendarDoc = (new CalendarDoc($calendar, null))->setCalendar($calendar); @@ -96,9 +94,7 @@ final readonly class CalendarDocController ); } - /** - * @Route("/{_locale}/calendar/calendar-doc/{id}/delete", name="chill_calendar_calendardoc_delete") - */ + #[Route(path: '/{_locale}/calendar/calendar-doc/{id}/delete', name: 'chill_calendar_calendardoc_delete')] public function delete(CalendarDoc $calendarDoc, Request $request): Response { if (!$this->security->isGranted(CalendarDocVoter::EDIT, $calendarDoc)) { @@ -156,9 +152,7 @@ final readonly class CalendarDocController ); } - /** - * @Route("/{_locale}/calendar/calendar-doc/{id}/edit", name="chill_calendar_calendardoc_edit") - */ + #[Route(path: '/{_locale}/calendar/calendar-doc/{id}/edit', name: 'chill_calendar_calendardoc_edit')] public function edit(CalendarDoc $calendarDoc, Request $request): Response { if (!$this->security->isGranted(CalendarDocVoter::EDIT, $calendarDoc)) { diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php index 459d8f6aa..3774f4226 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php @@ -25,12 +25,7 @@ class CalendarRangeAPIController extends ApiController { public function __construct(private readonly CalendarRangeRepository $calendarRangeRepository) {} - /** - * @Route("/api/1.0/calendar/calendar-range-available/{id}.{_format}", - * name="chill_api_single_calendar_range_available", - * requirements={"_format": "json"} - * ) - */ + #[Route(path: '/api/1.0/calendar/calendar-range-available/{id}.{_format}', name: 'chill_api_single_calendar_range_available', requirements: ['_format' => 'json'])] public function availableRanges(User $user, Request $request, string $_format): JsonResponse { // return new JsonResponse(['ok' => true], 200, [], false); diff --git a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php index 784a6f6ce..8b0337e14 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php @@ -38,9 +38,8 @@ class InviteApiController /** * Give an answer to a calendar invite. - * - * @Route("/api/1.0/calendar/calendar/{id}/answer/{answer}.json", methods={"post"}) */ + #[Route(path: '/api/1.0/calendar/calendar/{id}/answer/{answer}.json', methods: ['post'])] public function answer(Calendar $calendar, string $answer): Response { $user = $this->security->getUser(); diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php index 75b417e93..8790617ed 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php @@ -32,9 +32,7 @@ class RemoteCalendarConnectAzureController { public function __construct(private readonly ClientRegistry $clientRegistry, private readonly OnBehalfOfUserTokenStorage $MSGraphTokenStorage) {} - /** - * @Route("/{_locale}/connect/azure", name="chill_calendar_remote_connect_azure") - */ + #[Route(path: '/{_locale}/connect/azure', name: 'chill_calendar_remote_connect_azure')] public function connectAzure(Request $request): Response { $request->getSession()->set('azure_return_path', $request->query->get('returnPath', '/')); @@ -44,9 +42,7 @@ class RemoteCalendarConnectAzureController ->redirect(['https://graph.microsoft.com/.default', 'offline_access'], []); } - /** - * @Route("/connect/azure/check", name="chill_calendar_remote_connect_azure_check") - */ + #[Route(path: '/connect/azure/check', name: 'chill_calendar_remote_connect_azure_check')] public function connectAzureCheck(Request $request): Response { /** @var Azure $client */ diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php index e7d423abd..3faefeb00 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php @@ -29,10 +29,7 @@ class RemoteCalendarMSGraphSyncController { public function __construct(private readonly MessageBusInterface $messageBus) {} - /** - * @Route("/public/incoming-hook/calendar/msgraph/events/{userId}", name="chill_calendar_remote_msgraph_incoming_webhook_events", - * methods={"POST"}) - */ + #[Route(path: '/public/incoming-hook/calendar/msgraph/events/{userId}', name: 'chill_calendar_remote_msgraph_incoming_webhook_events', methods: ['POST'])] public function webhookCalendarReceiver(int $userId, Request $request): Response { if ($request->query->has('validationToken')) { diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php index 673912c0a..647c6e444 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php @@ -36,9 +36,7 @@ class RemoteCalendarProxyController { public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly SerializerInterface $serializer) {} - /** - * @Route("api/1.0/calendar/proxy/calendar/by-user/{id}/events") - */ + #[Route(path: 'api/1.0/calendar/proxy/calendar/by-user/{id}/events')] public function listEventForCalendar(User $user, Request $request): Response { if (!$request->query->has('dateFrom')) { diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 32308a50c..38a7e29f0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -43,11 +43,8 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; * ) * * @ORM\Entity - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "chill_calendar_calendar": Calendar::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_calendar_calendar' => Calendar::class])] class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCentersInterface { use RemoteCalendarTrait; @@ -91,9 +88,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars") - * - * @Serializer\Groups({"calendar:read", "read"}) */ + #[Serializer\Groups(['calendar:read', 'read'])] private ?AccompanyingPeriod $accompanyingPeriod = null; /** @@ -103,9 +99,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar") - * - * @Serializer\Groups({"calendar:read", "read"}) */ + #[Serializer\Groups(['calendar:read', 'read'])] private ?CalendarRange $calendarRange = null; /** @@ -115,9 +110,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_") - * - * @Serializer\Groups({"calendar:read", "read", "docgen:read"}) */ + #[Serializer\Groups(['calendar:read', 'read', 'docgen:read'])] private CommentEmbeddable $comment; /** @@ -134,11 +128,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\Column(type="datetime_immutable", nullable=false) - * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) - * - * @Assert\NotNull(message="calendar.An end date is required") */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[Assert\NotNull(message: 'calendar.An end date is required')] private ?\DateTimeImmutable $endDate = null; /** @@ -147,9 +139,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] private ?int $id = null; /** @@ -162,30 +153,25 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * * @ORM\JoinTable(name="chill_calendar.calendar_to_invites") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @var Collection&Selectable */ + #[Serializer\Groups(['read', 'docgen:read'])] private Collection&Selectable $invites; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - * - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Assert\NotNull(message="calendar.A location is required") */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[Assert\NotNull(message: 'calendar.A location is required')] private ?Location $location = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) - * - * @Assert\NotNull(message="calendar.A main user is mandatory") */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[Assert\NotNull(message: 'calendar.A main user is mandatory')] private ?User $mainUser = null; /** @@ -200,21 +186,18 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * - * @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.") - * * @var Collection */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')] private Collection $persons; /** * @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_") - * - * @Serializer\Groups({"calendar:read"}) */ + #[Serializer\Groups(['calendar:read'])] private PrivateCommentEmbeddable $privateComment; /** @@ -224,17 +207,15 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] private Collection $professionals; /** * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?bool $sendSMS = false; /** @@ -245,28 +226,24 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\Column(type="datetime_immutable", nullable=false) * - * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) - * - * @Assert\NotNull(message="calendar.A start date is required") */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[Assert\NotNull(message: 'calendar.A start date is required')] private ?\DateTimeImmutable $startDate = null; /** * @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"}) * - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light'])] private string $status = self::STATUS_VALID; /** * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?bool $urgent = false; public function __construct() @@ -394,9 +371,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente return $this->documents; } - /** - * @Serializer\Groups({"docgen:read"}) - */ + #[Serializer\Groups(['docgen:read'])] public function getDuration(): ?\DateInterval { if (null === $this->getStartDate() || null === $this->getEndDate()) { @@ -541,9 +516,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @return ReadableCollection<(int|string), User> - * - * @Serializer\Groups({"calendar:read", "read"}) */ + #[Serializer\Groups(['calendar:read', 'read'])] public function getUsers(): ReadableCollection { return $this->getInvites()->map(static fn (Invite $i) => $i->getUser()); diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php index ff4e10402..16c0e9105 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php @@ -16,17 +16,11 @@ use Symfony\Component\Validator\Constraints as Assert; class CalendarDocCreateDTO { - /** - * @Assert\NotNull - * - * @Assert\Valid - */ + #[Assert\NotNull] + #[Assert\Valid] public ?StoredObject $doc = null; - /** - * @Assert\NotBlank - * - * @Assert\NotNull - */ + #[Assert\NotBlank] + #[Assert\NotNull] public ?string $title = ''; } diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php index 2e8970db6..38276b0f3 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php @@ -17,16 +17,11 @@ use Symfony\Component\Validator\Constraints as Assert; class CalendarDocEditDTO { - /** - * @Assert\Valid - */ + #[Assert\Valid] public ?StoredObject $doc = null; - /** - * @Assert\NotBlank - * - * @Assert\NotNull - */ + #[Assert\NotBlank] + #[Assert\NotNull] public ?string $title = ''; public function __construct(CalendarDoc $calendarDoc) diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 0c46db57c..3e2cf1eb0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -44,11 +44,9 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) - * - * @Groups({"read", "write", "calendar:read"}) - * - * @Assert\NotNull */ + #[Groups(['read', 'write', 'calendar:read'])] + #[Assert\NotNull] private ?\DateTimeImmutable $endDate = null; /** @@ -57,38 +55,31 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=Location::class) * * @ORM\JoinColumn(nullable=false) - * - * @Groups({"read", "write", "calendar:read"}) - * - * @Assert\NotNull */ + #[Groups(['read', 'write', 'calendar:read'])] + #[Assert\NotNull] private ?Location $location = null; /** * @ORM\Column(type="datetime_immutable", nullable=false) - * - * @groups({"read", "write", "calendar:read"}) - * - * @Assert\NotNull */ + #[Groups(['read', 'write', 'calendar:read'])] + #[Assert\NotNull] private ?\DateTimeImmutable $startDate = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - * - * @Groups({"read", "write", "calendar:read"}) - * - * @Assert\NotNull */ + #[Groups(['read', 'write', 'calendar:read'])] + #[Assert\NotNull] private ?User $user = null; public function getCalendar(): ?Calendar diff --git a/src/Bundle/ChillCalendarBundle/Entity/Invite.php b/src/Bundle/ChillCalendarBundle/Entity/Invite.php index 48fe865b0..40024c52d 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Invite.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Invite.php @@ -69,25 +69,22 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups(groups={"calendar:read", "read"}) */ + #[Serializer\Groups(groups: ['calendar:read', 'read'])] private ?int $id = null; /** * @ORM\Column(type="text", nullable=false, options={"default": "pending"}) - * - * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ + #[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])] private string $status = self::PENDING; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * * @ORM\JoinColumn(nullable=false) - * - * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ + #[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])] private ?User $user = null; public function getCalendar(): ?Calendar diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php index 40d1d1435..8da4e74d7 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php @@ -23,26 +23,16 @@ use Symfony\Component\Serializer\Annotation as Serializer; class RemoteEvent { public function __construct( - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $id, - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $title, public string $description, - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public \DateTimeImmutable $startDate, - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public \DateTimeImmutable $endDate, - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public bool $isAllDay = false ) {} } diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index de3f0cf5b..24c531860 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -31,6 +31,7 @@ use Symfony\Component\Yaml\Parser; */ class CreateFieldsOnGroupCommand extends Command { + protected static $defaultDescription = 'Create custom fields from a yml file'; final public const ARG_DELETE = 'delete'; final public const ARG_PATH = 'path'; @@ -51,7 +52,6 @@ class CreateFieldsOnGroupCommand extends Command protected function configure() { $this->setName('chill:custom_fields:populate_group') - ->setDescription('Create custom fields from a yml file') ->addArgument( self::ARG_PATH, InputOption::VALUE_REQUIRED, @@ -130,7 +130,7 @@ class CreateFieldsOnGroupCommand extends Command $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); - return 0; + return Command::SUCCESS; } private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output) diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/AdminController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/AdminController.php index eda55bb87..525df57ee 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/AdminController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/AdminController.php @@ -21,9 +21,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class AdminController extends AbstractController { - /** - * @Route("/{_locale}/admin/customfield/", name="customfield_section") - */ + #[Route(path: '/{_locale}/admin/customfield/', name: 'customfield_section')] public function indexAction(): Response { return $this->render('@ChillCustomFields/Admin/layout.html.twig'); diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php index 85b5d9261..39d9821a9 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php @@ -33,9 +33,8 @@ class CustomFieldController extends AbstractController /** * Creates a new CustomField entity. - * - * @Route("/{_locale}/admin/customfield/new", name="customfield_create") */ + #[Route(path: '/{_locale}/admin/customfield/new', name: 'customfield_create')] public function createAction(Request $request) { $entity = new CustomField(); @@ -64,9 +63,8 @@ class CustomFieldController extends AbstractController /** * Displays a form to edit an existing CustomField entity. - * - * @Route("/{_locale}/admin/customfield/edit", name="customfield_edit") */ + #[Route(path: '/{_locale}/admin/customfield/edit', name: 'customfield_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -87,9 +85,8 @@ class CustomFieldController extends AbstractController /** * Displays a form to create a new CustomField entity. - * - * @Route("/{_locale}/admin/customfield/new", name="customfield_new") */ + #[Route(path: '/{_locale}/admin/customfield/new', name: 'customfield_new')] public function newAction(Request $request) { $entity = new CustomField(); @@ -118,9 +115,8 @@ class CustomFieldController extends AbstractController /** * Edits an existing CustomField entity. - * - * @Route("/{_locale}/admin/customfield/update", name="customfield_update") */ + #[Route(path: '/{_locale}/admin/customfield/update', name: 'customfield_update')] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php index 92a13eb0f..5d16269e6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php @@ -44,9 +44,8 @@ class CustomFieldsGroupController extends AbstractController /** * Creates a new CustomFieldsGroup entity. - * - * @Route("/{_locale}/admin/customfieldsgroup/create", name="customfieldsgroup_create") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/create', name: 'customfieldsgroup_create')] public function createAction(Request $request) { $entity = new CustomFieldsGroup(); @@ -75,9 +74,8 @@ class CustomFieldsGroupController extends AbstractController /** * Displays a form to edit an existing CustomFieldsGroup entity. - * - * @Route("/{_locale}/admin/customfieldsgroup/{id}/edit", name="customfieldsgroup_edit") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/{id}/edit', name: 'customfieldsgroup_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -98,9 +96,8 @@ class CustomFieldsGroupController extends AbstractController /** * Lists all CustomFieldsGroup entities. - * - * @Route("/{_locale}/admin/customfieldsgroup/", name="customfieldsgroup") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/', name: 'customfieldsgroup')] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -125,9 +122,8 @@ class CustomFieldsGroupController extends AbstractController /** * Set the CustomField Group with id $cFGroupId as default. - * - * @Route("/{_locale}/admin/customfieldsgroup/makedefault", name="customfieldsgroup_makedefault") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/makedefault', name: 'customfieldsgroup_makedefault')] public function makeDefaultAction(Request $request) { $form = $this->createMakeDefaultForm(null); @@ -170,9 +166,8 @@ class CustomFieldsGroupController extends AbstractController /** * Displays a form to create a new CustomFieldsGroup entity. - * - * @Route("/{_locale}/admin/customfieldsgroup/new", name="customfieldsgroup_new") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/new', name: 'customfieldsgroup_new')] public function newAction() { $entity = new CustomFieldsGroup(); @@ -235,9 +230,8 @@ class CustomFieldsGroupController extends AbstractController /** * Finds and displays a CustomFieldsGroup entity. - * - * @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup_show") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/{id}/show', name: 'customfieldsgroup_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -259,9 +253,8 @@ class CustomFieldsGroupController extends AbstractController /** * Edits an existing CustomFieldsGroup entity. - * - * @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup_update") */ + #[Route(path: '/{_locale}/admin/customfieldsgroup/{id}/update', name: 'customfieldsgroup_update')] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php index ecb896080..04fa9ce07 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php @@ -58,9 +58,7 @@ class AdminDocGeneratorTemplateController extends CRUDController return parent::new($request); } - /** - * @Route("{_locale}/admin/docgen/template/pick-context", name="chill_docgen_admin_template_pick-context") - */ + #[Route(path: '{_locale}/admin/docgen/template/pick-context', name: 'chill_docgen_admin_template_pick-context')] public function pickContext(Request $request): Response { $this->denyAccessUnlessGranted('ROLE_ADMIN'); diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 08470778a..dfb70d1c8 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -51,12 +51,7 @@ final class DocGeneratorTemplateController extends AbstractController private readonly ChillSecurity $security ) {} - /** - * @Route( - * "{_locale}/admin/doc/gen/generate/test/from/{template}/for/{entityClassName}/{entityId}", - * name="chill_docgenerator_test_generate_from_template" - * ) - */ + #[Route(path: '{_locale}/admin/doc/gen/generate/test/from/{template}/for/{entityClassName}/{entityId}', name: 'chill_docgenerator_test_generate_from_template')] public function adminTestGenerateDocFromTemplateAction( DocGeneratorTemplate $template, string $entityClassName, @@ -71,12 +66,7 @@ final class DocGeneratorTemplateController extends AbstractController ); } - /** - * @Route( - * "{_locale}/doc/gen/generate/from/{template}/for/{entityClassName}/{entityId}", - * name="chill_docgenerator_generate_from_template" - * ) - */ + #[Route(path: '{_locale}/doc/gen/generate/from/{template}/for/{entityClassName}/{entityId}', name: 'chill_docgenerator_generate_from_template')] public function generateDocFromTemplateAction( DocGeneratorTemplate $template, string $entityClassName, @@ -91,12 +81,7 @@ final class DocGeneratorTemplateController extends AbstractController ); } - /** - * @Route( - * "/api/1.0/docgen/templates/by-entity/{entityClassName}", - * name="chill_docgenerator_templates_for_entity_api" - * ) - */ + #[Route(path: '/api/1.0/docgen/templates/by-entity/{entityClassName}', name: 'chill_docgenerator_templates_for_entity_api')] public function listTemplateApiAction(string $entityClassName): Response { $nb = $this->docGeneratorTemplateRepository->countByEntity($entityClassName); @@ -116,13 +101,9 @@ final class DocGeneratorTemplateController extends AbstractController } /** - * @Route( - * "{_locale}/admin/doc/gen/generate/test/redirect", - * name="chill_docgenerator_test_generate_redirect" - * ) - * * @return void */ + #[Route(path: '{_locale}/admin/doc/gen/generate/test/redirect', name: 'chill_docgenerator_test_generate_redirect')] public function redirectToTestGenerate(Request $request): RedirectResponse { $template = $request->query->getInt('template'); diff --git a/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php b/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php index e2524e5ba..857b0f5b5 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php +++ b/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php @@ -19,11 +19,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_docgen_template") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "docgen_template": DocGeneratorTemplate::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['docgen_template' => DocGeneratorTemplate::class])] class DocGeneratorTemplate { /** @@ -43,9 +40,8 @@ class DocGeneratorTemplate /** * @ORM\Column(type="text", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?string $description = null; /** @@ -66,16 +62,14 @@ class DocGeneratorTemplate * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?int $id = null; /** * @ORM\Column(type="json") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private array $name = []; /** diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php index 542e44973..ad438ba2b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php @@ -238,10 +238,9 @@ final class DocGenObjectNormalizerTest extends KernelTestCase class TestableParentClass { /** - * @Serializer\Groups("docgen:read") - * * @Serializer\Context(normalizationContext={"groups": "docgen:read:foo"}, groups={"docgen:read"}) */ + #[Serializer\Groups('docgen:read')] public ?TestableChildClass $child; public function __construct() @@ -252,27 +251,19 @@ class TestableParentClass class TestableChildClass { - /** - * @Serializer\Groups("docgen:read") - */ + #[Serializer\Groups('docgen:read')] public string $baz = 'bloup'; - /** - * @Serializer\Groups("docgen:read:foo") - */ + #[Serializer\Groups('docgen:read:foo')] public string $foo = 'bar'; } class TestableClassWithBool { - /** - * @Serializer\Groups("docgen:read") - */ + #[Serializer\Groups('docgen:read')] public bool $foo; - /** - * @Serializer\Groups("docgen:read") - */ + #[Serializer\Groups('docgen:read')] public function getThing(): bool { return true; @@ -281,9 +272,7 @@ class TestableClassWithBool class TestableWithIntersectionReadableCollection { - /** - * @Serializer\Groups("docgen:read") - */ + #[Serializer\Groups('docgen:read')] public ReadableCollection&Selectable $collection; public function __construct() @@ -294,9 +283,7 @@ class TestableWithIntersectionReadableCollection class TestableWithCollection { - /** - * @Serializer\Groups("docgen:read") - */ + #[Serializer\Groups('docgen:read')] public Collection&Selectable $collection; public function __construct() diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php index de6690faf..fd1b41481 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Command/ConfigureOpenstackObjectStorageCommand.php @@ -21,6 +21,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; class ConfigureOpenstackObjectStorageCommand extends Command { + protected static $defaultDescription = 'Configure openstack container to store documents'; private readonly string $basePath; private readonly string $tempUrlKey; @@ -37,7 +38,7 @@ class ConfigureOpenstackObjectStorageCommand extends Command protected function configure() { - $this->setDescription('Configure openstack container to store documents') + $this ->setName('chill:doc-store:configure-openstack') ->addOption('os_token', 'o', InputOption::VALUE_REQUIRED, 'Openstack token') ->addOption('domain', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Domain name') @@ -85,6 +86,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command } } - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php index 9003a69ea..aba289652 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrl.php @@ -16,21 +16,14 @@ use Symfony\Component\Serializer\Annotation as Serializer; readonly class SignedUrl { public function __construct( - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $method, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $url, public \DateTimeImmutable $expires, ) {} - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public function getExpires(): int { return $this->expires->getTimestamp(); diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php index 4a5b4e0fb..9d37771d1 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/SignedUrlPost.php @@ -18,35 +18,17 @@ readonly class SignedUrlPost extends SignedUrl public function __construct( string $url, \DateTimeImmutable $expires, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public int $max_file_size, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public int $max_file_count, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public int $submit_delay, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $redirect, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $prefix, - - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public string $signature, ) { parent::__construct('POST', $url, $expires); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/AdminController.php b/src/Bundle/ChillDocStoreBundle/Controller/AdminController.php index 31c80158e..1ad892891 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/AdminController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/AdminController.php @@ -20,9 +20,8 @@ class AdminController extends AbstractController { /** * @return \Symfony\Component\HttpFoundation\Response - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document", name="chill_docstore_admin", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/document', name: 'chill_docstore_admin', options: [null])] public function indexAction() { return $this->render('@ChillDocStore/Admin/layout.html.twig'); @@ -30,9 +29,8 @@ class AdminController extends AbstractController /** * @return \Symfony\Component\HttpFoundation\RedirectResponse - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/document_redirect_to_main", name="chill_docstore_admin_redirect_to_admin_index", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/document_redirect_to_main', name: 'chill_docstore_admin_redirect_to_admin_index', options: [null])] public function redirectToAdminIndexAction() { return $this->redirectToRoute('chill_main_admin_central'); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php b/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php index decfde596..75be20d34 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/AsyncUploadController.php @@ -33,10 +33,7 @@ final readonly class AsyncUploadController private LoggerInterface $logger, ) {} - /** - * @Route("/asyncupload/temp_url/generate/{method}", - * name="async_upload.generate_url") - */ + #[Route(path: '/asyncupload/temp_url/generate/{method}', name: 'async_upload.generate_url')] public function getSignedUrl(string $method, Request $request): JsonResponse { try { diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index c7f6e1920..a281fc663 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -25,9 +25,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\Translation\TranslatorInterface; -/** - * @Route("/{_locale}/parcours/{course}/document") - */ +#[Route(path: '/{_locale}/parcours/{course}/document')] class DocumentAccompanyingCourseController extends AbstractController { /** @@ -40,9 +38,7 @@ class DocumentAccompanyingCourseController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @Route("/{id}/delete", name="chill_docstore_accompanying_course_document_delete") - */ + #[Route(path: '/{id}/delete', name: 'chill_docstore_accompanying_course_document_delete')] public function delete(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response { $this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::DELETE, $document); @@ -75,9 +71,7 @@ class DocumentAccompanyingCourseController extends AbstractController ); } - /** - * @Route("/{id}/edit", name="accompanying_course_document_edit", methods="GET|POST") - */ + #[Route(path: '/{id}/edit', name: 'accompanying_course_document_edit', methods: 'GET|POST')] public function edit(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response { $this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::UPDATE, $document); @@ -116,9 +110,7 @@ class DocumentAccompanyingCourseController extends AbstractController ); } - /** - * @Route("/new", name="accompanying_course_document_new", methods="GET|POST") - */ + #[Route(path: '/new', name: 'accompanying_course_document_new', methods: 'GET|POST')] public function new(Request $request, AccompanyingPeriod $course): Response { if (null === $course) { @@ -162,9 +154,7 @@ class DocumentAccompanyingCourseController extends AbstractController ]); } - /** - * @Route("/{id}", name="accompanying_course_document_show", methods="GET") - */ + #[Route(path: '/{id}', name: 'accompanying_course_document_show', methods: 'GET')] public function show(AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response { $this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::SEE_DETAILS, $document); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php index 7803f24e4..e67ac9751 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php @@ -20,16 +20,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route("/{_locale}/admin/document/category") - */ +#[Route(path: '/{_locale}/admin/document/category')] class DocumentCategoryController extends AbstractController { public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE") - */ + #[Route(path: '/{bundleId}/{idInsideBundle}', name: 'document_category_delete', methods: 'DELETE')] public function delete(Request $request, mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->managerRegistry->getManager(); @@ -47,9 +43,7 @@ class DocumentCategoryController extends AbstractController return $this->redirectToRoute('document_category_index'); } - /** - * @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST") - */ + #[Route(path: '/{bundleId}/{idInsideBundle}/edit', name: 'document_category_edit', methods: 'GET|POST')] public function edit(Request $request, mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->managerRegistry->getManager(); @@ -76,9 +70,8 @@ class DocumentCategoryController extends AbstractController ]); } - /** - * @Route("/", name="document_category_index", methods="GET") - * @Route("/", name="chill_docstore_category_admin", methods="GET") */ + #[Route(path: '/', name: 'document_category_index', methods: 'GET')] + #[Route(path: '/', name: 'chill_docstore_category_admin', methods: 'GET')] public function index(): Response { $em = $this->managerRegistry->getManager(); @@ -92,9 +85,7 @@ class DocumentCategoryController extends AbstractController ); } - /** - * @Route("/new", name="document_category_new", methods="GET|POST") - */ + #[Route(path: '/new', name: 'document_category_new', methods: 'GET|POST')] public function new(Request $request): Response { $em = $this->managerRegistry->getManager(); @@ -130,9 +121,7 @@ class DocumentCategoryController extends AbstractController ]); } - /** - * @Route("/{bundleId}/{idInsideBundle}", name="document_category_show", methods="GET") - */ + #[Route(path: '/{bundleId}/{idInsideBundle}', name: 'document_category_show', methods: 'GET')] public function show(mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 3c93acf5c..ad58b6e0c 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -29,11 +29,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * Class DocumentPersonController. - * - * @Route("/{_locale}/person/{person}/document") - * - * TODO faire un controller abstrait ? */ +#[Route(path: '/{_locale}/person/{person}/document')] // TODO faire un controller abstrait ? class DocumentPersonController extends AbstractController { /** @@ -46,9 +43,7 @@ class DocumentPersonController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @Route("/{id}/delete", name="chill_docstore_person_document_delete") - */ + #[Route(path: '/{id}/delete', name: 'chill_docstore_person_document_delete')] public function delete(Request $request, Person $person, PersonDocument $document): Response { $this->denyAccessUnlessGranted(PersonDocumentVoter::DELETE, $document); @@ -81,9 +76,7 @@ class DocumentPersonController extends AbstractController ); } - /** - * @Route("/{id}/edit", name="person_document_edit", methods="GET|POST") - */ + #[Route(path: '/{id}/edit', name: 'person_document_edit', methods: 'GET|POST')] public function edit(Request $request, Person $person, PersonDocument $document): Response { $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); @@ -140,9 +133,7 @@ class DocumentPersonController extends AbstractController ); } - /** - * @Route("/new", name="person_document_new", methods="GET|POST") - */ + #[Route(path: '/new', name: 'person_document_new', methods: 'GET|POST')] public function new(Request $request, Person $person): Response { if (null === $person) { @@ -188,9 +179,7 @@ class DocumentPersonController extends AbstractController ]); } - /** - * @Route("/{id}", name="person_document_show", methods="GET") - */ + #[Route(path: '/{id}', name: 'person_document_show', methods: 'GET')] public function show(Person $person, PersonDocument $document): Response { $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php index e615c3b00..f68158552 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php @@ -33,9 +33,8 @@ final readonly class GenericDocForAccompanyingPeriodController /** * @throws \Doctrine\DBAL\Exception - * - * @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index") */ + #[Route(path: '/{_locale}/doc-store/generic-doc/by-period/{id}/index', name: 'chill_docstore_generic-doc_by-period_index')] public function list(AccompanyingPeriod $accompanyingPeriod): Response { if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) { diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php index f6fecae04..c47b2c02a 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php @@ -33,9 +33,8 @@ final readonly class GenericDocForPerson /** * @throws \Doctrine\DBAL\Exception - * - * @Route("/{_locale}/doc-store/generic-doc/by-person/{id}/index", name="chill_docstore_generic-doc_by-person_index") */ + #[Route(path: '/{_locale}/doc-store/generic-doc/by-person/{id}/index', name: 'chill_docstore_generic-doc_by-person_index')] public function list(Person $person): Response { if (!$this->security->isGranted(PersonDocumentVoter::SEE, $person)) { diff --git a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php index 5a4b90474..38856b779 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php @@ -22,9 +22,7 @@ class StoredObjectApiController { public function __construct(private readonly Security $security) {} - /** - * @Route("/api/1.0/doc-store/stored-object/{uuid}/is-ready") - */ + #[Route(path: '/api/1.0/doc-store/stored-object/{uuid}/is-ready')] public function isDocumentReady(StoredObject $storedObject): Response { if (!$this->security->isGranted('ROLE_USER')) { diff --git a/src/Bundle/ChillDocStoreBundle/Entity/Document.php b/src/Bundle/ChillDocStoreBundle/Entity/Document.php index a56b6b800..2ffe06122 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/Document.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/Document.php @@ -54,13 +54,9 @@ class Document implements TrackCreationInterface, TrackUpdateInterface * targetEntity="Chill\DocStoreBundle\Entity\StoredObject", * cascade={"persist"} * ) - * - * @Assert\Valid - * - * @Assert\NotNull( - * message="Upload a document" - * ) */ + #[Assert\Valid] + #[Assert\NotNull(message: 'Upload a document')] private ?StoredObject $object = null; /** @@ -70,11 +66,8 @@ class Document implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text") - * - * @Assert\Length( - * min=2, max=250 - * ) */ + #[Assert\Length(min: 2, max: 250)] private string $title = ''; /** diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 52fc35951..8d3046ac7 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -46,16 +46,14 @@ class StoredObject implements Document, TrackCreationInterface /** * @ORM\Column(type="json", name="datas") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private array $datas = []; /** * @ORM\Column(type="text") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private string $filename = ''; /** @@ -64,46 +62,40 @@ class StoredObject implements Document, TrackCreationInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private ?int $id = null; /** * @var int[] * * @ORM\Column(type="json", name="iv") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private array $iv = []; /** * @ORM\Column(type="json", name="key") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private array $keyInfos = []; /** * @ORM\Column(type="text", name="title") - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private string $title = ''; /** * @ORM\Column(type="text", name="type", options={"default": ""}) - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private string $type = ''; /** * @ORM\Column(type="uuid", unique=true) - * - * @Serializer\Groups({"read", "write"}) */ + #[Serializer\Groups(['read', 'write'])] private UuidInterface $uuid; /** @@ -135,10 +127,9 @@ class StoredObject implements Document, TrackCreationInterface * @param StoredObject::STATUS_* $status */ public function __construct(/** - * @ORM\Column(type="text", options={"default": "ready"}) - * - * @Serializer\Groups({"read"}) - */ + * @ORM\Column(type="text", options={"default": "ready"}) + */ + #[Serializer\Groups(['read'])] private string $status = 'ready' ) { $this->uuid = Uuid::uuid4(); @@ -152,10 +143,9 @@ class StoredObject implements Document, TrackCreationInterface } /** - * @Serializer\Groups({"read", "write"}) - * * @deprecated */ + #[Serializer\Groups(['read', 'write'])] public function getCreationDate(): \DateTime { if (null === $this->createdAt) { @@ -233,10 +223,9 @@ class StoredObject implements Document, TrackCreationInterface } /** - * @Serializer\Groups({"write"}) - * * @deprecated */ + #[Serializer\Groups(['write'])] public function setCreationDate(\DateTime $creationDate): self { $this->createdAt = \DateTimeImmutable::createFromMutable($creationDate); diff --git a/src/Bundle/ChillEventBundle/Controller/AdminController.php b/src/Bundle/ChillEventBundle/Controller/AdminController.php index 3434df9e5..5e8bd3023 100644 --- a/src/Bundle/ChillEventBundle/Controller/AdminController.php +++ b/src/Bundle/ChillEventBundle/Controller/AdminController.php @@ -22,9 +22,8 @@ class AdminController extends AbstractController { /** * Event admin. - * - * @Route("/{_locale}/admin/event", name="chill_event_admin_index") */ + #[Route(path: '/{_locale}/admin/event', name: 'chill_event_admin_index')] public function indexAdminAction() { return $this->render('@ChillEvent/Admin/index.html.twig'); diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php index c652ddecf..72bc8964e 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventController.php @@ -60,9 +60,7 @@ final class EventController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/delete", name="chill_event__event_delete", requirements={"event_id"="\d+"}, methods={"GET", "DELETE"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/delete', name: 'chill_event__event_delete', requirements: ['event_id' => '\d+'], methods: ['GET', 'DELETE'])] public function deleteAction($event_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $em = $this->managerRegistry->getManager(); @@ -113,9 +111,11 @@ final class EventController extends AbstractController * Displays a form to edit an existing Event entity. * * @return \Symfony\Component\HttpFoundation\Response + * @return \Symfony\Component\HttpFoundation\Response * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/edit", name="chill_event__event_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/edit', name: 'chill_event__event_edit')] public function editAction($event_id) { $em = $this->managerRegistry->getManager(); @@ -140,9 +140,11 @@ final class EventController extends AbstractController * @return \Symfony\Component\HttpFoundation\Response * * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Doctrine\ORM\NonUniqueResultException * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{person_id}/list", name="chill_event__list_by_person", methods={"GET"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{person_id}/list', name: 'chill_event__list_by_person', methods: ['GET'])] public function listByPersonAction($person_id) { $em = $this->managerRegistry->getManager(); @@ -188,9 +190,7 @@ final class EventController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/most_recent", name="chill_event_list_most_recent", options={null}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/most_recent', name: 'chill_event_list_most_recent', options: [null])] public function mostRecentIndexAction() { return $this->redirectToRoute('chill_main_search', [ @@ -202,9 +202,11 @@ final class EventController extends AbstractController * Displays a form to create a new Event entity. * * @return \Symfony\Component\HttpFoundation\Response + * @return \Symfony\Component\HttpFoundation\Response * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new", name="chill_event__event_new", methods={"GET", "POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new', name: 'chill_event__event_new', methods: ['GET', 'POST'])] public function newAction(?Center $center, Request $request) { $user = $this->security->getUser(); @@ -244,9 +246,8 @@ final class EventController extends AbstractController /** * First step of new Event form. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new/pick-center", name="chill_event__event_new_pickcenter", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/new/pick-center', name: 'chill_event__event_new_pickcenter', options: [null])] public function newPickCenterAction() { $role = 'CHILL_EVENT_CREATE'; @@ -294,9 +295,11 @@ final class EventController extends AbstractController * @return \Symfony\Component\HttpFoundation\Response * * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws \PhpOffice\PhpSpreadsheet\Exception * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/show", name="chill_event__event_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/show', name: 'chill_event__event_show')] public function showAction(Event $event, Request $request) { if (!$event) { @@ -326,9 +329,8 @@ final class EventController extends AbstractController /** * Edits an existing Event entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/update", name="chill_event__event_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/event/{event_id}/update', name: 'chill_event__event_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, $event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillEventBundle/Controller/EventListController.php b/src/Bundle/ChillEventBundle/Controller/EventListController.php index 60df81240..692611adc 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventListController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventListController.php @@ -42,9 +42,7 @@ final readonly class EventListController private UrlGeneratorInterface $urlGenerator, ) {} - /** - * @Route("{_locale}/event/event/list", name="chill_event_event_list") - */ + #[Route(path: '{_locale}/event/event/list', name: 'chill_event_event_list')] public function __invoke(): Response { $filter = $this->buildFilterOrder(); diff --git a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php index 11cddbf77..881f7a135 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php @@ -26,9 +26,8 @@ class EventTypeController extends AbstractController /** * Creates a new EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/create", name="chill_eventtype_admin_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/create', name: 'chill_eventtype_admin_create', methods: ['POST'])] public function createAction(Request $request) { $entity = new EventType(); @@ -51,9 +50,8 @@ class EventTypeController extends AbstractController /** * Deletes a EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/delete", name="chill_eventtype_admin_delete", methods={"POST", "DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/{id}/delete', name: 'chill_eventtype_admin_delete', methods: ['POST', 'DELETE'])] public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); @@ -76,9 +74,8 @@ class EventTypeController extends AbstractController /** * Displays a form to edit an existing EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/edit", name="chill_eventtype_admin_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/{id}/edit', name: 'chill_eventtype_admin_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -101,9 +98,8 @@ class EventTypeController extends AbstractController /** * Lists all EventType entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/", name="chill_eventtype_admin", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/', name: 'chill_eventtype_admin', options: [null])] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -117,9 +113,8 @@ class EventTypeController extends AbstractController /** * Displays a form to create a new EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/new", name="chill_eventtype_admin_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/new', name: 'chill_eventtype_admin_new')] public function newAction() { $entity = new EventType(); @@ -133,9 +128,8 @@ class EventTypeController extends AbstractController /** * Finds and displays a EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/show", name="chill_eventtype_admin_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/{id}/show', name: 'chill_eventtype_admin_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -156,9 +150,8 @@ class EventTypeController extends AbstractController /** * Edits an existing EventType entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/update", name="chill_eventtype_admin_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/event_type/{id}/update', name: 'chill_eventtype_admin_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 5d911adf2..7b03f7685 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -44,9 +44,7 @@ final class ParticipationController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/create", name="chill_event_participation_create") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/create', name: 'chill_event_participation_create')] public function createAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse { // test the request is correct @@ -243,9 +241,8 @@ final class ParticipationController extends AbstractController /** * @param int $participation_id - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/delete", name="chill_event_participation_delete", requirements={"participation_id"="\d+"}, methods={"GET", "DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{participation_id}/delete', name: 'chill_event_participation_delete', requirements: ['participation_id' => '\d+'], methods: ['GET', 'DELETE'])] public function deleteAction($participation_id, Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse { $em = $this->managerRegistry->getManager(); @@ -292,9 +289,11 @@ final class ParticipationController extends AbstractController * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found * @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation + * @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/edit", name="chill_event_participation_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{participation_id}/edit', name: 'chill_event_participation_edit')] public function editAction(int $participation_id): Response { /** @var Participation $participation */ @@ -324,9 +323,11 @@ final class ParticipationController extends AbstractController * show a form to edit multiple participation for the same event. * * @param int $event_id + * @param int $event_id * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{event_id}/edit_multiple", name="chill_event_participation_edit_multiple") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{event_id}/edit_multiple', name: 'chill_event_participation_edit_multiple')] public function editMultipleAction($event_id): Response|\Symfony\Component\HttpFoundation\RedirectResponse { $event = $this->managerRegistry->getRepository(Event::class) @@ -381,9 +382,8 @@ final class ParticipationController extends AbstractController * This function parse the person_id / persons_ids query argument * and decide if it should process a single or multiple participation. Depending * on this, the appropriate layout and form. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/new", name="chill_event_participation_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/new', name: 'chill_event_participation_new')] public function newAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse { // test the request is correct @@ -416,9 +416,7 @@ final class ParticipationController extends AbstractController ."'persons_ids' argument in query"); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/update", name="chill_event_participation_update", methods={"POST"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{participation_id}/update', name: 'chill_event_participation_update', methods: ['POST'])] public function updateAction(int $participation_id, Request $request): Response { /** @var Participation $participation */ @@ -460,9 +458,7 @@ final class ParticipationController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{event_id}/update_multiple", name="chill_event_participation_update_multiple", methods={"POST"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/event/participation/{event_id}/update_multiple', name: 'chill_event_participation_update_multiple', methods: ['POST'])] public function updateMultipleAction(mixed $event_id, Request $request) { /** @var Event $event */ diff --git a/src/Bundle/ChillEventBundle/Controller/RoleController.php b/src/Bundle/ChillEventBundle/Controller/RoleController.php index 7d3e6e0f1..e1d94389a 100644 --- a/src/Bundle/ChillEventBundle/Controller/RoleController.php +++ b/src/Bundle/ChillEventBundle/Controller/RoleController.php @@ -26,9 +26,8 @@ class RoleController extends AbstractController /** * Creates a new Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/create", name="chill_event_admin_role_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/create', name: 'chill_event_admin_role_create', methods: ['POST'])] public function createAction(Request $request) { $entity = new Role(); @@ -51,9 +50,8 @@ class RoleController extends AbstractController /** * Deletes a Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/delete", name="chill_event_admin_role_delete", methods={"POST", "DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/{id}/delete', name: 'chill_event_admin_role_delete', methods: ['POST', 'DELETE'])] public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); @@ -76,9 +74,8 @@ class RoleController extends AbstractController /** * Displays a form to edit an existing Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/edit", name="chill_event_admin_role_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/{id}/edit', name: 'chill_event_admin_role_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -101,9 +98,8 @@ class RoleController extends AbstractController /** * Lists all Role entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/", name="chill_event_admin_role", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/', name: 'chill_event_admin_role', options: [null])] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -117,9 +113,8 @@ class RoleController extends AbstractController /** * Displays a form to create a new Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/new", name="chill_event_admin_role_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/new', name: 'chill_event_admin_role_new')] public function newAction() { $entity = new Role(); @@ -133,9 +128,8 @@ class RoleController extends AbstractController /** * Finds and displays a Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/show", name="chill_event_admin_role_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/{id}/show', name: 'chill_event_admin_role_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -156,9 +150,8 @@ class RoleController extends AbstractController /** * Edits an existing Role entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/update", name="chill_event_admin_role_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/role/{id}/update', name: 'chill_event_admin_role_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillEventBundle/Controller/StatusController.php b/src/Bundle/ChillEventBundle/Controller/StatusController.php index 294ca0222..77f6d4279 100644 --- a/src/Bundle/ChillEventBundle/Controller/StatusController.php +++ b/src/Bundle/ChillEventBundle/Controller/StatusController.php @@ -26,9 +26,8 @@ class StatusController extends AbstractController /** * Creates a new Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/create", name="chill_event_admin_status_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/create', name: 'chill_event_admin_status_create', methods: ['POST'])] public function createAction(Request $request) { $entity = new Status(); @@ -51,9 +50,8 @@ class StatusController extends AbstractController /** * Deletes a Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/delete", name="chill_event_admin_status_delete", methods={"POST", "DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/{id}/delete', name: 'chill_event_admin_status_delete', methods: ['POST', 'DELETE'])] public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); @@ -76,9 +74,8 @@ class StatusController extends AbstractController /** * Displays a form to edit an existing Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/edit", name="chill_event_admin_status_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/{id}/edit', name: 'chill_event_admin_status_edit')] public function editAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -101,9 +98,8 @@ class StatusController extends AbstractController /** * Lists all Status entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/", name="chill_event_admin_status", options={null}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/', name: 'chill_event_admin_status', options: [null])] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -117,9 +113,8 @@ class StatusController extends AbstractController /** * Displays a form to create a new Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/new", name="chill_event_admin_status_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/new', name: 'chill_event_admin_status_new')] public function newAction() { $entity = new Status(); @@ -133,9 +128,8 @@ class StatusController extends AbstractController /** * Finds and displays a Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/show", name="chill_event_admin_status_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/{id}/show', name: 'chill_event_admin_status_show')] public function showAction(mixed $id) { $em = $this->managerRegistry->getManager(); @@ -156,9 +150,8 @@ class StatusController extends AbstractController /** * Edits an existing Status entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/update", name="chill_event_admin_status_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/event/status/{id}/update', name: 'chill_event_admin_status_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, mixed $id) { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 486a67c5c..88d4ca3eb 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -45,9 +45,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")A - * - * @Assert\NotNull() */ + #[Assert\NotNull] private ?Center $center = null; /** @@ -76,9 +75,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @ORM\Column(type="string", length=150) - * - * @Assert\NotBlank() */ + #[Assert\NotBlank] private ?string $name = null; /** @@ -92,9 +90,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType") - * - * @Assert\NotNull() */ + #[Assert\NotNull] private ?EventType $type = null; /** diff --git a/src/Bundle/ChillEventBundle/Entity/Participation.php b/src/Bundle/ChillEventBundle/Entity/Participation.php index 9b4664f0d..55751998d 100644 --- a/src/Bundle/ChillEventBundle/Entity/Participation.php +++ b/src/Bundle/ChillEventBundle/Entity/Participation.php @@ -34,11 +34,12 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * * @ORM\UniqueConstraint(name="chill_event_participation_event_person_unique_idx", columns={"event_id", "person_id"}) * }) + * @ORM\UniqueConstraint(name="chill_event_participation_event_person_unique_idx", columns={"event_id", "person_id"}) + * }) * * @ORM\HasLifecycleCallbacks - * - * @UniqueEntity({"event", "person"}, message="event.validation.person_already_participate_to_event") */ +#[UniqueEntity(['event', 'person'], message: 'event.validation.person_already_participate_to_event')] class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface, TrackUpdateInterface, TrackCreationInterface { use TrackCreationTrait; @@ -62,9 +63,8 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") - * - * @Assert\NotNull() */ + #[Assert\NotNull] private ?Person $person = null; /** @@ -74,9 +74,8 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa /** * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Status") - * - * @Assert\NotNull() */ + #[Assert\NotNull] private ?Status $status = null; public function getCenter() diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index 0d6dd0998..c7871a346 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -27,12 +27,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; class ChillImportUsersCommand extends Command { + protected static $defaultDescription = 'Import users from csv file'; /** * Centers and aliases. * @@ -55,7 +55,7 @@ class ChillImportUsersCommand extends Command public function __construct( protected EntityManagerInterface $em, protected LoggerInterface $logger, - protected UserPasswordEncoderInterface $passwordEncoder, + protected \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, protected ValidatorInterface $validator, protected UserRepository $userRepository ) { @@ -86,7 +86,6 @@ class ChillImportUsersCommand extends Command protected function configure() { $this - ->setDescription('Import users from csv file') ->setHelp("Import users from a csv file. Users are added to centers contained in the file. Headers are used to detect columns. Adding to multiple centers can be done by using a `grouping centers` file, which will group multiple centers into a signle alias, used in 'centers' column.") ->addArgument('csvfile', InputArgument::REQUIRED, 'Path to the csv file. Columns are: `username`, `email`, `center` (can contain alias), `permission group`') ->addOption('grouping-centers', null, InputOption::VALUE_OPTIONAL, 'Path to a csv file to aggregate multiple centers into a single alias') @@ -130,7 +129,7 @@ class ChillImportUsersCommand extends Command ->setEmail(\trim((string) $data['email'])) ->setUsername(\trim((string) $data['username'])) ->setEnabled(true) - ->setPassword($this->passwordEncoder->encodePassword( + ->setPassword($this->passwordEncoder->hashPassword( $user, \bin2hex(\random_bytes(32)) )); @@ -207,7 +206,7 @@ class ChillImportUsersCommand extends Command throw $e; } - return 0; + return Command::SUCCESS; } /** diff --git a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php index da14d85ff..3e1367a00 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php @@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; */ class ChillUserSendRenewPasswordCodeCommand extends Command { + protected static $defaultDescription = 'Send a message with code to recover password'; /** * @var EntityManagerInterface */ @@ -82,7 +83,6 @@ class ChillUserSendRenewPasswordCodeCommand extends Command { $this ->setName('chill:user:send-password-recover-code') - ->setDescription('Send a message with code to recover password') ->addArgument('csvfile', InputArgument::REQUIRED, 'CSV file with the list of users') ->addOption('template', null, InputOption::VALUE_REQUIRED, 'Template for email') ->addOption('expiration', null, InputOption::VALUE_REQUIRED, 'Expiration of the link, as an unix timestamp') @@ -108,7 +108,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command $this->sendRecoverCode($user); } - return 0; + return Command::SUCCESS; } /** diff --git a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php index ec38fa173..6d998f732 100644 --- a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php @@ -19,6 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface; class ExecuteCronJobCommand extends Command { + protected static $defaultDescription = 'Execute the cronjob(s) given as argument, or one cronjob scheduled by system.'; + public function __construct( private readonly CronManagerInterface $cronManager ) { @@ -28,7 +30,6 @@ class ExecuteCronJobCommand extends Command protected function configure() { $this - ->setDescription('Execute the cronjob(s) given as argument, or one cronjob scheduled by system.') ->setHelp("If no job is specified, the next available cronjob will be executed by system.\nThis command should be execute every 15 minutes (more or less)") ->addArgument('job', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'one or more job to force execute (by default, all jobs are executed)', []) ->addUsage(''); @@ -39,13 +40,13 @@ class ExecuteCronJobCommand extends Command if ([] === $input->getArgument('job')) { $this->cronManager->run(); - return 0; + return Command::SUCCESS; } foreach ($input->getArgument('job') as $jobName) { $this->cronManager->run($jobName); } - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php index 710dedb8f..d5dedd169 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php @@ -20,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesBEFromBestAddressCommand extends Command { + protected static $defaultDescription = 'Import BE addresses from BeST Address (see https://osoc19.github.io/best/)'; + public function __construct( private readonly AddressReferenceBEFromBestAddress $addressImporter, private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter @@ -32,8 +34,7 @@ class LoadAddressesBEFromBestAddressCommand extends Command $this ->setName('chill:main:address-ref-from-best-addresses') ->addArgument('lang', InputArgument::REQUIRED, "Language code, for example 'fr'") - ->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)") - ->setDescription('Import BE addresses from BeST Address (see https://osoc19.github.io/best/)'); + ->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)"); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -42,6 +43,6 @@ class LoadAddressesBEFromBestAddressCommand extends Command $this->addressImporter->import($input->getArgument('lang'), $input->getArgument('list')); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php index 89a159fc4..2bfc3be5c 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php @@ -19,6 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesFRFromBANOCommand extends Command { + protected static $defaultDescription = 'Import FR addresses from bano (see https://bano.openstreetmap.fr'; + public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano) { parent::__construct(); @@ -27,8 +29,7 @@ class LoadAddressesFRFromBANOCommand extends Command protected function configure() { $this->setName('chill:main:address-ref-from-bano') - ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers') - ->setDescription('Import FR addresses from bano (see https://bano.openstreetmap.fr'); + ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -39,6 +40,6 @@ class LoadAddressesFRFromBANOCommand extends Command $this->addressReferenceFromBano->import($departementNo); } - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index e4b3ae673..376df4e52 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -54,8 +54,6 @@ class LoadAndUpdateLanguagesCommand extends Command { $this ->setName('chill:main:languages:populate') - ->setDescription('Load or update languages in db. This command does not delete existing '. - 'languages, but will update names according to available languages') ->addOption( self::INCLUDE_REGIONAL_VERSION, null, @@ -122,6 +120,6 @@ class LoadAndUpdateLanguagesCommand extends Command $em->flush(); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index b6a9be75c..3f7f82523 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -55,9 +55,7 @@ class LoadCountriesCommand extends Command */ protected function configure() { - $this->setName('chill:main:countries:populate') - ->setDescription('Load or update countries in db. This command does not delete existing countries, '. - 'but will update names according to available languages'); + $this->setName('chill:main:countries:populate'); } /** @@ -83,6 +81,6 @@ class LoadCountriesCommand extends Command $em->flush(); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php index be29cad9f..eb0bef879 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php @@ -18,6 +18,8 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadPostalCodeFR extends Command { + protected static $defaultDescription = 'Load France\'s postal code from online open data'; + public function __construct(private readonly PostalCodeFRFromOpenData $loader) { parent::__construct(); @@ -25,14 +27,13 @@ class LoadPostalCodeFR extends Command public function configure(): void { - $this->setName('chill:main:postal-code:load:FR') - ->setDescription('Load France\'s postal code from online open data'); + $this->setName('chill:main:postal-code:load:FR'); } public function execute(InputInterface $input, OutputInterface $output): int { $this->loader->import(); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index b22027499..4f0896114 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -25,6 +25,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; class LoadPostalCodesCommand extends Command { + protected static $defaultDescription = 'Add the postal code from a csv file.'; + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator) { parent::__construct(); @@ -33,7 +35,6 @@ class LoadPostalCodesCommand extends Command protected function configure() { $this->setName('chill:main:postal-code:populate') - ->setDescription('Add the postal code from a csv file.') ->setHelp('This script will try to avoid existing postal code ' ."using the postal code and name. \n" .'The CSV file must have the following columns: ' @@ -101,7 +102,7 @@ class LoadPostalCodesCommand extends Command $output->writeln(''.$num.' were added !'); - return 0; + return Command::SUCCESS; } private function addPostalCode($row, OutputInterface $output) diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index a83663ed0..6924b8049 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -18,13 +18,14 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactory; -use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; /** * Class SetPasswordCommand. */ class SetPasswordCommand extends Command { + protected static $defaultDescription = 'set a password to user'; + /** * SetPasswordCommand constructor. */ @@ -42,7 +43,7 @@ class SetPasswordCommand extends Command public function _setPassword(User $user, $password) { - $defaultEncoder = new MessageDigestPasswordEncoder('sha512', true, 5000); + $defaultEncoder = new \Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher('sha512', true, 5000); $encoders = [ User::class => $defaultEncoder, ]; @@ -56,7 +57,6 @@ class SetPasswordCommand extends Command public function configure() { $this->setName('chill:user:set_password') - ->setDescription('set a password to user') ->addArgument('username', InputArgument::REQUIRED, 'the user\'s ' .'username you want to change password') ->addArgument('password', InputArgument::OPTIONAL, 'the new password'); @@ -80,6 +80,6 @@ class SetPasswordCommand extends Command $this->_setPassword($user, $password); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php index 71bee0e0e..16a90dbe8 100644 --- a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php @@ -18,22 +18,20 @@ use Symfony\Component\Console\Output\OutputInterface; class SynchronizeEntityInfoViewsCommand extends Command { + protected static $defaultDescription = 'Update or create sql views which provide info for various entities'; + public function __construct( private readonly ViewEntityInfoManager $viewEntityInfoManager, ) { parent::__construct('chill:db:sync-views'); } - protected function configure(): void - { - $this - ->setDescription('Update or create sql views which provide info for various entities'); - } + protected function configure(): void {} protected function execute(InputInterface $input, OutputInterface $output): int { $this->viewEntityInfoManager->synchronizeOnDB(); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillMainBundle/Controller/AbsenceController.php b/src/Bundle/ChillMainBundle/Controller/AbsenceController.php index 23aa9fd10..3961c9f3a 100644 --- a/src/Bundle/ChillMainBundle/Controller/AbsenceController.php +++ b/src/Bundle/ChillMainBundle/Controller/AbsenceController.php @@ -21,13 +21,7 @@ class AbsenceController extends AbstractController { public function __construct(private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @Route( - * "/{_locale}/absence", - * name="chill_main_user_absence_index", - * methods={"GET", "POST"} - * ) - */ + #[Route(path: '/{_locale}/absence', name: 'chill_main_user_absence_index', methods: ['GET', 'POST'])] public function setAbsence(Request $request) { $user = $this->security->getUser(); @@ -48,13 +42,7 @@ class AbsenceController extends AbstractController ]); } - /** - * @Route( - * "/{_locale}/absence/unset", - * name="chill_main_user_absence_unset", - * methods={"GET", "POST"} - * ) - */ + #[Route(path: '/{_locale}/absence/unset', name: 'chill_main_user_absence_unset', methods: ['GET', 'POST'])] public function unsetAbsence(Request $request) { $user = $this->security->getUser(); diff --git a/src/Bundle/ChillMainBundle/Controller/AddressApiController.php b/src/Bundle/ChillMainBundle/Controller/AddressApiController.php index 1f7abdb7a..5ea68cdbc 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressApiController.php @@ -24,10 +24,8 @@ class AddressApiController extends ApiController /** * Duplicate an existing address. - * - * @Route("/api/1.0/main/address/{id}/duplicate.json", name="chill_api_main_address_duplicate", - * methods={"POST"}) */ + #[Route(path: '/api/1.0/main/address/{id}/duplicate.json', name: 'chill_api_main_address_duplicate', methods: ['POST'])] public function duplicate(Address $address): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php index b3cf68849..e50cea6bb 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php @@ -28,9 +28,7 @@ final class AddressReferenceAPIController extends ApiController { public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory) {} - /** - * @Route("/api/1.0/main/address-reference/by-postal-code/{id}/search.json") - */ + #[Route(path: '/api/1.0/main/address-reference/by-postal-code/{id}/search.json')] public function search(PostalCode $postalCode, Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php index 967ee7b5b..680a63859 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php @@ -25,9 +25,7 @@ class AddressToReferenceMatcherController { public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer) {} - /** - * @Route("/api/1.0/main/address/reference-match/{id}/set/reviewed", methods={"POST"}) - */ + #[Route(path: '/api/1.0/main/address/reference-match/{id}/set/reviewed', methods: ['POST'])] public function markAddressAsReviewed(Address $address): JsonResponse { if (!$this->security->isGranted('ROLE_USER')) { @@ -48,9 +46,8 @@ class AddressToReferenceMatcherController /** * Set an address back to "to review". Only if the address is in "reviewed" state. - * - * @Route("/api/1.0/main/address/reference-match/{id}/set/to_review", methods={"POST"}) */ + #[Route(path: '/api/1.0/main/address/reference-match/{id}/set/to_review', methods: ['POST'])] public function markAddressAsToReview(Address $address): JsonResponse { if (!$this->security->isGranted('ROLE_USER')) { @@ -73,9 +70,7 @@ class AddressToReferenceMatcherController ); } - /** - * @Route("/api/1.0/main/address/reference-match/{id}/sync-with-reference", methods={"POST"}) - */ + #[Route(path: '/api/1.0/main/address/reference-match/{id}/sync-with-reference', methods: ['POST'])] public function syncAddressWithReference(Address $address): JsonResponse { if (null === $address->getAddressReference()) { diff --git a/src/Bundle/ChillMainBundle/Controller/AdminController.php b/src/Bundle/ChillMainBundle/Controller/AdminController.php index 46fbfb351..abdfb679d 100644 --- a/src/Bundle/ChillMainBundle/Controller/AdminController.php +++ b/src/Bundle/ChillMainBundle/Controller/AdminController.php @@ -16,41 +16,31 @@ use Symfony\Component\Routing\Annotation\Route; class AdminController extends AbstractController { - /** - * @Route("/{_locale}/admin", name="chill_main_admin_central") - */ + #[Route(path: '/{_locale}/admin', name: 'chill_main_admin_central')] public function indexAction() { return $this->render('@ChillMain/Admin/index.html.twig'); } - /** - * @Route("/{_locale}/admin/language", name="chill_main_language_admin") - */ + #[Route(path: '/{_locale}/admin/language', name: 'chill_main_language_admin')] public function indexLanguageAction() { return $this->render('@ChillMain/Admin/indexLanguage.html.twig'); } - /** - * @Route("/{_locale}/admin/location", name="chill_main_location_admin") - */ + #[Route(path: '/{_locale}/admin/location', name: 'chill_main_location_admin')] public function indexLocationAction() { return $this->render('@ChillMain/Admin/indexLocation.html.twig'); } - /** - * @Route("/{_locale}/admin/user", name="chill_main_user_admin") - */ + #[Route(path: '/{_locale}/admin/user', name: 'chill_main_user_admin')] public function indexUserAction() { return $this->render('@ChillMain/Admin/indexUser.html.twig'); } - /** - * @Route("/{_locale}/admin/dashboard", name="chill_main_dashboard_admin") - */ + #[Route(path: '/{_locale}/admin/dashboard', name: 'chill_main_dashboard_admin')] public function indexDashboardAction() { return $this->render('@ChillMain/Admin/indexDashboard.html.twig'); diff --git a/src/Bundle/ChillMainBundle/Controller/DashboardApiController.php b/src/Bundle/ChillMainBundle/Controller/DashboardApiController.php index c9b5435ce..ffc23da81 100644 --- a/src/Bundle/ChillMainBundle/Controller/DashboardApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/DashboardApiController.php @@ -24,9 +24,8 @@ final readonly class DashboardApiController /** * Get user dashboard config (not yet based on user id and still hardcoded for now). - * - * @Route("/api/1.0/main/dashboard-config-item.json", methods={"get"}) */ + #[Route(path: '/api/1.0/main/dashboard-config-item.json', methods: ['get'])] public function getDashboardConfiguration(): JsonResponse { $data = []; diff --git a/src/Bundle/ChillMainBundle/Controller/DefaultController.php b/src/Bundle/ChillMainBundle/Controller/DefaultController.php index 389c89767..389ed7764 100644 --- a/src/Bundle/ChillMainBundle/Controller/DefaultController.php +++ b/src/Bundle/ChillMainBundle/Controller/DefaultController.php @@ -18,9 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; */ class DefaultController extends AbstractController { - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/homepage", name="chill_main_homepage") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/homepage', name: 'chill_main_homepage')] public function indexAction() { if ($this->isGranted('ROLE_ADMIN')) { @@ -30,9 +28,7 @@ class DefaultController extends AbstractController return $this->render('@ChillMain/layout.html.twig'); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/homepage", name="chill_main_homepage_without_locale") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/homepage', name: 'chill_main_homepage_without_locale')] public function indexWithoutLocaleAction() { return $this->redirectToRoute('chill_main_homepage'); diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 2df7008d6..709d3ceb9 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -65,9 +65,7 @@ class ExportController extends AbstractController $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/download/{alias}", name="chill_main_export_download", methods={"GET"}) - */ + #[Route(path: '/{_locale}/exports/download/{alias}', name: 'chill_main_export_download', methods: ['GET'])] public function downloadResultAction(Request $request, mixed $alias) { /** @var ExportManager $exportManager */ @@ -109,9 +107,11 @@ class ExportController extends AbstractController * @param string $alias * * @return Response + * @return Response * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/generate/{alias}", name="chill_main_export_generate", methods={"GET"}) */ + #[Route(path: '/{_locale}/exports/generate/{alias}', name: 'chill_main_export_generate', methods: ['GET'])] public function generateAction(Request $request, $alias) { /** @var ExportManager $exportManager */ @@ -130,10 +130,9 @@ class ExportController extends AbstractController } /** - * @Route("/{_locale}/exports/generate-from-saved/{id}", name="chill_main_export_generate_from_saved") - * * @throws \RedisException */ + #[Route(path: '/{_locale}/exports/generate-from-saved/{id}', name: 'chill_main_export_generate_from_saved')] public function generateFromSavedExport(SavedExport $savedExport): RedirectResponse { $this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport); @@ -154,9 +153,8 @@ class ExportController extends AbstractController /** * Render the list of available exports. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/", name="chill_main_export_index") */ + #[Route(path: '/{_locale}/exports/', name: 'chill_main_export_index')] public function indexAction(): Response { $exportManager = $this->exportManager; @@ -179,9 +177,8 @@ class ExportController extends AbstractController * stored in the session (if valid), and then a redirection is done to next step. * 3. 'generate': gather data from session from the previous steps, and * make a redirection to the "generate" action with data in query (HTTP GET) - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/new/{alias}", name="chill_main_export_new") */ + #[Route(path: '/{_locale}/exports/new/{alias}', name: 'chill_main_export_new')] public function newAction(Request $request, string $alias): Response { // first check for ACL @@ -205,9 +202,7 @@ class ExportController extends AbstractController }; } - /** - * @Route("/{_locale}/export/saved/update-from-key/{id}/{key}", name="chill_main_export_saved_edit_options_from_key") - */ + #[Route(path: '/{_locale}/export/saved/update-from-key/{id}/{key}', name: 'chill_main_export_saved_edit_options_from_key')] public function editSavedExportOptionsFromKey(SavedExport $savedExport, string $key): Response { $this->denyAccessUnlessGranted('ROLE_USER'); @@ -227,9 +222,7 @@ class ExportController extends AbstractController return $this->redirectToRoute('chill_main_export_saved_edit', ['id' => $savedExport->getId()]); } - /** - * @Route("/{_locale}/export/save-from-key/{alias}/{key}", name="chill_main_export_save_from_key") - */ + #[Route(path: '/{_locale}/export/save-from-key/{alias}/{key}', name: 'chill_main_export_save_from_key')] public function saveFromKey(string $alias, string $key, Request $request): Response { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php index 24253de36..7574eea1e 100644 --- a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php @@ -26,9 +26,7 @@ class GeographicalUnitByAddressApiController { public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer) {} - /** - * @Route("/api/1.0/main/geographical-unit/by-address/{id}.{_format}", requirements={"_format": "json"}) - */ + #[Route(path: '/api/1.0/main/geographical-unit/by-address/{id}.{_format}', requirements: ['_format' => 'json'])] public function getGeographicalUnitCoveringAddress(Address $address): JsonResponse { if (!$this->security->isGranted('ROLE_USER')) { diff --git a/src/Bundle/ChillMainBundle/Controller/LoginController.php b/src/Bundle/ChillMainBundle/Controller/LoginController.php index df295d0b2..a23d9ff08 100644 --- a/src/Bundle/ChillMainBundle/Controller/LoginController.php +++ b/src/Bundle/ChillMainBundle/Controller/LoginController.php @@ -35,9 +35,11 @@ class LoginController extends AbstractController * Show a login form. * * @return Response + * @return Response * * @\Symfony\Component\Routing\Annotation\Route(path="/login", name="login") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/login', name: 'login')] public function loginAction(Request $request) { return $this->render('@ChillMain/Login/login.html.twig', [ diff --git a/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php b/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php index c4476a041..c687acc2f 100644 --- a/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php @@ -29,9 +29,8 @@ class NewsItemApiController /** * Get list of news items filtered on start and end date. - * - * @Route("/api/1.0/main/news/current.json", methods={"get"}) */ + #[Route(path: '/api/1.0/main/news/current.json', methods: ['get'])] public function listCurrentNewsItems(): JsonResponse { $total = $this->newsItemRepository->countCurrentNews(); diff --git a/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php b/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php index b79812464..78b7077ee 100644 --- a/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php +++ b/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php @@ -30,9 +30,7 @@ final readonly class NewsItemHistoryController private readonly Environment $environment, ) {} - /** - * @Route("/{_locale}/news-items/history", name="chill_main_news_items_history") - */ + #[Route(path: '/{_locale}/news-items/history', name: 'chill_main_news_items_history')] public function list(): Response { $filter = $this->buildFilterOrder(); @@ -48,9 +46,7 @@ final readonly class NewsItemHistoryController ])); } - /** - * @Route("/{_locale}/news-items/{id}", name="chill_main_single_news_item") - */ + #[Route(path: '/{_locale}/news-items/{id}', name: 'chill_main_single_news_item')] public function showSingleItem(NewsItem $newsItem, Request $request): Response { return new Response($this->environment->render( diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php index 16599b9a2..2fb7969cf 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php @@ -26,32 +26,24 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\SerializerInterface; -/** - * @Route("/api/1.0/main/notification") - */ +#[Route(path: '/api/1.0/main/notification')] class NotificationApiController { public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {} - /** - * @Route("/{id}/mark/read", name="chill_api_main_notification_mark_read", methods={"POST"}) - */ + #[Route(path: '/{id}/mark/read', name: 'chill_api_main_notification_mark_read', methods: ['POST'])] public function markAsRead(Notification $notification): JsonResponse { return $this->markAs('read', $notification); } - /** - * @Route("/{id}/mark/unread", name="chill_api_main_notification_mark_unread", methods={"POST"}) - */ + #[Route(path: '/{id}/mark/unread', name: 'chill_api_main_notification_mark_unread', methods: ['POST'])] public function markAsUnread(Notification $notification): JsonResponse { return $this->markAs('unread', $notification); } - /** - * @Route("/my/unread") - */ + #[Route(path: '/my/unread')] public function myUnreadNotifications(Request $request): JsonResponse { $total = $this->notificationRepository->countUnreadByUser($this->security->getUser()); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index ea79317bf..162c099ef 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -35,16 +35,12 @@ use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -/** - * @Route("/{_locale}/notification") - */ +#[Route(path: '/{_locale}/notification')] class NotificationController extends AbstractController { public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly ChillSecurity $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @Route("/create", name="chill_main_notification_create") - */ + #[Route(path: '/create', name: 'chill_main_notification_create')] public function createAction(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -102,9 +98,7 @@ class NotificationController extends AbstractController ]); } - /** - * @Route("/{id}/edit", name="chill_main_notification_edit") - */ + #[Route(path: '/{id}/edit', name: 'chill_main_notification_edit')] public function editAction(Notification $notification, Request $request): Response { $this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_UPDATE, $notification); @@ -132,9 +126,7 @@ class NotificationController extends AbstractController ]); } - /** - * @Route("/{id}/access_key", name="chill_main_notification_grant_access_by_access_key") - */ + #[Route(path: '/{id}/access_key', name: 'chill_main_notification_grant_access_by_access_key')] public function getAccessByAccessKey(Notification $notification, Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -174,9 +166,7 @@ class NotificationController extends AbstractController return $this->redirectToRoute('chill_main_notification_show', ['id' => $notification->getId()]); } - /** - * @Route("/inbox", name="chill_main_notification_my") - */ + #[Route(path: '/inbox', name: 'chill_main_notification_my')] public function inboxAction(): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -200,9 +190,7 @@ class NotificationController extends AbstractController ]); } - /** - * @Route("/sent", name="chill_main_notification_sent") - */ + #[Route(path: '/sent', name: 'chill_main_notification_sent')] public function sentAction(): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -226,9 +214,7 @@ class NotificationController extends AbstractController ]); } - /** - * @Route("/{id}/show", name="chill_main_notification_show") - */ + #[Route(path: '/{id}/show', name: 'chill_main_notification_show')] public function showAction(Notification $notification, Request $request): Response { $this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_SEE, $notification); diff --git a/src/Bundle/ChillMainBundle/Controller/PasswordController.php b/src/Bundle/ChillMainBundle/Controller/PasswordController.php index e65c70672..efd6c9630 100644 --- a/src/Bundle/ChillMainBundle/Controller/PasswordController.php +++ b/src/Bundle/ChillMainBundle/Controller/PasswordController.php @@ -27,7 +27,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -40,21 +39,18 @@ final class PasswordController extends AbstractController /** * PasswordController constructor. */ - public function __construct(private readonly LoggerInterface $chillLogger, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly RecoverPasswordHelper $recoverPasswordHelper, private readonly TokenManager $tokenManager, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} + public function __construct(private readonly LoggerInterface $chillLogger, private readonly \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, private readonly RecoverPasswordHelper $recoverPasswordHelper, private readonly TokenManager $tokenManager, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} /** * @return Response - * - * @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-changed", name="password_request_recover_changed") */ + #[Route(path: '/public/{_locale}/password/request-changed', name: 'password_request_recover_changed')] public function changeConfirmedAction() { return $this->render('@ChillMain/Password/recover_password_changed.html.twig'); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/recover", name="password_recover") - */ + #[Route(path: '/public/{_locale}/password/recover', name: 'password_recover')] public function recoverAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse { if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { @@ -96,7 +92,7 @@ final class PasswordController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $password = $form->get('new_password')->getData(); - $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + $user->setPassword($this->passwordEncoder->hashPassword($user, $password)); // logging for prod $this ->chillLogger @@ -120,9 +116,11 @@ final class PasswordController extends AbstractController /** * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException + * @throws \Doctrine\ORM\NonUniqueResultException * * @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-recover", name="password_request_recover") */ + #[Route(path: '/public/{_locale}/password/request-recover', name: 'password_request_recover')] public function requestRecoverAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse { if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { @@ -193,9 +191,8 @@ final class PasswordController extends AbstractController /** * @return Response - * - * @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-confirm", name="password_request_recover_confirm") */ + #[Route(path: '/public/{_locale}/password/request-confirm', name: 'password_request_recover_confirm')] public function requestRecoverConfirmAction() { return $this->render('@ChillMain/Password/request_recover_password_confirm.html.twig'); @@ -203,9 +200,8 @@ final class PasswordController extends AbstractController /** * @return Response - * - * @Route("/{_locale}/my/password", name="change_my_password") */ + #[Route(path: '/{_locale}/my/password', name: 'change_my_password')] public function UserPasswordAction(Request $request) { if (!$this->security->isGranted('ROLE_USER')) { @@ -234,7 +230,7 @@ final class PasswordController extends AbstractController ] ); - $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + $user->setPassword($this->passwordEncoder->hashPassword($user, $password)); $em = $this->managerRegistry->getManager(); $em->flush(); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php index 8b0561635..2abb7333f 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php @@ -24,10 +24,9 @@ class PermissionApiController extends AbstractController public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security) {} /** - * @Route("/api/1.0/main/permissions/info.json", methods={"POST"}) - * * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface */ + #[Route(path: '/api/1.0/main/permissions/info.json', methods: ['POST'])] public function getPermissions(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 52ef9bfbb..62cc7a724 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -49,9 +49,7 @@ final class PermissionsGroupController extends AbstractController private readonly RoleScopeRepository $roleScopeRepository, ) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope", name="admin_permissionsgroup_add_role_scope", methods={"PUT"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope', name: 'admin_permissionsgroup_add_role_scope', methods: ['PUT'])] public function addLinkRoleScopeAction(Request $request, int $id): Response { $permissionsGroup = $this->permissionsGroupRepository->find($id); @@ -129,9 +127,8 @@ final class PermissionsGroupController extends AbstractController /** * Creates a new PermissionsGroup entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/create", name="admin_permissionsgroup_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/create', name: 'admin_permissionsgroup_create', methods: ['POST'])] public function createAction(Request $request): Response { $permissionsGroup = new PermissionsGroup(); @@ -153,9 +150,8 @@ final class PermissionsGroupController extends AbstractController /** * remove an association between permissionsGroup and roleScope. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}", name="admin_permissionsgroup_delete_role_scope", methods={"DELETE"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}', name: 'admin_permissionsgroup_delete_role_scope', methods: ['DELETE'])] public function deleteLinkRoleScopeAction(int $pgid, int $rsid): Response { $permissionsGroup = $this->permissionsGroupRepository->find($pgid); @@ -211,9 +207,8 @@ final class PermissionsGroupController extends AbstractController /** * Displays a form to edit an existing PermissionsGroup entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/edit", name="admin_permissionsgroup_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/edit', name: 'admin_permissionsgroup_edit')] public function editAction(int $id): Response { $permissionsGroup = $this->permissionsGroupRepository->find($id); @@ -259,9 +254,8 @@ final class PermissionsGroupController extends AbstractController /** * Lists all PermissionsGroup entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/", name="admin_permissionsgroup") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/', name: 'admin_permissionsgroup')] public function indexAction(): Response { $entities = $this->permissionsGroupRepository->findAllOrderedAlphabetically(); @@ -273,9 +267,8 @@ final class PermissionsGroupController extends AbstractController /** * Displays a form to create a new PermissionsGroup entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/new", name="admin_permissionsgroup_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/new', name: 'admin_permissionsgroup_new')] public function newAction(): Response { $permissionsGroup = new PermissionsGroup(); @@ -289,9 +282,8 @@ final class PermissionsGroupController extends AbstractController /** * Finds and displays a PermissionsGroup entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/show", name="admin_permissionsgroup_show") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/show', name: 'admin_permissionsgroup_show')] public function showAction(int $id): Response { $permissionsGroup = $this->permissionsGroupRepository->find($id); @@ -342,9 +334,8 @@ final class PermissionsGroupController extends AbstractController /** * Edits an existing PermissionsGroup entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/update", name="admin_permissionsgroup_update", methods={"POST", "PUT"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/update', name: 'admin_permissionsgroup_update', methods: ['POST', 'PUT'])] public function updateAction(Request $request, int $id): Response { $permissionsGroup = $this->permissionsGroupRepository diff --git a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php index 2b897130d..cd13ad455 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php @@ -28,9 +28,7 @@ final class PostalCodeAPIController extends ApiController { public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory) {} - /** - * @Route("/api/1.0/main/postal-code/search.json") - */ + #[Route(path: '/api/1.0/main/postal-code/search.json')] public function search(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); diff --git a/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php b/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php index b7ea48328..edd8efda8 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php @@ -35,12 +35,9 @@ class PostalCodeController extends AbstractController } /** - * @Route( - * "{_locale}/postalcode/search" - * ) - * * @return JsonResponse */ + #[Route(path: '{_locale}/postalcode/search')] public function searchAction(Request $request) { $pattern = $request->query->getAlnum('q', ''); diff --git a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php index 15bfcb9bb..82d41a9e1 100644 --- a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php @@ -36,9 +36,7 @@ class SavedExportController { public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) {} - /** - * @Route("/{_locale}/exports/saved/{id}/delete", name="chill_main_export_saved_delete") - */ + #[Route(path: '/{_locale}/exports/saved/{id}/delete', name: 'chill_main_export_saved_delete')] public function delete(SavedExport $savedExport, Request $request): Response { if (!$this->security->isGranted(SavedExportVoter::DELETE, $savedExport)) { @@ -71,9 +69,7 @@ class SavedExportController ); } - /** - * @Route("/{_locale}/exports/saved/{id}/edit", name="chill_main_export_saved_edit") - */ + #[Route(path: '/{_locale}/exports/saved/{id}/edit', name: 'chill_main_export_saved_edit')] public function edit(SavedExport $savedExport, Request $request): Response { if (!$this->security->isGranted(SavedExportVoter::EDIT, $savedExport)) { @@ -104,9 +100,7 @@ class SavedExportController ); } - /** - * @Route("/{_locale}/exports/saved/my", name="chill_main_export_saved_list_my") - */ + #[Route(path: '/{_locale}/exports/saved/my', name: 'chill_main_export_saved_list_my')] public function list(): Response { $user = $this->security->getUser(); diff --git a/src/Bundle/ChillMainBundle/Controller/ScopeController.php b/src/Bundle/ChillMainBundle/Controller/ScopeController.php index e6bcdce86..5e932063a 100644 --- a/src/Bundle/ChillMainBundle/Controller/ScopeController.php +++ b/src/Bundle/ChillMainBundle/Controller/ScopeController.php @@ -32,9 +32,8 @@ class ScopeController extends AbstractController /** * Creates a new Scope entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/create", name="admin_scope_create", methods={"POST"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/create', name: 'admin_scope_create', methods: ['POST'])] public function createAction(Request $request) { $scope = new Scope(); @@ -57,9 +56,8 @@ class ScopeController extends AbstractController /** * Displays a form to edit an existing Scope entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/{id}/edit", name="admin_scope_edit") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/{id}/edit', name: 'admin_scope_edit')] public function editAction(Scope $scope, Request $request): Response { $editForm = $this->createEditForm($scope); @@ -79,9 +77,8 @@ class ScopeController extends AbstractController /** * Lists all Scope entities. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/", name="admin_scope") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/', name: 'admin_scope')] public function indexAction() { $em = $this->managerRegistry->getManager(); @@ -95,9 +92,8 @@ class ScopeController extends AbstractController /** * Displays a form to create a new Scope entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/new", name="admin_scope_new") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/new', name: 'admin_scope_new')] public function newAction() { $scope = new Scope(); diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 78dd5eaba..90fa6e1b5 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -34,9 +34,7 @@ class SearchController extends AbstractController { public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search/advanced/{name}", name="chill_main_advanced_search") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search/advanced/{name}', name: 'chill_main_advanced_search')] public function advancedSearchAction(mixed $name, Request $request) { try { @@ -81,9 +79,7 @@ class SearchController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search/advanced", name="chill_main_advanced_search_list") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search/advanced', name: 'chill_main_advanced_search_list')] public function advancedSearchListAction(Request $request) { /** @var Chill\MainBundle\Search\SearchProvider $variable */ @@ -100,9 +96,7 @@ class SearchController extends AbstractController return $this->render('@ChillMain/Search/choose_list.html.twig'); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search.{_format}", name="chill_main_search", requirements={"_format"="html|json"}, defaults={"_format"="html"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search.{_format}', name: 'chill_main_search', requirements: ['_format' => 'html|json'], defaults: ['_format' => 'html'])] public function searchAction(Request $request, mixed $_format) { $pattern = trim((string) $request->query->get('q', '')); @@ -192,9 +186,7 @@ class SearchController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/api/1.0/search.{_format}", name="chill_main_search_global", requirements={"_format"="json"}, defaults={"_format"="json"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/api/1.0/search.{_format}', name: 'chill_main_search_global', requirements: ['_format' => 'json'], defaults: ['_format' => 'json'])] public function searchApi(Request $request, mixed $_format): JsonResponse { // TODO this is an incomplete implementation diff --git a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php index ebbd7a360..97507739e 100644 --- a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php @@ -22,12 +22,7 @@ class TimelineCenterController extends AbstractController { public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security) {} - /** - * @Route("/{_locale}/center/timeline", - * name="chill_center_timeline", - * methods={"GET"} - * ) - */ + #[Route(path: '/{_locale}/center/timeline', name: 'chill_center_timeline', methods: ['GET'])] public function centerAction(Request $request) { // collect reachable center for each group diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index ae764c9d2..262bfdfde 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -24,15 +24,7 @@ class UserApiController extends ApiController { public function __construct(private readonly ChillSecurity $security) {} - /** - * @Route( - * "/api/1.0/main/user-current-location.{_format}", - * name="chill_main_user_current_location", - * requirements={ - * "_format": "json" - * } - * ) - */ + #[Route(path: '/api/1.0/main/user-current-location.{_format}', name: 'chill_main_user_current_location', requirements: ['_format' => 'json'])] public function currentLocation(mixed $_format): JsonResponse { if (!$this->isGranted('ROLE_USER')) { @@ -47,15 +39,7 @@ class UserApiController extends ApiController ); } - /** - * @Route( - * "/api/1.0/main/whoami.{_format}", - * name="chill_main_user_whoami", - * requirements={ - * "_format": "json" - * } - * ) - */ + #[Route(path: '/api/1.0/main/whoami.{_format}', name: 'chill_main_user_whoami', requirements: ['_format' => 'json'])] public function whoami(mixed $_format): JsonResponse { return $this->json( diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 81f39b084..cc1666494 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -31,7 +31,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -42,7 +41,7 @@ class UserController extends CRUDController public function __construct( private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, - private readonly UserPasswordEncoderInterface $passwordEncoder, + private readonly \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag, private readonly TranslatorInterface $translator, @@ -50,10 +49,7 @@ class UserController extends CRUDController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter", - * name="admin_user_add_groupcenter") - */ + #[Route(path: '/{_locale}/admin/main/user/{uid}/add_link_groupcenter', name: 'admin_user_add_groupcenter')] public function addLinkGroupCenterAction(Request $request, mixed $uid): Response { $em = $this->managerRegistry->getManager(); @@ -102,10 +98,7 @@ class UserController extends CRUDController ]); } - /** - * @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}", - * name="admin_user_delete_groupcenter") - */ + #[Route(path: '/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}', name: 'admin_user_delete_groupcenter')] public function deleteLinkGroupCenterAction(mixed $uid, mixed $gcid, Request $request): RedirectResponse { $em = $this->managerRegistry->getManager(); @@ -202,9 +195,8 @@ class UserController extends CRUDController /** * Displays a form to edit the user current location. - * - * @Route("/{_locale}/main/user/current-location/edit", name="chill_main_user_currentlocation_edit") */ + #[Route(path: '/{_locale}/main/user/current-location/edit', name: 'chill_main_user_currentlocation_edit')] public function editCurrentLocationAction(Request $request) { $user = $this->security->getUser(); @@ -234,9 +226,8 @@ class UserController extends CRUDController /** * Displays a form to edit the user password. - * - * @Route("/{_locale}/admin/user/{id}/edit_password", name="admin_user_edit_password") */ + #[Route(path: '/{_locale}/admin/user/{id}/edit_password', name: 'admin_user_edit_password')] public function editPasswordAction(User $user, Request $request) { $editForm = $this->createEditPasswordForm($user); @@ -251,7 +242,7 @@ class UserController extends CRUDController 'user' => $user->getUsername(), ]); - $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + $user->setPassword($this->passwordEncoder->hashPassword($user, $password)); $this->managerRegistry->getManager()->flush(); $this->addFlash('success', $this->translator->trans('Password successfully updated!')); @@ -360,7 +351,7 @@ class UserController extends CRUDController // for "new", encode the password if ('new' === $action && $this->parameterBag->get('chill_main.access_user_change_password')) { $entity->setPassword($this->passwordEncoder - ->encodePassword($entity, $form['plainPassword']->getData())); + ->hashPassword($entity, $form['plainPassword']->getData())); } // default behaviour diff --git a/src/Bundle/ChillMainBundle/Controller/UserExportController.php b/src/Bundle/ChillMainBundle/Controller/UserExportController.php index 7f14b5e64..64b89a6f5 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserExportController.php @@ -33,9 +33,8 @@ final readonly class UserExportController * @throws \League\Csv\CannotInsertRecord * @throws \League\Csv\Exception * @throws \League\Csv\UnavailableStream - * - * @Route("/{_locale}/admin/main/users/export/list.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_list") */ + #[Route(path: '/{_locale}/admin/main/users/export/list.{_format}', requirements: ['_format' => 'csv'], name: 'chill_main_users_export_list')] public function userList(Request $request, string $_format = 'csv'): StreamedResponse { if (!$this->security->isGranted('ROLE_ADMIN')) { @@ -94,9 +93,8 @@ final readonly class UserExportController * @throws \League\Csv\CannotInsertRecord * @throws \League\Csv\Exception * @throws \League\Csv\UnavailableStream - * - * @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions") */ + #[Route(path: '/{_locale}/admin/main/users/export/permissions.{_format}', requirements: ['_format' => 'csv'], name: 'chill_main_users_export_permissions')] public function userPermissionsList(string $_format = 'csv'): StreamedResponse { if (!$this->security->isGranted('ROLE_ADMIN')) { diff --git a/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php b/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php index 55d7aceb7..1bbf5c0c1 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php @@ -23,9 +23,7 @@ class UserJobScopeHistoriesController extends AbstractController private readonly Environment $engine, ) {} - /** - * @Route("/{_locale}/admin/main/user/{id}/job-scope-history", name="admin_user_job_scope_history") - */ + #[Route(path: '/{_locale}/admin/main/user/{id}/job-scope-history', name: 'admin_user_job_scope_history')] public function indexAction(User $user): Response { $jobHistories = $user->getUserJobHistoriesOrdered(); diff --git a/src/Bundle/ChillMainBundle/Controller/UserProfileController.php b/src/Bundle/ChillMainBundle/Controller/UserProfileController.php index ecdde78a5..a48d1a1e2 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserProfileController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserProfileController.php @@ -32,9 +32,8 @@ final class UserProfileController extends AbstractController /** * User profile that allows editing of phonenumber and visualization of certain data. - * - * @Route("/{_locale}/main/user/my-profile", name="chill_main_user_profile") */ + #[Route(path: '/{_locale}/main/user/my-profile', name: 'chill_main_user_profile')] public function __invoke(Request $request) { if (!$this->security->isGranted('ROLE_USER')) { diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php index 4c4d8218c..28dca8016 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php @@ -33,9 +33,8 @@ class WorkflowApiController /** * Return a list of workflow which are waiting an action for the user. - * - * @Route("/api/1.0/main/workflow/my", methods={"GET"}) */ + #[Route(path: '/api/1.0/main/workflow/my', methods: ['GET'])] public function myWorkflow(Request $request): JsonResponse { if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { @@ -72,9 +71,8 @@ class WorkflowApiController /** * Return a list of workflow which are waiting an action for the user. - * - * @Route("/api/1.0/main/workflow/my-cc", methods={"GET"}) */ + #[Route(path: '/api/1.0/main/workflow/my-cc', methods: ['GET'])] public function myWorkflowCc(Request $request): JsonResponse { if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { @@ -109,17 +107,13 @@ class WorkflowApiController ); } - /** - * @Route("/api/1.0/main/workflow/{id}/subscribe", methods={"POST"}) - */ + #[Route(path: '/api/1.0/main/workflow/{id}/subscribe', methods: ['POST'])] public function subscribe(EntityWorkflow $entityWorkflow, Request $request): Response { return $this->handleSubscription($entityWorkflow, $request, 'subscribe'); } - /** - * @Route("/api/1.0/main/workflow/{id}/unsubscribe", methods={"POST"}) - */ + #[Route(path: '/api/1.0/main/workflow/{id}/unsubscribe', methods: ['POST'])] public function unsubscribe(EntityWorkflow $entityWorkflow, Request $request): Response { return $this->handleSubscription($entityWorkflow, $request, 'unsubscribe'); diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index b19f03c3b..d75e42012 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -40,9 +40,7 @@ class WorkflowController extends AbstractController { public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @Route("/{_locale}/main/workflow/create", name="chill_main_workflow_create") - */ + #[Route(path: '/{_locale}/main/workflow/create', name: 'chill_main_workflow_create')] public function create(Request $request): Response { if (!$request->query->has('entityClass')) { @@ -86,9 +84,7 @@ class WorkflowController extends AbstractController return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]); } - /** - * @Route("/{_locale}/main/workflow/{id}/delete", name="chill_main_workflow_delete") - */ + #[Route(path: '/{_locale}/main/workflow/{id}/delete', name: 'chill_main_workflow_delete')] public function delete(EntityWorkflow $entityWorkflow, Request $request): Response { $this->denyAccessUnlessGranted(EntityWorkflowVoter::DELETE, $entityWorkflow); @@ -113,9 +109,7 @@ class WorkflowController extends AbstractController ]); } - /** - * @Route("/{_locale}/main/workflow-step/{id}/access_key", name="chill_main_workflow_grant_access_by_key") - */ + #[Route(path: '/{_locale}/main/workflow-step/{id}/access_key', name: 'chill_main_workflow_grant_access_by_key')] public function getAccessByAccessKey(EntityWorkflowStep $entityWorkflowStep, Request $request): Response { if (null === $accessKey = $request->query->get('accessKey', null)) { @@ -143,9 +137,8 @@ class WorkflowController extends AbstractController /** * Previous workflows where the user has applyed a transition. - * - * @Route("/{_locale}/main/workflow/list/previous_transitionned", name="chill_main_workflow_list_previous_transitionned") */ + #[Route(path: '/{_locale}/main/workflow/list/previous_transitionned', name: 'chill_main_workflow_list_previous_transitionned')] public function myPreviousWorkflowsTransitionned(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -173,9 +166,8 @@ class WorkflowController extends AbstractController /** * Previous workflows where the user was mentioned, but did not give any reaction. - * - * @Route("/{_locale}/main/workflow/list/previous_without_reaction", name="chill_main_workflow_list_previous_without_reaction") */ + #[Route(path: '/{_locale}/main/workflow/list/previous_without_reaction', name: 'chill_main_workflow_list_previous_without_reaction')] public function myPreviousWorkflowsWithoutReaction(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -201,9 +193,7 @@ class WorkflowController extends AbstractController ); } - /** - * @Route("/{_locale}/main/workflow/list/cc", name="chill_main_workflow_list_cc") - */ + #[Route(path: '/{_locale}/main/workflow/list/cc', name: 'chill_main_workflow_list_cc')] public function myWorkflowsCc(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -228,9 +218,7 @@ class WorkflowController extends AbstractController ); } - /** - * @Route("/{_locale}/main/workflow/list/dest", name="chill_main_workflow_list_dest") - */ + #[Route(path: '/{_locale}/main/workflow/list/dest', name: 'chill_main_workflow_list_dest')] public function myWorkflowsDest(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -255,9 +243,7 @@ class WorkflowController extends AbstractController ); } - /** - * @Route("/{_locale}/main/workflow/list/subscribed", name="chill_main_workflow_list_subscribed") - */ + #[Route(path: '/{_locale}/main/workflow/list/subscribed', name: 'chill_main_workflow_list_subscribed')] public function myWorkflowsSubscribed(Request $request): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); @@ -282,9 +268,7 @@ class WorkflowController extends AbstractController ); } - /** - * @Route("/{_locale}/main/workflow/{id}/show", name="chill_main_workflow_show") - */ + #[Route(path: '/{_locale}/main/workflow/{id}/show', name: 'chill_main_workflow_show')] public function show(EntityWorkflow $entityWorkflow, Request $request): Response { $this->denyAccessUnlessGranted(EntityWorkflowVoter::SEE, $entityWorkflow); diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php index 8cb335fba..1c99a3a74 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php @@ -18,7 +18,6 @@ use Doctrine\Persistence\ObjectManager; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactory; -use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; /** * Load fixtures users into database. @@ -65,7 +64,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde foreach (self::$refs as $username => $params) { $user = new User(); - $defaultEncoder = new MessageDigestPasswordEncoder('sha512', true, 5000); + $defaultEncoder = new \Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher('sha512', true, 5000); $encoderFactory = new EncoderFactory([ User::class => $defaultEncoder, diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php index 29f1c2f43..71c8dc504 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php @@ -20,18 +20,16 @@ trait TrackCreationTrait { /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateTimeImmutable $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?User $createdBy = null; public function getCreatedAt(): ?\DateTimeInterface diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php index 8a3f98972..c48a287d6 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php @@ -20,18 +20,16 @@ trait TrackUpdateTrait { /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?User $updatedBy = null; public function getUpdatedAt(): ?\DateTimeInterface diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index f6584fddd..b98f27b1a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -57,60 +57,52 @@ class Address implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=AddressReference::class) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private ?AddressReference $addressReference = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $buildingName = ''; /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private bool $confidential = false; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $corridor = ''; /** * used for the CEDEX information. * * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $distribution = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $extra = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $flat = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $floor = ''; /** @@ -140,19 +132,17 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * * @ORM\GeneratedValue(strategy="AUTO") * - * @Groups({"write"}) - * * @readonly */ + #[Groups(['write'])] private ?int $id = null; /** * True if the address is a "no address", aka homeless person, ... * - * @Groups({"write"}) - * * @ORM\Column(type="boolean", options={"default": false}) */ + #[Groups(['write'])] private bool $isNoAddress = false; /** @@ -160,28 +150,25 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * - * @Groups({"write"}) - * * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") */ + #[Groups(['write'])] private ?ThirdParty $linkedToThirdParty = null; /** * A geospatial field storing the coordinates of the Address. * * @ORM\Column(type="point", nullable=true) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private ?Point $point = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") * * @ORM\JoinColumn(nullable=false) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private ?PostalCode $postcode = null; /** @@ -198,23 +185,20 @@ class Address implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $steps = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $street = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $streetNumber = ''; /** @@ -222,9 +206,8 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * of address. By default, the current date. * * @ORM\Column(type="date") - * - * @Groups({"write"}) */ + #[Groups(['write'])] private \DateTime $validFrom; /** @@ -232,9 +215,8 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * of address. * * @ORM\Column(type="date", nullable=true) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private ?\DateTime $validTo = null; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 49b510f8c..84c8aa2b6 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -42,16 +42,14 @@ class AddressReference /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeImmutable $createdAt = null; /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeImmutable $deletedAt = null; /** @@ -60,67 +58,58 @@ class AddressReference * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?int $id = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) */ + #[Groups(['read'])] private string $municipalityCode = ''; /** * A geospatial field storing the coordinates of the Address. * * @ORM\Column(type="point") - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?Point $point = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?PostalCode $postcode = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) */ + #[Groups(['read'])] private string $refId = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) */ + #[Groups(['read'])] private string $source = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) */ + #[Groups(['read'])] private string $street = ''; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) */ + #[Groups(['read'])] private string $streetNumber = ''; /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeImmutable $updatedAt = null; public function getCreatedAt(): ?\DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Entity/Center.php b/src/Bundle/ChillMainBundle/Entity/Center.php index b81200bdb..20c8e3767 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -39,16 +39,14 @@ class Center implements HasCenterInterface, \Stringable * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="string", length=255) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private string $name = ''; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 322155fe5..fa1accae8 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -18,25 +18,22 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Table(name="chill_main_civility") * * @ORM\Entity - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={"chill_main_civility": Civility::class}) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_main_civility' => Civility::class])] class Civility { /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $abbreviation = []; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $active = true; /** @@ -45,18 +42,16 @@ class Civility * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $name = []; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Country.php b/src/Bundle/ChillMainBundle/Entity/Country.php index 91484ba46..7ed4dc576 100644 --- a/src/Bundle/ChillMainBundle/Entity/Country.php +++ b/src/Bundle/ChillMainBundle/Entity/Country.php @@ -31,10 +31,9 @@ class Country /** * @ORM\Column(type="string", length=3) * - * @groups({"read", "docgen:read"}) - * * @Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private string $countryCode = ''; /** @@ -43,9 +42,8 @@ class Country * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -53,10 +51,9 @@ class Country * * @ORM\Column(type="json") * - * @groups({"read", "docgen:read"}) - * * @Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private array $name = []; public function getCountryCode(): string diff --git a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php index ed9cc07bf..03662b5ff 100644 --- a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php +++ b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php @@ -28,27 +28,22 @@ class DashboardConfigItem * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] private ?int $id = null; /** * @ORM\Column(type="string") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) - * - * @Assert\NotNull */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] + #[Assert\NotNull] private string $type = ''; /** * @ORM\Column(type="string") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) - * - * @Assert\NotNull */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] + #[Assert\NotNull] private string $position = ''; /** @@ -58,9 +53,8 @@ class DashboardConfigItem /** * @ORM\Column(type="json", options={"default": "[]", "jsonb": true}) - * - * @Serializer\Groups({"dashboardConfigItem:read"}) */ + #[Serializer\Groups(['dashboardConfigItem:read'])] private array $metadata = []; public function getId(): ?int diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php index 79e28e6f3..196b5140a 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php @@ -25,33 +25,29 @@ class SimpleGeographicalUnitDTO * @readonly * * @psalm-readonly - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] public int $id, /** * @readonly * * @psalm-readonly - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] public string $unitName, /** * @readonly * * @psalm-readonly - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] public string $unitRefId, /** * @readonly * * @psalm-readonly - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] public int $layerId ) {} } diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php index c875fecd4..7129de879 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php @@ -32,23 +32,20 @@ class GeographicalUnitLayer * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?int $id = null; /** * @ORM\Column(type="json", nullable=false, options={"default": "[]"}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private array $name = []; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private string $refId = ''; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Language.php b/src/Bundle/ChillMainBundle/Entity/Language.php index 1a91de7b8..b6e42d7d8 100644 --- a/src/Bundle/ChillMainBundle/Entity/Language.php +++ b/src/Bundle/ChillMainBundle/Entity/Language.php @@ -31,9 +31,8 @@ class Language * @ORM\Id * * @ORM\Column(type="string") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?string $id = null; /** @@ -41,10 +40,9 @@ class Language * * @ORM\Column(type="json") * - * @Serializer\Groups({"docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private array $name = []; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index 29a049d35..92a2b43b7 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -24,55 +24,46 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * @ORM\Table(name="chill_main_location") * * @ORM\Entity(repositoryClass=LocationRepository::class) - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "location": Location::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['location' => Location::class])] class Location implements TrackCreationInterface, TrackUpdateInterface { /** * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $active = true; /** * @ORM\ManyToOne(targetEntity=Address::class, cascade={"persist"}) * * @ORM\JoinColumn(nullable=true) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?Address $address = null; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $availableForUsers = false; /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateTimeImmutable $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?User $createdBy = null; /** * @ORM\Column(type="string", length=255, nullable=true) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?string $email = null; /** @@ -81,57 +72,50 @@ class Location implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=LocationType::class) * * @ORM\JoinColumn(nullable=false) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?LocationType $locationType = null; /** * @ORM\Column(type="string", length=255, nullable=true) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?string $name = null; /** * @ORM\Column(type="phone_number", nullable=true) * - * @Serializer\Groups({"read", "write", "docgen:read"}) - * * @PhonenumberConstraint(type="any") */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?PhoneNumber $phonenumber1 = null; /** * @ORM\Column(type="phone_number", nullable=true) * - * @Serializer\Groups({"read", "write", "docgen:read"}) - * * @PhonenumberConstraint(type="any") */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] private ?PhoneNumber $phonenumber2 = null; /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?User $updatedBy = null; public function getActive(): ?bool diff --git a/src/Bundle/ChillMainBundle/Entity/LocationType.php b/src/Bundle/ChillMainBundle/Entity/LocationType.php index c6a176ab6..54e876d2d 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -21,13 +21,9 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * @ORM\Table(name="chill_main_location_type") * * @ORM\Entity(repositoryClass=LocationTypeRepository::class) - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "location-type": LocationType::class - * }) - * - * @UniqueEntity({"defaultFor"}) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['location-type' => LocationType::class])] +#[UniqueEntity(['defaultFor'])] class LocationType { final public const DEFAULT_FOR_3PARTY = 'thirdparty'; @@ -42,44 +38,38 @@ class LocationType /** * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $active = true; /** * @ORM\Column(type="string", length=32, options={"default": "optional"}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private string $addressRequired = self::STATUS_OPTIONAL; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $availableForUsers = true; /** * @ORM\Column(type="string", length=32, options={"default": "optional"}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private string $contactData = self::STATUS_OPTIONAL; /** * @ORM\Column(type="string", nullable=true, length=32, unique=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?string $defaultFor = null; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $editableByUsers = true; /** @@ -88,18 +78,16 @@ class LocationType * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $title = []; public function getActive(): ?bool diff --git a/src/Bundle/ChillMainBundle/Entity/NewsItem.php b/src/Bundle/ChillMainBundle/Entity/NewsItem.php index 604c58c5f..1aa2d83a1 100644 --- a/src/Bundle/ChillMainBundle/Entity/NewsItem.php +++ b/src/Bundle/ChillMainBundle/Entity/NewsItem.php @@ -36,49 +36,38 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?int $id = null; /** * @ORM\Column(type="text") - * - * @Groups({"read"}) - * - * @Assert\NotBlank - * - * @Assert\NotNull */ + #[Groups(['read'])] + #[Assert\NotBlank] + #[Assert\NotNull] private string $title = ''; /** * @ORM\Column(type="text") - * - * @Groups({"read"}) - * - * @Assert\NotBlank - * - * @Assert\NotNull */ + #[Groups(['read'])] + #[Assert\NotBlank] + #[Assert\NotNull] private string $content = ''; /** * @ORM\Column(type="date_immutable", nullable=false) - * - * @Assert\NotNull - * - * @Groups({"read"}) */ + #[Assert\NotNull] + #[Groups(['read'])] private ?\DateTimeImmutable $startDate = null; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Assert\GreaterThanOrEqual(propertyPath="startDate") - * - * @Groups({"read"}) */ + #[Assert\GreaterThanOrEqual(propertyPath: 'startDate')] + #[Groups(['read'])] private ?\DateTimeImmutable $endDate = null; public function getTitle(): string diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index 8604b5ee1..52dd6aba1 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -116,9 +116,8 @@ class Notification implements TrackUpdateInterface /** * @ORM\Column(type="text", options={"default": ""}) - * - * @Assert\NotBlank(message="notification.Title must be defined") */ + #[Assert\NotBlank(message: 'notification.Title must be defined')] private string $title = ''; /** @@ -187,10 +186,9 @@ class Notification implements TrackUpdateInterface } /** - * @Assert\Callback - * * @param array $payload */ + #[Assert\Callback] public function assertCountAddresses(ExecutionContextInterface $context, $payload): void { if (0 === (\count($this->getAddressesEmails()) + \count($this->getAddressees()))) { diff --git a/src/Bundle/ChillMainBundle/Entity/NotificationComment.php b/src/Bundle/ChillMainBundle/Entity/NotificationComment.php index 49d1e859d..3e23a7ceb 100644 --- a/src/Bundle/ChillMainBundle/Entity/NotificationComment.php +++ b/src/Bundle/ChillMainBundle/Entity/NotificationComment.php @@ -29,9 +29,8 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac { /** * @ORM\Column(type="text") - * - * @Assert\NotBlank(message="notification.Comment content might not be blank") */ + #[Assert\NotBlank(message: 'notification.Comment content might not be blank')] private string $content = ''; /** diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 4d906d6c8..fee552c6b 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -56,23 +56,20 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface /** * @ORM\Column(type="point", nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?Point $center = null; /** * @ORM\Column(type="string", length=100) - * - * @groups({"write", "read"}) */ + #[Groups(['write', 'read'])] private ?string $code = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country") - * - * @groups({"write", "read"}) */ + #[Groups(['write', 'read'])] private ?Country $country = null; /** @@ -86,37 +83,32 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @groups({"write", "read"}) */ + #[Groups(['write', 'read'])] private ?int $id = null; /** * @ORM\Column(type="string", length=255, name="label") - * - * @groups({"write", "read"}) */ + #[Groups(['write', 'read'])] private ?string $name = null; /** * @ORM\Column(name="origin", type="integer", nullable=true) - * - * @groups({"write", "read"}) */ + #[Groups(['write', 'read'])] private int $origin = 0; /** * @ORM\Column(type="string", length=255, nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?string $postalCodeSource = null; /** * @ORM\Column(type="string", length=255, nullable=true) - * - * @groups({"read"}) */ + #[Groups(['read'])] private ?string $refPostalCodeId = null; public function getCenter(): ?Point diff --git a/src/Bundle/ChillMainBundle/Entity/SavedExport.php b/src/Bundle/ChillMainBundle/Entity/SavedExport.php index 224423783..b9b27c39b 100644 --- a/src/Bundle/ChillMainBundle/Entity/SavedExport.php +++ b/src/Bundle/ChillMainBundle/Entity/SavedExport.php @@ -33,9 +33,8 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Assert\NotBlank */ + #[Assert\NotBlank] private string $description = ''; /** @@ -59,9 +58,8 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Assert\NotBlank */ + #[Assert\NotBlank] private string $title = ''; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Scope.php b/src/Bundle/ChillMainBundle/Entity/Scope.php index 464d60488..4a21c66d7 100644 --- a/src/Bundle/ChillMainBundle/Entity/Scope.php +++ b/src/Bundle/ChillMainBundle/Entity/Scope.php @@ -24,11 +24,8 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\Table(name="scopes") * * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "scope": Scope::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['scope' => Scope::class])] class Scope { /** @@ -42,9 +39,8 @@ class Scope * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -52,10 +48,9 @@ class Scope * * @ORM\Column(type="json") * - * @Groups({"read", "docgen:read"}) - * * @Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private array $name = []; /** diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 4ea96bb2d..b9af72fd0 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -33,11 +33,8 @@ use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint; * @ORM\Table(name="users") * * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "user": User::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['user' => User::class])] class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInterface { /** diff --git a/src/Bundle/ChillMainBundle/Entity/UserJob.php b/src/Bundle/ChillMainBundle/Entity/UserJob.php index 6be1a5efe..d071d2adc 100644 --- a/src/Bundle/ChillMainBundle/Entity/UserJob.php +++ b/src/Bundle/ChillMainBundle/Entity/UserJob.php @@ -18,11 +18,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table("chill_main_user_job") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "user_job": UserJob::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['user_job' => UserJob::class])] class UserJob { /** @@ -36,9 +33,8 @@ class UserJob * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] protected ?int $id = null; /** @@ -46,10 +42,9 @@ class UserJob * * @ORM\Column(name="label", type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] protected array $label = []; public function getId(): ?int diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index e26547428..6e2824b88 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -29,11 +29,8 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Table("chill_main_workflow_entity") * * @EntityWorkflowCreation(groups={"creation"}) - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "entity_workflow": EntityWorkflow::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['entity_workflow' => EntityWorkflow::class])] class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -100,10 +97,9 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface * * @ORM\OrderBy({"transitionAt": "ASC", "id": "ASC"}) * - * @Assert\Valid(traverse=true) - * * @var Collection */ + #[Assert\Valid(traverse: true)] private Collection $steps; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index 53e4ad945..509390fac 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -413,9 +413,7 @@ class EntityWorkflowStep return $this; } - /** - * @Assert\Callback - */ + #[Assert\Callback] public function validateOnCreation(ExecutionContextInterface $context, mixed $payload): void { return; diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php index 8db31c0b1..a4cab4a9b 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php @@ -28,7 +28,7 @@ class AddressDataMapper implements DataMapperInterface * @param Address $address * @param \Iterator $forms */ - public function mapDataToForms($address, iterable $forms) + public function mapDataToForms($address, \Traversable $forms) { if (null === $address) { return; @@ -78,7 +78,7 @@ class AddressDataMapper implements DataMapperInterface * @param \Iterator $forms * @param Address $address */ - public function mapFormsToData(iterable $forms, &$address) + public function mapFormsToData(\Traversable $forms, &$address) { if (!$address instanceof Address) { $address = new Address(); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 495c5d221..2a19c8e0b 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\FormInterface; final readonly class ExportPickCenterDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, iterable $forms): void + public function mapDataToForms($viewData, \Traversable $forms): void { if (null === $viewData) { return; @@ -31,7 +31,7 @@ final readonly class ExportPickCenterDataMapper implements DataMapperInterface // NOTE: we do not map back the regroupments } - public function mapFormsToData(iterable $forms, &$viewData): void + public function mapFormsToData(\Traversable $forms, &$viewData): void { /** @var array $forms */ $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php index 4f6022afe..3f1284db8 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php @@ -21,7 +21,7 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI { public function __construct(private readonly Security $security) {} - public function mapDataToForms($viewData, iterable $forms) + public function mapDataToForms($viewData, \Traversable $forms) { if (null === $viewData) { return null; @@ -36,7 +36,7 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI $forms['comments']->setData($viewData->getCommentForUser($this->security->getUser())); } - public function mapFormsToData(iterable $forms, &$viewData) + public function mapFormsToData(\Traversable $forms, &$viewData) { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php index 99dd4b053..254860e64 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/RollingDateDataMapper.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\Exception; class RollingDateDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, iterable $forms) + public function mapDataToForms($viewData, \Traversable $forms) { if (null === $viewData) { return; @@ -33,7 +33,7 @@ class RollingDateDataMapper implements DataMapperInterface $forms['fixedDate']->setData($viewData->getFixedDate()); } - public function mapFormsToData(iterable $forms, &$viewData): void + public function mapFormsToData(\Traversable $forms, &$viewData): void { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php index ef040d16b..d6a0cea20 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php @@ -18,7 +18,7 @@ class ScopePickerDataMapper implements DataMapperInterface { public function __construct(private readonly ?Scope $scope = null) {} - public function mapDataToForms($data, iterable $forms) + public function mapDataToForms($data, \Traversable $forms) { $forms = iterator_to_array($forms); @@ -37,7 +37,7 @@ class ScopePickerDataMapper implements DataMapperInterface } } - public function mapFormsToData(iterable $forms, &$data) + public function mapFormsToData(\Traversable $forms, &$data) { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/UserPasswordType.php b/src/Bundle/ChillMainBundle/Form/UserPasswordType.php index 8a5dc01fd..b3ae403a3 100644 --- a/src/Bundle/ChillMainBundle/Form/UserPasswordType.php +++ b/src/Bundle/ChillMainBundle/Form/UserPasswordType.php @@ -17,7 +17,6 @@ use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; @@ -32,12 +31,12 @@ class UserPasswordType extends AbstractType protected $chillLogger; /** - * @var UserPasswordEncoderInterface + * @var \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface */ protected $passwordEncoder; public function __construct( - UserPasswordEncoderInterface $passwordEncoder, + \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, LoggerInterface $chillLogger ) { $this->passwordEncoder = $passwordEncoder; diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php index 14f448746..9d6a0f948 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php @@ -19,17 +19,13 @@ class SearchApiResult public function __construct(private readonly float $relevance) {} - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public function getRelevance(): float { return $this->relevance; } - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public function getResult() { return $this->result; diff --git a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php index c624c6a99..a561fe0bc 100644 --- a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php +++ b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\User; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\NoResultException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; @@ -36,7 +35,7 @@ class UserProvider implements UserProviderInterface ->setParameter('pattern', $username) ->getSingleResult(); } catch (NoResultException $e) { - throw new UsernameNotFoundException('Bad credentials.', 0, $e); + throw new \Symfony\Component\Security\Core\Exception\UserNotFoundException('Bad credentials.', 0, $e); } return $user; @@ -51,7 +50,7 @@ class UserProvider implements UserProviderInterface $reloadedUser = $this->em->getRepository(User::class)->find($user->getId()); if (null === $reloadedUser) { - throw new UsernameNotFoundException(sprintf('User with ID "%s" could not be reloaded.', $user->getId())); + throw new \Symfony\Component\Security\Core\Exception\UserNotFoundException(sprintf('User with ID "%s" could not be reloaded.', $user->getId())); } return $reloadedUser; diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php index 4108566ad..8699aded5 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Test\PrepareClientTrait; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; /** * @internal @@ -34,7 +33,7 @@ final class UserControllerTest extends WebTestCase $user = new User(); $user->setUsername('Test_user '.uniqid()); - $user->setPassword(self::getContainer()->get(UserPasswordEncoderInterface::class)->encodePassword( + $user->setPassword(self::getContainer()->get(\Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface::class)->encodePassword( $user, 'password' )); @@ -138,9 +137,9 @@ final class UserControllerTest extends WebTestCase protected function isPasswordValid($username, $password) { - /** @var \Symfony\Component\Security\Core\Encoder\UserPasswordEncoder $passwordEncoder */ + /** @var \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher $passwordEncoder */ $passwordEncoder = self::getContainer() - ->get(UserPasswordEncoderInterface::class); + ->get(\Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface::class); $user = self::getContainer()->get(UserRepositoryInterface::class) ->findOneBy(['username' => $username]); diff --git a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php index fd86aefbf..6472a48f5 100644 --- a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php @@ -23,6 +23,8 @@ use Symfony\Component\Console\Output\OutputInterface; final class ChillPersonMoveCommand extends Command { + protected static $defaultDescription = 'Move all the associated entities on a "from" person to a "to" person and remove the old person'; + public function __construct( private readonly PersonMove $mover, private readonly EntityManagerInterface $em, @@ -53,7 +55,6 @@ final class ChillPersonMoveCommand extends Command { $this ->setName('chill:person:move') - ->setDescription('Move all the associated entities on a "from" person to a "to" person and remove the old person') ->addOption('from', 'f', InputOption::VALUE_REQUIRED, 'The person id to delete, all associated data will be moved before') ->addOption('to', 't', InputOption::VALUE_REQUIRED, 'The person id which will received data') ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'dump sql to stdout') @@ -99,7 +100,7 @@ final class ChillPersonMoveCommand extends Command $this->chillLogger->notice('Move a person from command line succeeded', $ctxt); } - return 0; + return Command::SUCCESS; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php index 6c85548dd..6aab04389 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php @@ -41,7 +41,6 @@ final class ImportSocialWorkMetadata extends Command ->setName('chill:person:import-socialwork') ->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.') ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language') - ->setDescription($description) ->setHelp($help); } diff --git a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php index f826c4d17..43a74a5e1 100644 --- a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php @@ -20,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface; class RemoveOldDraftAccompanyingPeriodCommand extends Command { + protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused'; + public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover) { parent::__construct('chill:person:remove-old-draft-period'); @@ -28,7 +30,6 @@ class RemoveOldDraftAccompanyingPeriodCommand extends Command protected function configure(): void { $this - ->setDescription('Remove draft accompanying period which are still draft and unused') ->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D'); } @@ -50,6 +51,6 @@ class RemoveOldDraftAccompanyingPeriodCommand extends Command $this->logger->info('['.$this->getName().'] end of command'); - return 0; + return Command::SUCCESS; } } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 6caa6be4c..262a4a03d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -79,9 +79,7 @@ final class AccompanyingCourseApiController extends ApiController ]); } - /** - * @Route("/api/1.0/person/accompanying-course/list/by-recent-attributions") - */ + #[Route(path: '/api/1.0/person/accompanying-course/list/by-recent-attributions')] public function findMyRecentCourseAttribution(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_USER'); @@ -247,11 +245,7 @@ final class AccompanyingCourseApiController extends ApiController return $this->addRemoveSomething('socialissue', $id, $request, $_format, 'socialIssue', SocialIssue::class, ['groups' => ['read']]); } - /** - * @Route("/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}", - * requirements={ "_format": "json"}, - * name="chill_api_person_accompanying_period_referrers_suggested") - */ + #[Route(path: '/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}', requirements: ['_format' => 'json'], name: 'chill_api_person_accompanying_period_referrers_suggested')] public function suggestReferrals(AccompanyingPeriod $period, string $_format = 'json'): JsonResponse { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $period); @@ -278,10 +272,9 @@ final class AccompanyingCourseApiController extends ApiController } /** - * @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential") - * * @ParamConverter("accompanyingCourse", options={"id": "id"}) */ + #[Route(path: '/api/1.0/person/accompanying-course/{id}/confidential.json', name: 'chill_api_person_accompanying_period_confidential')] public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, mixed $id, Request $request) { if ('POST' === $request->getMethod()) { @@ -296,10 +289,9 @@ final class AccompanyingCourseApiController extends ApiController } /** - * @Route("/api/1.0/person/accompanying-course/{id}/intensity.json", name="chill_api_person_accompanying_period_intensity") - * * @ParamConverter("accompanyingCourse", options={"id": "id"}) */ + #[Route(path: '/api/1.0/person/accompanying-course/{id}/intensity.json', name: 'chill_api_person_accompanying_period_intensity')] public function toggleIntensityApi(AccompanyingPeriod $accompanyingCourse, Request $request) { if ('POST' === $request->getMethod()) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index d4a78fc18..f7622953d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -41,10 +41,9 @@ class AccompanyingCourseCommentController extends AbstractController /** * Page of comments in Accompanying Course section. * - * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/comments', name: 'chill_person_accompanying_period_comment_list')] public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE_DETAILS, $accompanyingCourse); @@ -118,12 +117,8 @@ class AccompanyingCourseCommentController extends AbstractController /** * Delete an existing comment. - * - * @Route( - * "/{_locale}/parcours/comment/{id}/delete", - * name="chill_person_accompanying_period_comment_delete" - * ) */ + #[Route(path: '/{_locale}/parcours/comment/{id}/delete', name: 'chill_person_accompanying_period_comment_delete')] public function deleteAction(AccompanyingPeriod\Comment $comment, Request $request): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::DELETE, $comment); @@ -159,9 +154,7 @@ class AccompanyingCourseCommentController extends AbstractController ]); } - /** - * @Route("/{_locale}/parcours/comment/{id}/pin", name="chill_person_accompanying_period_comment_pin") - */ + #[Route(path: '/{_locale}/parcours/comment/{id}/pin', name: 'chill_person_accompanying_period_comment_pin')] public function pinComment(AccompanyingPeriod\Comment $comment): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod()); @@ -177,9 +170,7 @@ class AccompanyingCourseCommentController extends AbstractController ]); } - /** - * @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin") - */ + #[Route(path: '/{_locale}/parcours/comment/{id}/unpin', name: 'chill_person_accompanying_period_comment_unpin')] public function unpinComment(AccompanyingPeriod\Comment $comment): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod()); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 972ed2dd0..1b2362533 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -15,7 +15,6 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Household\Household; -use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Repository\PersonRepository; @@ -50,10 +49,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle ) {} /** - * @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/close', name: 'chill_person_accompanying_course_close')] public function closeAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); @@ -97,10 +95,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle /** * Delete page of Accompanying Course section. * - * @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/delete', name: 'chill_person_accompanying_course_delete')] public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse) { $em = $this->managerRegistry->getManager(); @@ -154,10 +151,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle * * the page edit all blocks managed by vuejs component * - * @Route("/{_locale}/parcours/{accompanying_period_id}/edit", name="chill_person_accompanying_course_edit") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/edit', name: 'chill_person_accompanying_course_edit')] public function editAction(AccompanyingPeriod $accompanyingCourse): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); @@ -172,10 +168,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle * * the page show anti chronologic history with all actions, title of page is 'Accompanying Course History' * - * @Route("/{_locale}/parcours/{accompanying_period_id}/history", name="chill_person_accompanying_course_history") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/history', name: 'chill_person_accompanying_course_history')] public function historyAction(AccompanyingPeriod $accompanyingCourse): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); @@ -188,10 +183,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle /** * Homepage of Accompanying Course section. * - * @Route("/{_locale}/parcours/{accompanying_period_id}", name="chill_person_accompanying_course_index") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}', name: 'chill_person_accompanying_course_index')] public function indexAction(AccompanyingPeriod $accompanyingCourse): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); @@ -228,9 +222,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle ]); } - /** - * @Route("/{_locale}/person/parcours/new", name="chill_person_accompanying_course_new") - */ + #[Route(path: '/{_locale}/person/parcours/new', name: 'chill_person_accompanying_course_new')] public function newAction(Request $request): Response { $user = $this->security->getUser(); @@ -268,9 +260,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle ]); } - /** - * @Route("/{_locale}/person/household/parcours/new", name="chill_household_accompanying_course_new") - */ + #[Route(path: '/{_locale}/person/household/parcours/new', name: 'chill_household_accompanying_course_new')] public function newHouseholdParcoursAction(Request $request): Response { $user = $this->getUser(); @@ -308,10 +298,9 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle } /** - * @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen") - * * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ + #[Route(path: '/{_locale}/parcours/{accompanying_period_id}/open', name: 'chill_person_accompanying_course_reopen')] public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php index 9999257a3..98467a302 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php @@ -29,9 +29,7 @@ class AccompanyingCourseWorkApiController extends ApiController private readonly Security $security, ) {} - /** - * @Route("/api/1.0/person/accompanying-period/work/my-near-end") - */ + #[Route(path: '/api/1.0/person/accompanying-period/work/my-near-end')] public function myWorksNearEndDate(Request $request): JsonResponse { $user = $this->security->getUser(); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 591742ee9..fb5b3066c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; -use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; @@ -44,13 +43,7 @@ final class AccompanyingCourseWorkController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry ) {} - /** - * @Route( - * "{_locale}/person/accompanying-period/{id}/work/new", - * name="chill_person_accompanying_period_work_new", - * methods={"GET"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/{id}/work/new', name: 'chill_person_accompanying_period_work_new', methods: ['GET'])] public function createWork(AccompanyingPeriod $period): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::CREATE, $period); @@ -77,13 +70,7 @@ final class AccompanyingCourseWorkController extends AbstractController ]); } - /** - * @Route( - * "{_locale}/person/accompanying-period/work/{id}/delete", - * name="chill_person_accompanying_period_work_delete", - * methods={"GET", "POST", "DELETE"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/work/{id}/delete', name: 'chill_person_accompanying_period_work_delete', methods: ['GET', 'POST', 'DELETE'])] public function deleteWork(AccompanyingPeriodWork $work, Request $request): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::UPDATE, $work); @@ -123,13 +110,7 @@ final class AccompanyingCourseWorkController extends AbstractController ]); } - /** - * @Route( - * "{_locale}/person/accompanying-period/work/{id}/edit", - * name="chill_person_accompanying_period_work_edit", - * methods={"GET"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/work/{id}/edit', name: 'chill_person_accompanying_period_work_edit', methods: ['GET'])] public function editWork(AccompanyingPeriodWork $work): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::UPDATE, $work); @@ -143,13 +124,7 @@ final class AccompanyingCourseWorkController extends AbstractController ]); } - /** - * @Route( - * "{_locale}/person/accompanying-period/{id}/work", - * name="chill_person_accompanying_period_work_list", - * methods={"GET"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/{id}/work', name: 'chill_person_accompanying_period_work_list', methods: ['GET'])] public function listWorkByAccompanyingPeriod(AccompanyingPeriod $period): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period); @@ -181,13 +156,7 @@ final class AccompanyingCourseWorkController extends AbstractController ]); } - /** - * @Route( - * "{_locale}/person/accompanying-period/work/{id}/show", - * name="chill_person_accompanying_period_work_show", - * methods={"GET"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/work/{id}/show', name: 'chill_person_accompanying_period_work_show', methods: ['GET'])] public function showWork(AccompanyingPeriodWork $work): Response { if (null === $work) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkEvaluationDocumentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkEvaluationDocumentController.php index 21378b9d7..677040484 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkEvaluationDocumentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkEvaluationDocumentController.php @@ -22,13 +22,7 @@ class AccompanyingCourseWorkEvaluationDocumentController extends AbstractControl { public function __construct(private readonly Security $security) {} - /** - * @Route( - * "{_locale}/person/accompanying-period/work/evaluation/document/{id}/show", - * name="chill_person_accompanying_period_work_evaluation_document_show", - * methods={"GET"} - * ) - */ + #[Route(path: '{_locale}/person/accompanying-period/work/evaluation/document/{id}/show', name: 'chill_person_accompanying_period_work_evaluation_document_show', methods: ['GET'])] public function showAccompanyingCourseWork(AccompanyingPeriodWorkEvaluationDocument $document): Response { $work = $document->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork(); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index ed86f02e5..7c18ab8a3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -44,9 +44,8 @@ class AccompanyingPeriodController extends AbstractController /** * @throws \Exception - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/close", name="chill_person_accompanying_period_close") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/close', name: 'chill_person_accompanying_period_close')] public function closeAction(int $person_id, Request $request): Response { $person = $this->_getPerson($person_id); @@ -123,9 +122,7 @@ class AccompanyingPeriodController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/create", name="chill_person_accompanying_period_create") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/create', name: 'chill_person_accompanying_period_create')] public function createAction(int $person_id, Request $request): Response { $person = $this->_getPerson($person_id); @@ -190,10 +187,9 @@ class AccompanyingPeriodController extends AbstractController } /** - * @ParamConverter("person", options={"id": "person_id"}) - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period", name="chill_person_accompanying_period_list") + * @ParamConverter("person", options={"id"="person_id"}) */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period', name: 'chill_person_accompanying_period_list')] public function listAction(Person $person): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $person); @@ -218,9 +214,7 @@ class AccompanyingPeriodController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/open", name="chill_person_accompanying_period_open") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/open', name: 'chill_person_accompanying_period_open')] public function openAction(int $person_id, Request $request): Response { $person = $this->_getPerson($person_id); @@ -303,9 +297,7 @@ class AccompanyingPeriodController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open", name="chill_person_accompanying_period_re_open") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open', name: 'chill_person_accompanying_period_re_open')] public function reOpenAction(int $person_id, int $period_id, Request $request): Response { /** @var Person $person */ @@ -353,9 +345,8 @@ class AccompanyingPeriodController extends AbstractController /** * @throws Exception - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/{period_id}/update", name="chill_person_accompanying_period_update") */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/{period_id}/update', name: 'chill_person_accompanying_period_update')] public function updateAction(int $person_id, int $period_id, Request $request): Response { $em = $this->managerRegistry->getManager(); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index f5516114f..a3ce3ef13 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -33,9 +33,7 @@ class AccompanyingPeriodRegulationListController { public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) {} - /** - * @Route("/{_locale}/person/periods/undispatched", name="chill_person_course_list_regulation") - */ + #[Route(path: '/{_locale}/person/periods/undispatched', name: 'chill_person_course_list_regulation')] public function listRegul(Request $request): Response { if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php index 60b8e9cff..1be5543d1 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php @@ -31,10 +31,7 @@ class AccompanyingPeriodWorkEvaluationApiController { public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security) {} - /** - * @Route("/api/1.0/person/docgen/template/by-evaluation/{id}.{_format}", - * requirements={"format": "json"}) - */ + #[Route(path: '/api/1.0/person/docgen/template/by-evaluation/{id}.{_format}', requirements: ['format' => 'json'])] public function listTemplateByEvaluation(Evaluation $evaluation, string $_format): JsonResponse { if ('json' !== $_format) { @@ -64,9 +61,7 @@ class AccompanyingPeriodWorkEvaluationApiController ), JsonResponse::HTTP_OK, [], true); } - /** - * @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end") - */ + #[Route(path: '/api/1.0/person/accompanying-period/work/evaluation/my-near-end')] public function myWorksNearEndDate(Request $request): JsonResponse { $total = $this->accompanyingPeriodWorkEvaluationRepository diff --git a/src/Bundle/ChillPersonBundle/Controller/AdminController.php b/src/Bundle/ChillPersonBundle/Controller/AdminController.php index 7f973d50a..970010e20 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AdminController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AdminController.php @@ -19,33 +19,25 @@ use Symfony\Component\Routing\Annotation\Route; */ class AdminController extends AbstractController { - /** - * @Route("/{_locale}/admin/accompanying-course", name="chill_accompanying-course_admin_index") - */ + #[Route(path: '/{_locale}/admin/accompanying-course', name: 'chill_accompanying-course_admin_index')] public function indexAccompanyingCourseAdminAction() { return $this->render('@ChillPerson/Admin/indexAccompanyingCourse.html.twig'); } - /** - * @Route("/{_locale}/admin/household", name="chill_household_admin_index") - */ + #[Route(path: '/{_locale}/admin/household', name: 'chill_household_admin_index')] public function indexHouseholdAdminAction() { return $this->render('@ChillPerson/Admin/indexHousehold.html.twig'); } - /** - * @Route("/{_locale}/admin/person", name="chill_person_admin_index") - */ + #[Route(path: '/{_locale}/admin/person', name: 'chill_person_admin_index')] public function indexPersonAdminAction() { return $this->render('@ChillPerson/Admin/indexPerson.html.twig'); } - /** - * @Route("/{_locale}/admin/social-work", name="chill_social-work_admin_index") - */ + #[Route(path: '/{_locale}/admin/social-work', name: 'chill_social-work_admin_index')] public function indexSocialWorkAdminAction() { return $this->render('@ChillPerson/Admin/indexSocialWork.html.twig'); @@ -53,9 +45,8 @@ class AdminController extends AbstractController /** * @return \Symfony\Component\HttpFoundation\RedirectResponse - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/person_redirect_to_main", name="chill_person_admin_redirect_to_admin_index", options={null}) */ + #[Route(path: '/{_locale}/admin/person_redirect_to_main', name: 'chill_person_admin_redirect_to_admin_index', options: [null])] public function redirectToAdminIndexAction() { return $this->redirectToRoute('chill_main_admin_central'); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index a6d5ed2c5..05e73ad2a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -34,11 +34,9 @@ class HouseholdApiController extends ApiController public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly HouseholdRepository $householdRepository, private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} /** - * @Route("/api/1.0/person/household/by-address-reference/{id}.json", - * name="chill_api_person_household_by_address_reference") - * * @return \Symfony\Component\HttpFoundation\JsonResponse */ + #[Route(path: '/api/1.0/person/household/by-address-reference/{id}.json', name: 'chill_api_person_household_by_address_reference')] public function getHouseholdByAddressReference(AddressReference $addressReference): Response { $this->denyAccessUnlessGranted('ROLE_USER'); @@ -59,10 +57,8 @@ class HouseholdApiController extends ApiController /** * Add an address to a household. - * - * @Route("/api/1.0/person/household/{id}/address.{_format}", name="chill_api_single_household_address", - * methods={"POST"}, requirements={"_format": "json"}) */ + #[Route(path: '/api/1.0/person/household/{id}/address.{_format}', name: 'chill_api_single_household_address', methods: ['POST'], requirements: ['_format' => 'json'])] public function householdAddressApi(Household $household, Request $request, string $_format): Response { $this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household); @@ -104,15 +100,9 @@ class HouseholdApiController extends ApiController } /** - * @Route("/api/1.0/person/address/suggest/by-household/{household_id}.{_format}", - * name="chill_person_address_suggest_by_household", - * requirements={ - * "_format": "json" - * } - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/api/1.0/person/address/suggest/by-household/{household_id}.{_format}', name: 'chill_person_address_suggest_by_household', requirements: ['_format' => 'json'])] public function suggestAddressByHousehold(Household $household, string $_format) { // TODO add acl diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 00503ab3e..0da3688f9 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -46,9 +46,7 @@ class HouseholdCompositionController extends AbstractController private readonly UrlGeneratorInterface $urlGenerator ) {} - /** - * @Route("/{_locale}/person/household/{household_id}/composition/{composition_id}/delete", name="chill_person_household_composition_delete") - */ + #[Route(path: '/{_locale}/person/household/{household_id}/composition/{composition_id}/delete', name: 'chill_person_household_composition_delete')] public function deleteAction(Request $request, mixed $household_id, mixed $composition_id): Response { $composition = $this->householdCompositionRepository->find($composition_id); @@ -95,9 +93,7 @@ class HouseholdCompositionController extends AbstractController ); } - /** - * @Route("/{_locale}/person/household/{id}/composition/index", name="chill_person_household_composition_index") - */ + #[Route(path: '/{_locale}/person/household/{id}/composition/index', name: 'chill_person_household_composition_index')] public function index(Household $household, Request $request): Response { if (!$this->security->isGranted(HouseholdVoter::SEE, $household)) { @@ -122,9 +118,7 @@ class HouseholdCompositionController extends AbstractController )); } - /** - * @Route("/{_locale}/person/household/{id}/composition/new", name="chill_person_household_composition_new") - */ + #[Route(path: '/{_locale}/person/household/{id}/composition/new', name: 'chill_person_household_composition_new')] public function newAction(Household $household, Request $request): Response { if ($this->security->isGranted(HouseholdVoter::EDIT, $household)) { diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index ae74d365b..83a195c5b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -29,22 +29,15 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -/** - * @Route("/{_locale}/person/household") - */ +#[Route(path: '/{_locale}/person/household')] class HouseholdController extends AbstractController { public function __construct(private readonly TranslatorInterface $translator, private readonly PositionRepository $positionRepository, private readonly SerializerInterface $serializer, private readonly Security $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} /** - * @Route( - * "/{household_id}/accompanying-period", - * name="chill_person_household_accompanying_period", - * methods={"GET", "HEAD"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/accompanying-period', name: 'chill_person_household_accompanying_period', methods: ['GET', 'HEAD'])] public function accompanyingPeriod(Request $request, Household $household) { $currentMembers = $household->getCurrentPersons(); @@ -92,14 +85,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/address/edit", - * name="chill_person_household_address_edit", - * methods={"GET", "HEAD", "POST"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/address/edit', name: 'chill_person_household_address_edit', methods: ['GET', 'HEAD', 'POST'])] public function addressEdit(Request $request, Household $household) { // TODO ACL @@ -119,14 +107,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/addresses", - * name="chill_person_household_addresses", - * methods={"GET", "HEAD"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/addresses', name: 'chill_person_household_addresses', methods: ['GET', 'HEAD'])] public function addresses(Request $request, Household $household) { // TODO ACL @@ -150,14 +133,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/address/move", - * name="chill_person_household_address_move", - * methods={"GET", "HEAD", "POST"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/address/move', name: 'chill_person_household_address_move', methods: ['GET', 'HEAD', 'POST'])] public function addressMove(Request $request, Household $household) { // TODO ACL @@ -171,14 +149,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/address/edit_valid_from", - * name="chill_person_household_address_valid_from_edit", - * methods={"GET", "HEAD", "POST"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/address/edit_valid_from', name: 'chill_person_household_address_valid_from_edit', methods: ['GET', 'HEAD', 'POST'])] public function addressValidFromEdit(Request $request, Household $household) { $this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household); @@ -228,14 +201,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/members/metadata/edit", - * name="chill_person_household_members_metadata_edit", - * methods={"GET", "POST"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/members/metadata/edit', name: 'chill_person_household_members_metadata_edit', methods: ['GET', 'POST'])] public function editHouseholdMetadata(Request $request, Household $household) { // TODO ACL @@ -260,14 +228,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/relationship", - * name="chill_person_household_relationship", - * methods={"GET", "HEAD"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/relationship', name: 'chill_person_household_relationship', methods: ['GET', 'HEAD'])] public function showRelationship(Request $request, Household $household) { $jsonString = $this->serializer->serialize( @@ -286,14 +249,9 @@ class HouseholdController extends AbstractController } /** - * @Route( - * "/{household_id}/summary", - * name="chill_person_household_summary", - * methods={"GET", "HEAD"} - * ) - * * @ParamConverter("household", options={"id": "household_id"}) */ + #[Route(path: '/{household_id}/summary', name: 'chill_person_household_summary', methods: ['GET', 'HEAD'])] public function summary(Request $request, Household $household) { // TODO ACL diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index aa2f80a43..07ab6da70 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -47,12 +47,7 @@ class HouseholdMemberController extends ApiController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, ) {} - /** - * @Route( - * "/{_locale}/person/household/member/{id}/edit", - * name="chill_person_household_member_edit" - * ) - */ + #[Route(path: '/{_locale}/person/household/member/{id}/edit', name: 'chill_person_household_member_edit')] public function editMembership(Request $request, HouseholdMember $member): Response { // TODO ACL @@ -90,12 +85,8 @@ class HouseholdMemberController extends ApiController * * household: the id of the destination household * * allow_leave_without_household: if present, the editor will allow * to leave household without joining another - * - * @Route( - * "/{_locale}/person/household/members/editor", - * name="chill_person_household_members_editor" - * ) */ + #[Route(path: '/{_locale}/person/household/members/editor', name: 'chill_person_household_members_editor')] public function editor(Request $request) { $ids = $request->query->all('persons'); @@ -173,12 +164,7 @@ class HouseholdMemberController extends ApiController ]); } - /** - * @Route( - * "/api/1.0/person/household/members/move.{_format}", - * name="chill_api_person_household_members_move" - * ) - */ + #[Route(path: '/api/1.0/person/household/members/move.{_format}', name: 'chill_api_person_household_members_move')] public function move(Request $request, mixed $_format): Response { try { diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php b/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php index b1df6cb16..13b1fc7ca 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php @@ -31,9 +31,7 @@ class PersonAddressController extends AbstractController */ public function __construct(private readonly ValidatorInterface $validator, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/create", name="chill_person_address_create", methods={"POST"}) - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/create', name: 'chill_person_address_create', methods: ['POST'])] public function createAction(mixed $person_id, Request $request) { $person = $this->managerRegistry->getManager() @@ -88,9 +86,7 @@ class PersonAddressController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/edit", name="chill_person_address_edit") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/{address_id}/edit', name: 'chill_person_address_edit')] public function editAction(mixed $person_id, mixed $address_id) { $person = $this->managerRegistry->getManager() @@ -118,9 +114,7 @@ class PersonAddressController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/list", name="chill_person_address_list") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/list', name: 'chill_person_address_list')] public function listAction(mixed $person_id) { $person = $this->managerRegistry->getManager() @@ -142,9 +136,7 @@ class PersonAddressController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/new", name="chill_person_address_new") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/new', name: 'chill_person_address_new')] public function newAction(mixed $person_id) { $person = $this->managerRegistry->getManager() @@ -171,9 +163,7 @@ class PersonAddressController extends AbstractController ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/update", name="chill_person_address_update") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/{address_id}/update', name: 'chill_person_address_update')] public function updateAction(mixed $person_id, mixed $address_id, Request $request) { $person = $this->managerRegistry->getManager() diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 01008f240..6a1820b24 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -36,11 +36,7 @@ class PersonApiController extends ApiController $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; } - /** - * @Route("/api/1.0/person/creation/authorized-centers", - * name="chill_person_person_creation_authorized_centers" - * ) - */ + #[Route(path: '/api/1.0/person/creation/authorized-centers', name: 'chill_person_person_creation_authorized_centers')] public function authorizedCentersForCreation(): Response { $centers = $this->authorizedCenterOnPersonCreation->getCenters(); @@ -53,14 +49,7 @@ class PersonApiController extends ApiController ); } - /** - * @Route("/api/1.0/person/config/alt_names.{_format}", - * name="chill_person_config_alt_names", - * requirements={ - * "_format": "json" - * } - * ) - */ + #[Route(path: '/api/1.0/person/config/alt_names.{_format}', name: 'chill_person_config_alt_names', requirements: ['_format' => 'json'])] public function configAltNames(Request $request, string $_format): Response { $configAltNamesChoices = $this->configPersonAltNameHelper->getChoices(); @@ -83,15 +72,9 @@ class PersonApiController extends ApiController } /** - * @Route("/api/1.0/person/address/suggest/by-person/{person_id}.{_format}", - * name="chill_person_address_suggest_by_person", - * requirements={ - * "_format": "json" - * } - * ) - * * @ParamConverter("person", options={"id": "person_id"}) */ + #[Route(path: '/api/1.0/person/address/suggest/by-person/{person_id}.{_format}', name: 'chill_person_address_suggest_by_person', requirements: ['_format' => 'json'])] public function suggestAddress(Person $person, Request $request, string $_format): Response { $this->denyAccessUnlessGranted(PersonVoter::SEE, $person); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 3d8d1bdbe..9f35e1b5c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -49,9 +49,7 @@ final class PersonController extends AbstractController private readonly EntityManagerInterface $em, ) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/general/edit", name="chill_person_general_edit") - */ + #[Route(path: '/{_locale}/person/{person_id}/general/edit', name: 'chill_person_general_edit')] public function editAction(int $person_id, Request $request) { $person = $this->_getPerson($person_id); @@ -116,14 +114,9 @@ final class PersonController extends AbstractController } /** - * @Route( - * "/{_locale}/person/household/{person_id}/history", - * name="chill_person_household_person_history", - * methods={"GET", "POST"} - * ) - * * @ParamConverter("person", options={"id": "person_id"}) */ + #[Route(path: '/{_locale}/person/household/{person_id}/history', name: 'chill_person_household_person_history', methods: ['GET', 'POST'])] public function householdHistoryByPerson(Request $request, Person $person): Response { $this->denyAccessUnlessGranted( @@ -146,14 +139,13 @@ final class PersonController extends AbstractController /** * Method for creating a new person. * - *The controller register data from a previous post on the form, and + * The controller register data from a previous post on the form, and * register it in the session. * * The next post compare the data with previous one and, if yes, show a * review page if there are "alternate persons". - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/new", name="chill_person_new") */ + #[Route(path: '/{_locale}/person/new', name: 'chill_person_new')] public function newAction(Request $request): Response { $person = new Person(); @@ -248,9 +240,7 @@ final class PersonController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/general", name="chill_person_view") - */ + #[Route(path: '/{_locale}/person/{person_id}/general', name: 'chill_person_view')] public function viewAction(int $person_id) { $person = $this->_getPerson($person_id); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 119780b47..b11390a46 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -42,9 +42,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, ) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm", name="chill_person_duplicate_confirm") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm', name: 'chill_person_duplicate_confirm')] public function confirmAction(mixed $person1_id, mixed $person2_id, Request $request) { if ($person1_id === $person2_id) { @@ -104,9 +102,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/find-manually", name="chill_person_find_manually_duplicate") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/find-manually', name: 'chill_person_find_manually_duplicate')] public function findManuallyDuplicateAction(mixed $person_id, Request $request) { $person = $this->_getPerson($person_id); @@ -155,9 +151,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll ]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/not-duplicate", name="chill_person_duplicate_not_duplicate") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/not-duplicate', name: 'chill_person_duplicate_not_duplicate')] public function notDuplicateAction(mixed $person1_id, mixed $person2_id) { $user = $this->security->getUser(); @@ -190,9 +184,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/remove-not-duplicate", name="chill_person_remove_duplicate_not_duplicate") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/remove-not-duplicate', name: 'chill_person_remove_duplicate_not_duplicate')] public function removeNotDuplicateAction(mixed $person1_id, mixed $person2_id) { [$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id); @@ -214,9 +206,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/duplicate/view", name="chill_person_duplicate_view") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/duplicate/view', name: 'chill_person_duplicate_view')] public function viewAction(mixed $person_id, PersonNotDuplicateRepository $personNotDuplicateRepository) { $person = $this->_getPerson($person_id); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index a9d60d18e..079830cf7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -27,9 +27,7 @@ final class PersonResourceController extends AbstractController { public function __construct(private readonly PersonResourceRepository $personResourceRepository, private readonly PersonRepository $personRepository, private readonly EntityManagerInterface $em, private readonly TranslatorInterface $translator) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/delete", name="chill_person_resource_delete") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/{resource_id}/delete', name: 'chill_person_resource_delete')] public function deleteAction(Request $request, mixed $person_id, mixed $resource_id): Response { $personOwner = $this->personRepository->find($person_id); @@ -76,9 +74,7 @@ final class PersonResourceController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/edit", name="chill_person_resource_edit") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/{resource_id}/edit', name: 'chill_person_resource_edit')] public function editAction(Request $request, mixed $resource_id, mixed $person_id): Response { $resource = $this->personResourceRepository->find($resource_id); @@ -113,9 +109,7 @@ final class PersonResourceController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/list", name="chill_person_resource_list") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/list', name: 'chill_person_resource_list')] public function listAction(Request $request, mixed $person_id) { $personOwner = $this->personRepository->find($person_id); @@ -133,9 +127,7 @@ final class PersonResourceController extends AbstractController ); } - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/new", name="chill_person_resource_new") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/new', name: 'chill_person_resource_new')] public function newAction(Request $request, mixed $person_id) { $personOwner = $this->personRepository->find($person_id); diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 7cd95773e..6e3fa5117 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -41,9 +41,7 @@ class ReassignAccompanyingPeriodController extends AbstractController { public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em) {} - /** - * @Route("/{_locale}/person/accompanying-periods/reassign", name="chill_course_list_reassign") - */ + #[Route(path: '/{_locale}/person/accompanying-periods/reassign', name: 'chill_course_list_reassign')] public function listAction(Request $request): Response { if (!$this->security->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK)) { diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index 4cf3e0d6e..dc3c8ee0a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -29,9 +29,7 @@ final class ResidentialAddressController extends AbstractController { public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly ResidentialAddressRepository $residentialAddressRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @Route("/{_locale}/person/residential-address/{id}/delete", name="chill_person_residential_address_delete") - */ + #[Route(path: '/{_locale}/person/residential-address/{id}/delete', name: 'chill_person_residential_address_delete')] public function deleteAction(Request $request, ResidentialAddress $residentialAddress): Response { $this->denyAccessUnlessGranted(PersonVoter::UPDATE, $residentialAddress->getPerson()); @@ -57,9 +55,7 @@ final class ResidentialAddressController extends AbstractController ]); } - /** - * @Route("/{_locale}/person/residential-address/{id}/edit", name="chill_person_residential_address_edit") - */ + #[Route(path: '/{_locale}/person/residential-address/{id}/edit', name: 'chill_person_residential_address_edit')] public function editAction(Request $request, ResidentialAddress $residentialAddress): Response { if ($request->query->has('kind')) { @@ -93,9 +89,7 @@ final class ResidentialAddressController extends AbstractController ]); } - /** - * @Route("/{_locale}/person/{id}/residential-address/list", name="chill_person_residential_address_list") - */ + #[Route(path: '/{_locale}/person/{id}/residential-address/list', name: 'chill_person_residential_address_list')] public function listAction(Request $request, Person $person): Response { $this->denyAccessUnlessGranted(PersonVoter::SEE, $person); @@ -108,9 +102,7 @@ final class ResidentialAddressController extends AbstractController ]); } - /** - * @Route("/{_locale}/person/{id}/residential-address/new", name="chill_person_residential_address_new") - */ + #[Route(path: '/{_locale}/person/{id}/residential-address/new', name: 'chill_person_residential_address_new')] public function newAction(Request $request, Person $person): Response { $residentialAddress = new ResidentialAddress(); diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php index b97f2ed30..27a7acbf5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php @@ -25,15 +25,9 @@ class SocialWorkEvaluationApiController extends AbstractController public function __construct(private readonly PaginatorFactory $paginatorFactory) {} /** - * @Route("/api/1.0/person/social-work/evaluation/by-social-action/{action_id}.json", - * name="chill_person_evaluation_index_by_social_action", - * requirements={ - * "_format": "json" - * } - * ) - * * @ParamConverter("action", options={"id": "action_id"}) */ + #[Route(path: '/api/1.0/person/social-work/evaluation/by-social-action/{action_id}.json', name: 'chill_person_evaluation_index_by_social_action', requirements: ['_format' => 'json'])] public function listEvaluationBySocialAction(SocialAction $action): Response { $evaluations = $action->getEvaluations()->filter(static fn (Evaluation $eval) => $eval->isActive()); diff --git a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php index 5cfc26cc7..0cd86eb5b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php @@ -24,9 +24,7 @@ class TimelinePersonController extends AbstractController { public function __construct(protected EventDispatcherInterface $eventDispatcher, protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} - /** - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/timeline", name="chill_person_timeline") - */ + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/timeline', name: 'chill_person_timeline')] public function personAction(Request $request, mixed $person_id) { $person = $this->managerRegistry diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 1f484fd91..adaaa27d0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -23,9 +23,7 @@ class UserAccompanyingPeriodController extends AbstractController { public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly PaginatorFactory $paginatorFactory) {} - /** - * @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user") - */ + #[Route(path: '/{_locale}/person/accompanying-periods/my', name: 'chill_person_accompanying_period_user')] public function listAction(Request $request): Response { $active = $request->query->getBoolean('active', true); @@ -56,9 +54,7 @@ class UserAccompanyingPeriodController extends AbstractController ]); } - /** - * @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user") - */ + #[Route(path: '/{_locale}/person/accompanying-periods/my/drafts', name: 'chill_person_accompanying_period_draft_user')] public function listDraftsAction(): Response { $total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => 'DRAFT']); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a38b7055c..27a217987 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -58,18 +58,14 @@ use UnexpectedValueException; * * @ORM\Table(name="chill_person_accompanying_period") * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period": AccompanyingPeriod::class - * }) - * - * @Assert\GroupSequenceProvider - * * @AccompanyingPeriodValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED}) * * @LocationValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED}) * * @ConfidentialCourseMustHaveReferrer(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED}) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period' => AccompanyingPeriod::class])] +#[Assert\GroupSequenceProvider] class AccompanyingPeriod implements GroupSequenceProviderInterface, HasCentersInterface, @@ -144,11 +140,9 @@ class AccompanyingPeriod implements /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - * - * @Groups({"read", "write"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED}) */ + #[Groups(['read', 'write'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])] private ?Location $administrativeLocation = null; /** @@ -160,17 +154,10 @@ class AccompanyingPeriod implements /** * @ORM\Column(type="date", nullable=true) - * - * @Groups({"read", "write", "docgen:read"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED}) - * - * @Assert\GreaterThanOrEqual( - * propertyPath="openingDate", - * groups={AccompanyingPeriod::STEP_CLOSED}, - * message="The closing date must be later than the date of creation" - * ) */ + #[Groups(['read', 'write', 'docgen:read'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CLOSED])] + #[Assert\GreaterThanOrEqual(propertyPath: 'openingDate', groups: [AccompanyingPeriod::STEP_CLOSED], message: 'The closing date must be later than the date of creation')] private ?\DateTime $closingDate = null; /** @@ -178,11 +165,9 @@ class AccompanyingPeriod implements * targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive") * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "write"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED}) */ + #[Groups(['read', 'write'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CLOSED])] private ?ClosingMotive $closingMotive = null; /** @@ -194,40 +179,35 @@ class AccompanyingPeriod implements * * @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"}) * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT}) - * * @var Collection */ + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_DRAFT])] private Collection $comments; /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"read", "write", "docgen:read"}) */ + #[Groups(['read', 'write', 'docgen:read'])] private bool $confidential = false; /** * @ORM\Column(type="datetime", nullable=true, options={"default": NULL}) - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?\DateTimeInterface $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?User $createdBy = null; /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"read", "write", "docgen:read"}) */ + #[Groups(['read', 'write', 'docgen:read'])] private bool $emergency = false; /** @@ -236,29 +216,24 @@ class AccompanyingPeriod implements * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="string", nullable=true) - * - * @Groups({"read"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED}) */ + #[Groups(['read'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])] private ?string $intensity = self::INTENSITY_OCCASIONAL; /** * @ORM\ManyToOne( * targetEntity=UserJob::class * ) - * - * @Groups({"read", "write"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED}) */ + #[Groups(['read', 'write'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])] private ?UserJob $job = null; /** @@ -271,24 +246,19 @@ class AccompanyingPeriod implements /** * @ORM\Column(type="date") - * - * @Groups({"read", "write", "docgen:read"}) - * - * @Assert\LessThan(value="tomorrow", groups={AccompanyingPeriod::STEP_CONFIRMED}) - * - * @Assert\LessThanOrEqual(propertyPath="closingDate", groups={AccompanyingPeriod::STEP_CONFIRMED}) */ + #[Groups(['read', 'write', 'docgen:read'])] + #[Assert\LessThan(value: 'tomorrow', groups: [AccompanyingPeriod::STEP_CONFIRMED])] + #[Assert\LessThanOrEqual(propertyPath: 'closingDate', groups: [AccompanyingPeriod::STEP_CONFIRMED])] private ?\DateTime $openingDate = null; /** * @ORM\ManyToOne(targetEntity=Origin::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "write"}) - * - * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED}) */ + #[Groups(['read', 'write'])] + #[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])] private ?Origin $origin = null; /** @@ -296,12 +266,11 @@ class AccompanyingPeriod implements * mappedBy="accompanyingPeriod", orphanRemoval=true, * cascade={"persist", "refresh", "remove", "merge", "detach"}) * - * @Groups({"read", "docgen:read"}) - * * @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED}) * * @var Collection */ + #[Groups(['read', 'docgen:read'])] private Collection $participations; /** @@ -318,26 +287,23 @@ class AccompanyingPeriod implements * cascade={"persist"}, * ) * - * @Groups({"read"}) - * * @ORM\JoinColumn(onDelete="SET NULL") */ + #[Groups(['read'])] private ?Comment $pinnedComment = null; private bool $preventUserIsChangedNotification = false; /** * @ORM\Column(type="text") - * - * @Groups({"read", "write"}) */ + #[Groups(['read', 'write'])] private string $remark = ''; /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"read", "write", "docgen:read"}) */ + #[Groups(['read', 'write', 'docgen:read'])] private bool $requestorAnonymous = false; /** @@ -364,10 +330,9 @@ class AccompanyingPeriod implements * orphanRemoval=true * ) * - * @Groups({"read", "docgen:read"}) - * * @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"}) */ + #[Groups(['read', 'docgen:read'])] private Collection $resources; /** @@ -383,11 +348,9 @@ class AccompanyingPeriod implements * joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")} * ) - * - * @Groups({"read", "docgen:read"}) - * - * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope") */ + #[Groups(['read', 'docgen:read'])] + #[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must be associated to at least one scope')] private Collection $scopes; /** @@ -400,20 +363,17 @@ class AccompanyingPeriod implements * @ORM\JoinTable( * name="chill_person_accompanying_period_social_issues" * ) - * - * @Groups({"read", "docgen:read"}) - * - * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must contains at least one social issue") */ + #[Groups(['read', 'docgen:read'])] + #[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must contains at least one social issue')] private Collection $socialIssues; /** * @ORM\Column(type="string", length=32, nullable=true) * - * @Groups({"read"}) - * * @var AccompanyingPeriod::STEP_* */ + #[Groups(['read'])] private ?string $step = self::STEP_DRAFT; /** @@ -440,9 +400,8 @@ class AccompanyingPeriod implements * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "write", "docgen:read"}) */ + #[Groups(['read', 'write', 'docgen:read'])] private ?User $user = null; /** @@ -469,9 +428,8 @@ class AccompanyingPeriod implements * targetEntity=AccompanyingPeriodWork::class, * mappedBy="accompanyingPeriod" * ) - * - * @Assert\Valid(traverse=true) */ + #[Assert\Valid(traverse: true)] private Collection $works; /** @@ -749,10 +707,9 @@ class AccompanyingPeriod implements } /** - * @Groups({"read"}) - * * @return ReadableCollection<(int|string), Comment> */ + #[Groups(['read'])] public function getComments(): ReadableCollection { $pinnedComment = $this->pinnedComment; @@ -775,9 +732,7 @@ class AccompanyingPeriod implements return $this->createdBy; } - /** - * @Groups({"docgen:read"}) - */ + #[Groups(['docgen:read'])] public function getCurrentParticipations(): ReadableCollection { return $this->getOpenParticipations(); @@ -826,9 +781,8 @@ class AccompanyingPeriod implements /** * Get the location, taking precedence into account. - * - * @Groups({"read"}) */ + #[Groups(['read'])] public function getLocation(?\DateTimeImmutable $at = null): ?Address { if ($this->getPersonLocation() instanceof Person) { @@ -849,10 +803,9 @@ class AccompanyingPeriod implements /** * Get where the location is. * - * @Groups({"read"}) - * * @return 'person'|'address'|'none' */ + #[Groups(['read'])] public function getLocationStatus(): string { if ($this->getPersonLocation() instanceof Person) { @@ -949,9 +902,7 @@ class AccompanyingPeriod implements ); } - /** - * @Groups({"read"}) - */ + #[Groups(['read'])] public function getPersonLocation(): ?Person { return $this->personLocation; @@ -971,9 +922,7 @@ class AccompanyingPeriod implements ); } - /** - * @Groups({"read"}) - */ + #[Groups(['read'])] public function getPinnedComment(): ?Comment { return $this->pinnedComment; @@ -1026,9 +975,7 @@ class AccompanyingPeriod implements return $this->remark; } - /** - * @Groups({"read"}) - */ + #[Groups(['read'])] public function getRequestor(): Person|ThirdParty|null { return $this->requestorPerson ?? $this->requestorThirdParty; @@ -1254,9 +1201,7 @@ class AccompanyingPeriod implements return $this; } - /** - * @Groups({"write"}) - */ + #[Groups(['write'])] public function setAddressLocation(?Address $addressLocation = null): self { if ($this->addressLocation !== $addressLocation) { @@ -1369,9 +1314,7 @@ class AccompanyingPeriod implements return $this; } - /** - * @Groups({"write"}) - */ + #[Groups(['write'])] public function setPersonLocation(?Person $person = null): self { if ($this->personLocation !== $person) { @@ -1391,9 +1334,7 @@ class AccompanyingPeriod implements return $this; } - /** - * @Groups({"write"}) - */ + #[Groups(['write'])] public function setPinnedComment(?Comment $comment = null): self { if (null !== $this->pinnedComment) { @@ -1421,9 +1362,8 @@ class AccompanyingPeriod implements * @param $requestor Person|ThirdParty * * @throw UnexpectedValueException if the requestor is not a Person or ThirdParty - * - * @Groups({"write"}) */ + #[Groups(['write'])] public function setRequestor($requestor): self { if ($requestor instanceof Person) { diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 618918695..dcf154b8b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -33,23 +33,16 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity * * @ORM\Table(name="chill_person_accompanying_period_work") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "accompanying_period_work": AccompanyingPeriodWork::class - * } - * ) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work' => AccompanyingPeriodWork::class])] class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, TrackCreationInterface, TrackUpdateInterface { /** * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) * - * @Serializer\Groups({"read", "read:accompanyingPeriodWork:light"}) - * * @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'read:accompanyingPeriodWork:light'])] private ?AccompanyingPeriod $accompanyingPeriod = null; /** @@ -60,57 +53,46 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * orphanRemoval=true * ) * - * @Serializer\Groups({"read", "docgen:read"}) - * * @ORM\OrderBy({"startDate": "DESC", "id": "DESC"}) * * @var Collection * * @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer` */ + #[Serializer\Groups(['read', 'docgen:read'])] private Collection $accompanyingPeriodWorkEvaluations; /** * @ORM\Column(type="datetime_immutable") - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] private ?\DateTimeImmutable $createdAt = null; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] private bool $createdAutomatically = false; /** * @ORM\Column(type="text") - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] private string $createdAutomaticallyReason = ''; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=false) - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] private ?User $createdBy = null; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"accompanying_period_work:create"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) - * - * @Assert\GreaterThanOrEqual(propertyPath="startDate", - * message="accompanying_course_work.The endDate should be greater or equal than the start date" - * ) */ + #[Serializer\Groups(['accompanying_period_work:create', 'accompanying_period_work:edit', 'read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] + #[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'accompanying_course_work.The endDate should be greater or equal than the start date')] private ?\DateTimeImmutable $endDate = null; /** @@ -122,20 +104,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * cascade={"persist"}, * orphanRemoval=true * ) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])] private Collection $goals; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * - * In schema : traitant */ + #[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])] private ?ThirdParty $handlingThierParty = null; /** @@ -144,16 +120,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light", "read:evaluation:include-work"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'read:evaluation:include-work'])] private ?int $id = null; /** * @ORM\Column(type="text") - * - * @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"}) */ + #[Serializer\Groups(['read', 'accompanying_period_work:edit', 'docgen:read'])] private string $note = ''; /** @@ -162,18 +136,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * @ORM\ManyToMany(targetEntity=Person::class) * * @ORM\JoinTable(name="chill_person_accompanying_period_work_person") - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"accompanying_period_work:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:edit', 'accompanying_period_work:create'])] private Collection $persons; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_") - * - * @Serializer\Groups({"read", "accompanying_period_work:edit"}) */ + #[Serializer\Groups(['read', 'accompanying_period_work:edit'])] private PrivateCommentEmbeddable $privateComment; /** @@ -189,29 +159,22 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") * * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])] private Collection $results; /** * @ORM\ManyToOne(targetEntity=SocialAction::class) * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) - * @Serializer\Groups({"accompanying_period_work:create"}) - * * @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:create'])] private ?SocialAction $socialAction = null; /** * @ORM\Column(type="date_immutable") - * - * @Serializer\Groups({"accompanying_period_work:create"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) */ + #[Serializer\Groups(['accompanying_period_work:create', 'accompanying_period_work:edit', 'read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] private ?\DateTimeImmutable $startDate = null; /** @@ -222,35 +185,30 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party") * * In schema : intervenants - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])] private Collection $thirdParties; /** * @ORM\Column(type="datetime_immutable") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?\DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=false) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?User $updatedBy = null; /** * @ORM\Column(type="integer", nullable=false, options={"default": 1}) * - * @Serializer\Groups({"read", "accompanying_period_work:edit"}) - * * @ORM\Version */ + #[Serializer\Groups(['read', 'accompanying_period_work:edit'])] private int $version = 1; public function __construct() @@ -394,11 +352,8 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues /** * @return ReadableCollection - * - * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"accompanying_period_work:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:edit', 'accompanying_period_work:create'])] public function getReferrers(): ReadableCollection { $users = $this->referrersHistory diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 7f2fc981c..18993c3d9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -25,11 +25,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table("chill_person_accompanying_period_work_evaluation") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period_work_evaluation": AccompanyingPeriodWorkEvaluation::class, - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_evaluation' => AccompanyingPeriodWorkEvaluation::class])] class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackUpdateInterface { /** @@ -38,35 +35,29 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU * inversedBy="accompanyingPeriodWorkEvaluations" * ) * - * @Serializer\Groups({"read:evaluation:include-work"}) - * * @Serializer\Context(normalizationContext={"groups": {"read:accompanyingPeriodWork:light"}}, groups={"read:evaluation:include-work"}) */ + #[Serializer\Groups(['read:evaluation:include-work'])] private ?AccompanyingPeriodWork $accompanyingPeriodWork = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])] private string $comment = ''; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?\DateTimeImmutable $createdAt = null; /** * @ORM\ManyToOne( * targetEntity=User::class * ) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?User $createdBy = null; /** @@ -83,29 +74,23 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU * * @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"}) * - * @Serializer\Groups({"read"}) - * * @var Collection */ + #[Serializer\Groups(['read'])] private Collection $documents; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])] private ?\DateTimeImmutable $endDate = null; /** * @ORM\ManyToOne( * targetEntity=Evaluation::class * ) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work_evaluation:create'])] private ?Evaluation $evaluation = null; /** @@ -114,9 +99,8 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -125,63 +109,46 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU * * This data is not persisted into database, but will appears on the data * normalized during the same request (like PUT/PATCH request) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])] private $key; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])] private ?\DateTimeImmutable $maxDate = null; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])] private ?\DateTimeImmutable $startDate = null; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?\DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne( * targetEntity=User::class * ) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?User $updatedBy = null; /** * @ORM\Column(type="dateinterval", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])] private ?\DateInterval $warningInterval = null; /** * @ORM\Column(type="integer", nullable=true) - * - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])] private ?int $timeSpent = null; public function __construct() @@ -270,9 +237,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this->updatedBy; } - /** - * @Serializer\Groups({"docgen:read"}) - */ + #[Serializer\Groups(['docgen:read'])] public function getWarningDate(): ?\DateTimeImmutable { if (null === $this->getEndDate() || null === $this->getWarningInterval()) { diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index e5ddc059a..d20e8d7ed 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -23,11 +23,8 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity * * @ORM\Table("chill_person_accompanying_period_work_evaluation_document") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period_work_evaluation_document": AccompanyingPeriodWorkEvaluationDocument::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_evaluation_document' => AccompanyingPeriodWorkEvaluationDocument::class])] class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface { use TrackCreationTrait; @@ -52,10 +49,8 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct * @internal the default name exceeds 64 characters, we must set manually: * * @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'accompanying_period_work_evaluation:create'])] private ?int $id = null; /** @@ -64,43 +59,31 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct * * This data is not persisted into database, but will appears on the data * normalized during the same request (like PUT/PATCH request) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])] private $key; /** * @ORM\ManyToOne( * targetEntity=StoredObject::class, * ) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - * - * @Assert\Valid */ + #[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])] + #[Assert\Valid] private ?StoredObject $storedObject = null; /** * @ORM\ManyToOne( * targetEntity=DocGeneratorTemplate::class * ) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'accompanying_period_work_evaluation:create'])] private ?DocGeneratorTemplate $template = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"write"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ + #[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])] private ?string $title = ''; public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php index c0a1528ad..bdd30eec3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php @@ -22,14 +22,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_accompanying_period_work_goal") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "accompanying_period_work_goal": AccompanyingPeriodWorkGoal::class - * } - * ) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_goal' => AccompanyingPeriodWorkGoal::class])] class AccompanyingPeriodWorkGoal { /** @@ -39,10 +33,8 @@ class AccompanyingPeriodWorkGoal /** * @ORM\ManyToOne(targetEntity=Goal::class) - * - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['accompanying_period_work:edit', 'read', 'docgen:read'])] private ?Goal $goal = null; /** @@ -51,17 +43,14 @@ class AccompanyingPeriodWorkGoal * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="text") - * - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['accompanying_period_work:edit', 'read'])] private string $note = ''; /** @@ -70,10 +59,8 @@ class AccompanyingPeriodWorkGoal * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals") * * @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result") - * - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['accompanying_period_work:edit', 'read', 'docgen:read'])] private Collection $results; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php index 97938dafc..dc12bff2a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/ClosingMotive.php @@ -47,18 +47,16 @@ class ClosingMotive * @ORM\Column(name="id", type="integer") * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private array $name = []; /** diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index c972f453a..b230b4b18 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -24,11 +24,8 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity * * @ORM\Table(name="chill_person_accompanying_period_comment") - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period_comment": Comment::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_comment' => Comment::class])] class Comment implements TrackCreationInterface, TrackUpdateInterface { /** @@ -42,29 +39,24 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default":""}) - * - * @Groups({"read", "write", "docgen:read"}) - * - * @Assert\NotBlank - * - * @Assert\NotNull */ + #[Groups(['read', 'write', 'docgen:read'])] + #[Assert\NotBlank] + #[Assert\NotNull] private string $content = ''; /** * @ORM\Column(type="datetime") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?\DateTimeInterface $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=false) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?User $creator = null; /** @@ -73,25 +65,22 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="datetime") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeInterface $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * * @ORM\JoinColumn(nullable=false) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?User $updatedBy = null; public function getAccompanyingPeriod(): ?AccompanyingPeriod diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php index 979fd4581..565f6f789 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php @@ -18,13 +18,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_accompanying_period_origin") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "origin": Origin::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['origin' => Origin::class])] class Origin { /** @@ -33,25 +28,22 @@ class Origin * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $label = []; /** * @ORM\Column(type="date_immutable", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateTimeImmutable $noActiveAfter = null; public function getId(): ?int diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php index f0ff1d956..e5e5a6091 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php @@ -31,11 +31,12 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"}) * } * ) - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period_resource": Resource::class - * }) + * @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}), + * @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"}) + * } + * ) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_resource' => Resource::class])] class Resource { /** @@ -50,9 +51,8 @@ class Resource /** * @ORM\Column(type="text", nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?string $comment = ''; /** @@ -61,27 +61,24 @@ class Resource * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=Person::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?Person $person = null; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"docgen:read"}) */ + #[Groups(['docgen:read'])] private ?ThirdParty $thirdParty = null; public function getAccompanyingPeriod(): ?AccompanyingPeriod @@ -104,9 +101,7 @@ class Resource return $this->person; } - /** - * @Groups({"read"}) - */ + #[Groups(['read'])] public function getResource(): Person|ThirdParty|null { return $this->person ?? $this->thirdParty; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php index 964f66f1a..2a04bbff5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php @@ -21,18 +21,14 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\Entity * * @ORM\Table(name="chill_person_accompanying_period_participation") - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "accompanying_period_participation": AccompanyingPeriodParticipation::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_participation' => AccompanyingPeriodParticipation::class])] class AccompanyingPeriodParticipation { /** * @ORM\Column(type="date", nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?\DateTime $endDate = null; /** @@ -41,16 +37,14 @@ class AccompanyingPeriodParticipation * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="date", nullable=false) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?\DateTime $startDate = null; public function __construct(/** @@ -59,12 +53,11 @@ class AccompanyingPeriodParticipation * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) */ private ?AccompanyingPeriod $accompanyingPeriod, /** - * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") - * - * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) - * - * @Groups({"read", "docgen:read"}) - */ + * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") + * + * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) + */ + #[Groups(['read', 'docgen:read'])] private ?Person $person ) { $this->startDate = new \DateTime('now'); diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index cc0ff2d69..45f6eb3a3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -32,12 +32,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * name="chill_person_household" * ) * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "household": Household::class - * }) - * * @MaxHolder(groups={"household_memberships"}) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household' => Household::class])] class Household { /** @@ -52,9 +49,8 @@ class Household * @ORM\JoinTable(name="chill_person_household_to_addresses") * * @ORM\OrderBy({"validFrom": "DESC", "id": "DESC"}) - * - * @Serializer\Groups({"write"}) */ + #[Serializer\Groups(['write'])] private Collection $addresses; /** @@ -73,9 +69,8 @@ class Household * ) * * @ORM\OrderBy({"startDate": "DESC"}) - * - * @Assert\Valid(traverse=true, groups={"household_composition"}) */ + #[Assert\Valid(traverse: true, groups: ['household_composition'])] private Collection&Selectable $compositions; /** @@ -84,9 +79,8 @@ class Household * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -96,23 +90,20 @@ class Household * targetEntity=HouseholdMember::class, * mappedBy="household" * ) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private Collection $members; /** * @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false}) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private bool $waitingForBirth = false; /** * @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?\DateTimeImmutable $waitingForBirthDate = null; public function __construct() @@ -159,8 +150,6 @@ class Household * By default, the addresses are ordered by date, descending (the most * recent first). * - * @Assert\Callback(methods={"validate"}) - * * @return Collection
*/ public function getAddresses(): Collection @@ -209,11 +198,8 @@ class Household return $this->compositions; } - /** - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Serializer\SerializedName("current_address") - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[Serializer\SerializedName('current_address')] public function getCurrentAddress(?\DateTime $at = null): ?Address { $at ??= new \DateTime('today'); @@ -229,11 +215,8 @@ class Household return null; } - /** - * @Serializer\Groups({"docgen:read"}) - * - * @Serializer\SerializedName("current_composition") - */ + #[Serializer\Groups(['docgen:read'])] + #[Serializer\SerializedName('current_composition')] public function getCurrentComposition(?\DateTimeImmutable $at = null): ?HouseholdComposition { $at ??= new \DateTimeImmutable('today'); @@ -259,9 +242,7 @@ class Household return null; } - /** - * @Serializer\Groups({"docgen:read"}) - */ + #[Serializer\Groups(['docgen:read'])] public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection { return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now)); @@ -281,11 +262,9 @@ class Household * get current members ids. * * Used in serialization - * - * @Serializer\Groups({"read"}) - * - * @Serializer\SerializedName("current_members_id") */ + #[Serializer\Groups(['read'])] + #[Serializer\SerializedName('current_members_id')] public function getCurrentMembersIds(?\DateTimeImmutable $now = null): ReadableCollection { return $this->getCurrentMembers($now)->map( @@ -606,9 +585,8 @@ class Household * This will force the startDate's address on today. * * Used on household creation. - * - * @Serializer\Groups({"create"}) */ + #[Serializer\Groups(['create'])] public function setForceAddress(Address $address) { $address->setValidFrom(new \DateTime('today')); @@ -629,6 +607,7 @@ class Household return $this; } + #[Assert\Callback] public function validate(ExecutionContextInterface $context, $payload) { $addresses = $this->getAddresses(); diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php index d8eab9bef..77f2a5994 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php @@ -26,11 +26,8 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Table( * name="chill_person_household_composition" * ) - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "household_composition_type": HouseholdCompositionType::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])] class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -44,11 +41,9 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Assert\GreaterThanOrEqual(propertyPath="startDate", groups={"Default", "household_composition"}) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Assert\GreaterThanOrEqual(propertyPath: 'startDate', groups: ['Default', 'household_composition'])] + #[Serializer\Groups(['docgen:read'])] private ?\DateTimeImmutable $endDate = null; /** @@ -62,9 +57,8 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa * @ORM\ManyToOne(targetEntity=HouseholdCompositionType::class) * * @ORM\JoinColumn(nullable=false) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?HouseholdCompositionType $householdCompositionType = null; /** @@ -73,29 +67,23 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="integer", nullable=true, options={"default": null}) - * - * @Assert\NotNull - * - * @Assert\GreaterThanOrEqual(0, groups={"Default", "household_composition"}) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Assert\NotNull] + #[Assert\GreaterThanOrEqual(0, groups: ['Default', 'household_composition'])] + #[Serializer\Groups(['docgen:read'])] private ?int $numberOfChildren = null; /** * @ORM\Column(type="date_immutable", nullable=false) - * - * @Assert\NotNull(groups={"Default", "household_composition"}) - * - * @Serializer\Groups({"docgen:read"}) */ + #[Assert\NotNull(groups: ['Default', 'household_composition'])] + #[Serializer\Groups(['docgen:read'])] private ?\DateTimeImmutable $startDate = null; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdCompositionType.php index cb1fe2703..2b3773bdf 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdCompositionType.php @@ -20,11 +20,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Table( * name="chill_person_household_composition_type" * ) - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "household_composition_type": HouseholdCompositionType::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])] class HouseholdCompositionType { /** @@ -38,18 +35,16 @@ class HouseholdCompositionType * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $label = []; public function getId(): ?int diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index 21c28f52e..09a32b2e2 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -27,40 +27,30 @@ class HouseholdMember { /** * @ORM\Column(type="string", length=255, nullable=true) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?string $comment = null; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Assert\GreaterThanOrEqual( - * propertyPath="startDate", - * message="household_membership.The end date must be after start date", - * groups={"household_memberships"} - * ) */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'household_membership.The end date must be after start date', groups: ['household_memberships'])] private ?\DateTimeImmutable $endDate = null; /** * @ORM\Column(type="boolean", options={"default": false}) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private bool $holder = false; /** * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Household\Household" * ) - * - * @Assert\Valid(groups={"household_memberships"}) - * - * @Assert\NotNull(groups={"household_memberships"}) */ + #[Assert\Valid(groups: ['household_memberships'])] + #[Assert\NotNull(groups: ['household_memberships'])] private ?Household $household = null; /** @@ -69,9 +59,8 @@ class HouseholdMember * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -79,21 +68,17 @@ class HouseholdMember * targetEntity="\Chill\PersonBundle\Entity\Person" * ) * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"docgen:person:with-household": false}) - * - * @Assert\Valid(groups={"household_memberships"}) - * - * @Assert\NotNull(groups={"household_memberships"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[Assert\Valid(groups: ['household_memberships'])] + #[Assert\NotNull(groups: ['household_memberships'])] private ?Person $person = null; /** * @ORM\ManyToOne(targetEntity=Position::class) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?Position $position = null; /** @@ -103,11 +88,9 @@ class HouseholdMember /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Assert\NotNull(groups={"household_memberships"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[Assert\NotNull(groups: ['household_memberships'])] private ?\DateTimeImmutable $startDate = null; public function getComment(): ?string @@ -140,9 +123,7 @@ class HouseholdMember return $this->position; } - /** - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] public function getShareHousehold(): ?bool { return $this->shareHousehold; diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Position.php b/src/Bundle/ChillPersonBundle/Entity/Household/Position.php index 2252fca97..2080fceb1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Position.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Position.php @@ -18,18 +18,14 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_household_position") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "household_position": Position::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_position' => Position::class])] class Position { /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({ "read" }) */ + #[Serializer\Groups(['read'])] private bool $allowHolder = false; /** @@ -38,32 +34,28 @@ class Position * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $label = []; /** * @ORM\Column(type="float") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private float $ordering = 0.00; /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $shareHouseHold = true; public function getAllowHolder(): bool diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 3ee30ac87..50c17cc19 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -62,19 +62,25 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * columns={"birthdate"} * ) * }) + * @ORM\Index( + * name="person_names", + * columns={"firstName", "lastName"} + * ), + * @ORM\Index( + * name="person_birthdate", + * columns={"birthdate"} + * ) + * }) * * @ORM\HasLifecycleCallbacks * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "person": Person::class - * }) - * * @PersonHasCenter * * @HouseholdMembershipSequential( * groups={"household_memberships"} * ) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['person' => Person::class])] class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable { final public const BOTH_GENDER = 'both'; @@ -282,35 +288,27 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * The person's deathdate. * * @ORM\Column(type="date_immutable", nullable=true) - * - * @Assert\Date - * - * @Assert\GreaterThanOrEqual(propertyPath="birthdate") - * - * @Assert\LessThanOrEqual("today") */ + #[Assert\Date] + #[Assert\GreaterThanOrEqual(propertyPath: 'birthdate')] + #[Assert\LessThanOrEqual('today')] private ?\DateTimeImmutable $deathdate = null; /** * The person's email. * * @ORM\Column(type="text", nullable=true) - * - * @Assert\Email() */ + #[Assert\Email] private ?string $email = ''; /** * The person's first name. * * @ORM\Column(type="string", length=255) - * - * @Assert\NotBlank(message="The firstname cannot be empty") - * - * @Assert\Length( - * max=255, - * ) */ + #[Assert\NotBlank(message: 'The firstname cannot be empty')] + #[Assert\Length(max: 255)] private string $firstName = ''; /** @@ -325,9 +323,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * The person's gender. * * @ORM\Column(type="string", length=9, nullable=true) - * - * @Assert\NotNull(message="The gender must be set") */ + #[Assert\NotNull(message: 'The gender must be set')] private ?string $gender = null; /** @@ -374,13 +371,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * The person's last name. * * @ORM\Column(type="string", length=255) - * - * @Assert\NotBlank(message="The lastname cannot be empty") - * - * @Assert\Length( - * max=255, - * ) */ + #[Assert\NotBlank(message: 'The lastname cannot be empty')] + #[Assert\Length(max: 255)] private string $lastName = ''; /** @@ -403,9 +396,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * The date of the last marital status change of the person. * * @ORM\Column(type="date", nullable=true) - * - * @Assert\Date */ + #[Assert\Date] private ?\DateTime $maritalStatusDate = null; /** @@ -451,11 +443,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * cascade={"persist", "remove", "merge", "detach"}, * orphanRemoval=true * ) - * - * @Assert\Valid( - * traverse=true, - * ) */ + #[Assert\Valid(traverse: true)] private Collection $otherPhoneNumbers; /** @@ -1410,11 +1399,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * Validation callback that checks if the accompanying periods are valid. * * This method add violation errors. - * - * @Assert\Callback( - * groups={"accompanying_period_consistent"} - * ) */ + #[Assert\Callback(groups: ['accompanying_period_consistent'])] public function isAccompanyingPeriodValid(ExecutionContextInterface $context) { $r = $this->checkAccompanyingPeriodsAreNotCollapsing(); @@ -1439,11 +1425,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * two addresses with the same validFrom date). * * This method add violation errors. - * - * @Assert\Callback( - * groups={"addresses_consistent"} - * ) */ + #[Assert\Callback(groups: ['addresses_consistent'])] public function isAddressesValid(ExecutionContextInterface $context) { if ($this->hasTwoAdressWithSameValidFromDate()) { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index c5c2c8d08..de30f059c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -28,11 +28,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * @ORM\Entity * * @ORM\Table(name="chill_person_resource") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "personResource": personResource::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['personResource' => PersonResource::class])] class PersonResource implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -41,16 +38,14 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private CommentEmbeddable $comment; /** * @ORM\Column(type="text", nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?string $freeText = null; /** @@ -59,18 +54,16 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources") * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?PersonResourceKind $kind = null; /** @@ -79,9 +72,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=Person::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?Person $person = null; /** @@ -90,18 +82,16 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="resources") * * @ORM\JoinColumn(nullable=false) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?Person $personOwner = null; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources") * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read", "docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] private ?ThirdParty $thirdParty = null; public function __construct() @@ -142,9 +132,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this->personOwner; } - /** - * @Groups({"read", "docgen:read"}) - */ + #[Groups(['read', 'docgen:read'])] public function getResourceKind(): string { if ($this->getPerson() instanceof Person) { @@ -234,9 +222,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * @Assert\Callback - */ + #[Assert\Callback] public function validate(ExecutionContextInterface $context, mixed $payload) { if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php index f036e4b4a..03def4e4d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php @@ -27,9 +27,8 @@ class PersonResourceKind * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?int $id = null; /** @@ -40,10 +39,9 @@ class PersonResourceKind /** * @ORM\Column(type="json", length=255) * - * @Serializer\Groups({"docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private array $title; public function getId(): ?int diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php index acd312190..7317a7eba 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php @@ -31,9 +31,8 @@ class ResidentialAddress * @ORM\ManyToOne(targetEntity=Address::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?Address $address = null; /** @@ -43,9 +42,8 @@ class ResidentialAddress /** * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeImmutable $endDate = null; /** @@ -53,19 +51,17 @@ class ResidentialAddress * * @ORM\JoinColumn(nullable=true) * - * @Groups({"read"}) - * * @Context(normalizationContext={"groups": {"minimal"}}) */ + #[Groups(['read'])] private ?Person $hostPerson = null; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) * * @ORM\JoinColumn(nullable=true) - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?ThirdParty $hostThirdParty = null; /** @@ -86,9 +82,8 @@ class ResidentialAddress /** * @ORM\Column(type="datetime_immutable") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private ?\DateTimeImmutable $startDate = null; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonAltName.php b/src/Bundle/ChillPersonBundle/Entity/PersonAltName.php index c17172882..e31c8b877 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonAltName.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonAltName.php @@ -34,16 +34,14 @@ class PersonAltName /** * @ORM\Column(name="key", type="string", length=255) - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $key = ''; /** * @ORM\Column(name="label", type="text") - * - * @Groups({"write"}) */ + #[Groups(['write'])] private string $label = ''; /** diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php index a8c542622..ab60a06d9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php +++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php @@ -19,11 +19,8 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * @ORM\Entity * * @ORM\Table(name="chill_person_relations") - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "relation": Relation::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['relation' => Relation::class])] class Relation { /** @@ -32,34 +29,30 @@ class Relation * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $isActive = true; /** * @ORM\Column(type="json", nullable=true) * - * @Serializer\Groups({"read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read'])] private array $reverseTitle = []; /** * @ORM\Column(type="json", nullable=true) * - * @Serializer\Groups({"read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read'])] private array $title = []; public function getId(): ?int diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php index ce56fa013..d0a7f5fd9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php +++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php @@ -30,12 +30,9 @@ use Symfony\Component\Validator\Constraints as Assert; * * @DiscriminatorColumn(name="relation_id", type="integer") * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "relationship": Relationship::class - * }) - * * @RelationshipNoDuplicate */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['relationship' => Relationship::class])] class Relationship implements TrackCreationInterface, TrackUpdateInterface { /** @@ -54,11 +51,9 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=Person::class) * * @ORM\JoinColumn(nullable=false) - * - * @Assert\NotNull - * - * @Serializer\Groups({"read", "write"}) */ + #[Assert\NotNull] + #[Serializer\Groups(['read', 'write'])] private ?Person $fromPerson = null; /** @@ -67,43 +62,33 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=Relation::class) * * @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id") - * - * @Assert\NotNull - * - * @Serializer\Groups({"read", "write"}) */ + #[Assert\NotNull] + #[Serializer\Groups(['read', 'write'])] private ?Relation $relation = null; /** * @ORM\Column(type="boolean") - * - * @Assert\Type( - * type="bool", - * message="This must be of type boolean" - * ) - * - * @Serializer\Groups({"read", "write"}) */ + #[Assert\Type(type: 'bool', message: 'This must be of type boolean')] + #[Serializer\Groups(['read', 'write'])] private bool $reverse; /** * @ORM\ManyToOne(targetEntity=Person::class) * * @ORM\JoinColumn(nullable=false) - * - * @Assert\NotNull - * - * @Serializer\Groups({"read", "write"}) */ + #[Assert\NotNull] + #[Serializer\Groups(['read', 'write'])] private ?Person $toPerson = null; /** diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index 4ec5bcf78..d7ada64d2 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -21,11 +21,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_social_work_evaluation") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "social_work_evaluation": Evaluation::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_evaluation' => Evaluation::class])] class Evaluation { /** @@ -35,9 +32,8 @@ class Evaluation /** * @ORM\Column(type="dateinterval", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateInterval $delay = null; /** @@ -46,16 +42,14 @@ class Evaluation * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="dateinterval", nullable=true, options={"default": null}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?\DateInterval $notificationDelay = null; /** @@ -71,17 +65,15 @@ class Evaluation /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $title = []; /** * @ORM\Column(type="text", nullable=true) - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?string $url = null; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php index 856e565eb..85a8d3607 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php @@ -20,14 +20,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_social_work_goal") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "social_work_goal": Goal::class - * } - * ) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_goal' => Goal::class])] class Goal { /** @@ -41,9 +35,8 @@ class Goal * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -65,10 +58,9 @@ class Goal /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $title = []; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php index c8afb0456..6cb1d1db4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php @@ -23,14 +23,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_social_work_result") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "social_work_result": Result::class - * } - * ) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_result' => Result::class])] class Result { /** @@ -65,9 +59,8 @@ class Result * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private ?int $id = null; /** @@ -80,10 +73,9 @@ class Result /** * @ORM\Column(type="json") * - * @Serializer\Groups({"read", "docgen:read"}) - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] private array $title = []; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index 19fd7395b..5aafef643 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -22,14 +22,8 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * * @ORM\Table(name="chill_person_social_action") - * - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "social_work_social_action": SocialAction::class - * } - * ) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_social_action' => SocialAction::class])] class SocialAction { /** diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 397e5a826..63e2c0566 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -21,11 +21,8 @@ use Symfony\Component\Serializer\Annotation\Groups; * @ORM\Entity * * @ORM\Table(name="chill_person_social_issue") - * - * @DiscriminatorMap(typeProperty="type", mapping={ - * "social_issue": SocialIssue::class - * }) */ +#[DiscriminatorMap(typeProperty: 'type', mapping: ['social_issue' => SocialIssue::class])] class SocialIssue { /** @@ -68,9 +65,8 @@ class SocialIssue /** * @ORM\Column(type="json") - * - * @Groups({"read"}) */ + #[Groups(['read'])] private array $title = []; public function __construct() diff --git a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php index d2a7aba55..3a2a61cad 100644 --- a/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php +++ b/src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php @@ -19,7 +19,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException; class PersonAltNameDataMapper implements DataMapperInterface { - public function mapDataToForms($viewData, iterable $forms): void + public function mapDataToForms($viewData, \Traversable $forms): void { if (null === $viewData) { return; @@ -43,7 +43,7 @@ class PersonAltNameDataMapper implements DataMapperInterface } } - public function mapFormsToData(iterable $forms, &$viewData): void + public function mapFormsToData(\Traversable $forms, &$viewData): void { $mapIndexToKey = []; diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 200a8fbac..2c6234eb0 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -62,12 +62,7 @@ final class SingleTaskController extends AbstractController private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, ) {} - /** - * @Route( - * "/{_locale}/task/single-task/{id}/delete", - * name="chill_task_single_task_delete" - * ) - */ + #[Route(path: '/{_locale}/task/single-task/{id}/delete', name: 'chill_task_single_task_delete')] public function deleteAction(Request $request, mixed $id) { $course = null; @@ -163,12 +158,7 @@ final class SingleTaskController extends AbstractController ); } - /** - * @Route( - * "/{_locale}/task/single-task/{id}/edit", - * name="chill_task_single_task_edit" - * ) - */ + #[Route(path: '/{_locale}/task/single-task/{id}/edit', name: 'chill_task_single_task_edit')] public function editAction( SingleTask $task, Request $request @@ -258,12 +248,8 @@ final class SingleTaskController extends AbstractController * - person_id * - hide_form (hide the form to filter the tasks) * - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed'. - * - * @Route( - * "/{_locale}/task/single-task/list", - * name="chill_task_singletask_list" - * ) */ + #[Route(path: '/{_locale}/task/single-task/list', name: 'chill_task_singletask_list')] public function listAction( Request $request ) { @@ -316,11 +302,7 @@ final class SingleTaskController extends AbstractController ]); } - /** - * @Route( - * "/{_locale}/task/single-task/by-course/{id}", - * name="chill_task_singletask_by-course_list") - */ + #[Route(path: '/{_locale}/task/single-task/by-course/{id}', name: 'chill_task_singletask_by-course_list')] public function listCourseTasks( AccompanyingPeriod $course, FormFactoryInterface $formFactory, @@ -367,11 +349,7 @@ final class SingleTaskController extends AbstractController ); } - /** - * @Route( - * "/{_locale}/task/single-task/by-person/{id}", - * name="chill_task_singletask_by-person_list") - */ + #[Route(path: '/{_locale}/task/single-task/by-person/{id}', name: 'chill_task_singletask_by-person_list')] public function listPersonTasks( Person $person ): Response { @@ -418,17 +396,9 @@ final class SingleTaskController extends AbstractController /** * @return Response - * - * @Route( - * "/{_locale}/task/single-task/list/my", - * name="chill_task_singletask_my_tasks", - * defaults={"_format": "html"} - * ) - * @Route( - * "/api/1.0/task/single-task/list/my", - * defaults={"_format": "json"} - * ) */ + #[Route(path: '/{_locale}/task/single-task/list/my', name: 'chill_task_singletask_my_tasks', defaults: ['_format' => 'html'])] + #[Route(path: '/api/1.0/task/single-task/list/my', defaults: ['_format' => 'json'])] public function myTasksAction(string $_format, Request $request) { $this->denyAccessUnlessGranted('ROLE_USER'); @@ -484,12 +454,7 @@ final class SingleTaskController extends AbstractController } } - /** - * @Route( - * "/{_locale}/task/single-task/new", - * name="chill_task_single_task_new" - * ) - */ + #[Route(path: '/{_locale}/task/single-task/new', name: 'chill_task_single_task_new')] public function newAction(Request $request) { $user = $this->security->getUser(); @@ -600,12 +565,7 @@ final class SingleTaskController extends AbstractController }; } - /** - * @Route( - * "/{_locale}/task/single-task/{id}/show", - * name="chill_task_single_task_show" - * ) - */ + #[Route(path: '/{_locale}/task/single-task/{id}/show', name: 'chill_task_single_task_show')] public function showAction(SingleTask $task, Request $request) { $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task); diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 5ffc202de..8837dda05 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -36,17 +36,13 @@ class TaskController extends AbstractController /** * Apply a transition to a task. * - * @Route( - * "/{_locale}/task/transition/{kind}/{taskId}/{transition}", - * name="chill_task_task_transition" - * ) - * * @param string $kind * @param int $taskId * @param string $transition * * @return Response */ + #[Route(path: '/{_locale}/task/transition/{kind}/{taskId}/{transition}', name: 'chill_task_task_transition')] public function applyTransitionAction( $kind, $taskId, diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index f9118737f..d111ada3d 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -25,20 +25,16 @@ use Symfony\Component\Validator\Constraints as Assert; * AbstractTask. * * @ORM\MappedSuperclass - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "single_task": SingleTask::class - * }) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['single_task' => SingleTask::class])] abstract class AbstractTask implements HasCenterInterface, HasScopeInterface { /** * @ORM\ManyToOne( * targetEntity="\Chill\MainBundle\Entity\User" * ) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?User $assignee = null; /** @@ -50,55 +46,47 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface /** * @ORM\Column(name="closed", type="boolean", options={ "default": false }) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $closed = false; /** * @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?AccompanyingPeriod $course = null; /** * @ORM\Column(name="current_states", type="json", options={"jsonb"=true, "default"="[]"}) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private array $currentStates = []; /** * @ORM\Column(name="description", type="text") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private string $description = ''; /** * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Person" * ) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?Person $person = null; /** * @ORM\Column(name="title", type="text") - * - * @Assert\NotBlank - * - * @Serializer\Groups({"read"}) */ + #[Assert\NotBlank] + #[Serializer\Groups(['read'])] private string $title = ''; /** * @ORM\Column(name="type", type="string", length=255) - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?string $type = null; public function getAssignee(): ?User diff --git a/src/Bundle/ChillTaskBundle/Entity/SingleTask.php b/src/Bundle/ChillTaskBundle/Entity/SingleTask.php index 5e8f8eb0b..dab5eb7e5 100644 --- a/src/Bundle/ChillTaskBundle/Entity/SingleTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/SingleTask.php @@ -47,11 +47,9 @@ class SingleTask extends AbstractTask { /** * @ORM\Column(name="end_date", type="date", nullable=true) - * - * @Assert\Date - * - * @Serializer\Groups({"read"}) */ + #[Assert\Date] + #[Serializer\Groups(['read'])] private ?\DateTime $endDate = null; /** @@ -60,9 +58,8 @@ class SingleTask extends AbstractTask * @ORM\Id * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private ?int $id = null; /** @@ -75,20 +72,11 @@ class SingleTask extends AbstractTask /** * @ORM\Column(name="start_date", type="date", nullable=true) - * - * @Serializer\Groups({"read"}) - * - * @Assert\Date - * - * @Assert\Expression( - * "value === null or this.getEndDate() === null or value < this.getEndDate()", - * message="The start date must be before the end date" - * ) - * @Assert\Expression( - * "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()", - * message="The start date must be before warning date" - * ) */ + #[Serializer\Groups(['read'])] + #[Assert\Date] + #[Assert\Expression('value === null or this.getEndDate() === null or value < this.getEndDate()', message: 'The start date must be before the end date')] + #[Assert\Expression('value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()', message: 'The start date must be before warning date')] private ?\DateTime $startDate = null; /** @@ -104,14 +92,9 @@ class SingleTask extends AbstractTask /** * @ORM\Column(name="warning_interval", type="dateinterval", nullable=true) - * - * @Serializer\Groups({"read"}) - * - * @Assert\Expression( - * "!(value != null and this.getEndDate() == null)", - * message="An end date is required if a warning interval is set" - * ) */ + #[Serializer\Groups(['read'])] + #[Assert\Expression('!(value != null and this.getEndDate() == null)', message: 'An end date is required if a warning interval is set')] private ?\DateInterval $warningInterval = null; public function __construct() @@ -164,9 +147,8 @@ class SingleTask extends AbstractTask * Return null if warningDate or endDate is null * * @return \DateTimeImmutable - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] public function getWarningDate() { if (null === $this->getWarningInterval()) { diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/AdminController.php b/src/Bundle/ChillThirdPartyBundle/Controller/AdminController.php index 559310be6..85d50e93f 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/AdminController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/AdminController.php @@ -18,9 +18,8 @@ class AdminController extends AbstractController { /** * ThirdParty admin. - * - * @Route("/{_locale}/admin/thirdparty", name="chill_thirdparty_admin_index") */ + #[Route(path: '/{_locale}/admin/thirdparty', name: 'chill_thirdparty_admin_index')] public function indexAdminAction() { return $this->render('@ChillThirdParty/Admin/index.html.twig'); diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 56a2e4dcd..ca910d854 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -92,11 +92,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * [fr] Sigle. * * @ORM\Column(name="acronym", type="string", length=64, nullable=true) - * - * @Assert\Length(min="2") - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Assert\Length(min: 2)] + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?string $acronym = ''; /** @@ -112,10 +110,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) - * * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?Address $address = null; /** @@ -136,10 +133,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * joinColumns={@ORM\JoinColumn(name="thirdparty_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")}) * - * @Groups({"docgen:read", "docgen:read:3party:parent"}) - * * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ + #[Groups(['docgen:read', 'docgen:read:3party:parent'])] private Collection $categories; /** @@ -158,33 +154,29 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * cascade={"persist"}, orphanRemoval=true) * * @var Collection - * - * @Assert\Valid(traverse=true) */ + #[Assert\Valid(traverse: true)] private Collection $children; /** * @ORM\ManyToOne(targetEntity=Civility::class) * ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true) * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) - * * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?Civility $civility = null; /** * @ORM\Column(name="comment", type="text", nullable=true) - * - * @Groups({"read", "write"}) */ + #[Groups(['read', 'write'])] private ?string $comment = null; /** * @ORM\Column(name="contact_data_anonymous", type="boolean", options={"default": false}) - * - * @Groups({"read", "docgen:read", "docgen:read:3party:parent"}) */ + #[Groups(['read', 'docgen:read', 'docgen:read:3party:parent'])] private bool $contactDataAnonymous = false; /** @@ -201,18 +193,15 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin /** * @ORM\Column(name="email", type="string", length=255, nullable=true) - * - * @Assert\Email() - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Assert\Email] + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?string $email = null; /** * @ORM\Column(name="firstname", type="text", options={"default": ""}) - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?string $firstname = ''; /** @@ -221,40 +210,32 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * @ORM\Id * * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"read", "docgen:read", "docgen:read:3party:parent"}) */ + #[Groups(['read', 'docgen:read', 'docgen:read:3party:parent'])] private ?int $id = null; /** * @ORM\Column(name="kind", type="string", length="20", options={"default": ""}) - * - * @Groups({"write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Groups(['write', 'docgen:read', 'docgen:read:3party:parent'])] private string $kind = ''; /** * @ORM\Column(name="name", type="string", length=255) - * - * @Assert\Length(min="2") - * - * @Assert\NotNull - * - * @Assert\NotBlank - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Assert\Length(min: 2)] + #[Assert\NotNull] + #[Assert\NotBlank] + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private string $name = ''; /** * [fr] Raison sociale. * * @ORM\Column(name="name_company", type="string", length=255, nullable=true) - * - * @Assert\Length(min="3") - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Assert\Length(min: 3)] + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?string $nameCompany = ''; /** @@ -264,10 +245,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") * - * @Groups({"read", "write", "docgen:read"}) - * * @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"}) */ + #[Groups(['read', 'write', 'docgen:read'])] private ?ThirdParty $parent = null; /** @@ -275,19 +255,17 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * * @ORM\Column(name="profession", type="text", nullable=false) * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) - * * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private string $profession = ''; /** * @ORM\Column(name="telephone", type="phone_number", nullable=true) * * @PhonenumberConstraint(type="any") - * - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ + #[Groups(['read', 'write', 'docgen:read', 'docgen:read:3party:parent'])] private ?PhoneNumber $telephone = null; /** @@ -546,9 +524,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin return $this->updatedBy; } - /** - * @Groups({"read", "docgen:read", "docgen:read:3party:parent"}) - */ + #[Groups(['read', 'docgen:read', 'docgen:read:3party:parent'])] public function isChild(): bool { return null !== $this->parent; diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyCategory.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyCategory.php index 7bd8f9f7b..8d29ab620 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyCategory.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyCategory.php @@ -33,16 +33,14 @@ class ThirdPartyCategory * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private ?int $id = null; /** * @ORM\Column(type="json") - * - * @Serializer\Groups({"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] private array $name = []; public function getActive(): ?bool diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php index 8994543c2..87d9d046c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php @@ -19,17 +19,14 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Table(name="chill_3party.party_profession") * * @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class) - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "third_party_profession": ThirdPartyProfession::class}) */ +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['third_party_profession' => ThirdPartyProfession::class])] class ThirdPartyProfession { /** * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) */ + #[Serializer\Groups(['read'])] private bool $active = true; /** @@ -38,16 +35,14 @@ class ThirdPartyProfession * @ORM\GeneratedValue * * @ORM\Column(type="integer") - * - * @Serializer\Groups({"docgen:read", "read", "write"}) */ + #[Serializer\Groups(['docgen:read', 'read', 'write'])] private ?int $id = null; /** * @ORM\Column(type="json") - * - * @Serializer\Groups({"docgen:read", "read"}) */ + #[Serializer\Groups(['docgen:read', 'read'])] private array $name = []; public function getActive(): ?bool From 72016e1a21edfb0e98a3979bf9f2cd54f138e3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Apr 2024 00:01:30 +0200 Subject: [PATCH 074/132] Apply rector rules: add annotation for doctrine mapping --- rector.php | 1 + .../ChillActivityBundle/Entity/Activity.php | 100 +++----- .../Entity/ActivityPresence.php | 24 +- .../Entity/ActivityReason.php | 31 +-- .../Entity/ActivityReasonCategory.php | 29 +-- .../Entity/ActivityType.php | 188 ++++----------- .../Entity/ActivityTypeCategory.php | 34 +-- .../src/Entity/AsideActivity.php | 75 ++---- .../src/Entity/AsideActivityCategory.php | 42 ++-- .../Entity/AbstractElement.php | 35 +-- .../ChillBudgetBundle/Entity/Charge.php | 27 +-- .../ChillBudgetBundle/Entity/ChargeKind.php | 38 +-- .../ChillBudgetBundle/Entity/Resource.php | 23 +- .../ChillBudgetBundle/Entity/ResourceKind.php | 43 ++-- .../ChillCalendarBundle/Entity/Calendar.php | 108 +++------ .../Entity/CalendarDoc.php | 45 ++-- .../Entity/CalendarRange.php | 47 ++-- .../Entity/CancelReason.php | 31 +-- .../ChillCalendarBundle/Entity/Invite.php | 35 +-- .../Entity/RemoteCalendarTrait.php | 8 +- .../Entity/CustomField.php | 50 ++-- .../Entity/CustomFieldLongChoice/Option.php | 50 ++-- .../Entity/CustomFieldsDefaultGroup.php | 32 +-- .../Entity/CustomFieldsGroup.php | 32 +-- .../Entity/DocGeneratorTemplate.php | 44 ++-- .../Entity/AccompanyingCourseDocument.php | 27 +-- .../ChillDocStoreBundle/Entity/Document.php | 44 +--- .../Entity/DocumentCategory.php | 23 +- .../Entity/PersonDocument.php | 26 +- .../Entity/StoredObject.php | 62 ++--- .../Controller/EventController.php | 25 +- .../Controller/ParticipationController.php | 4 - src/Bundle/ChillEventBundle/Entity/Event.php | 66 ++--- .../ChillEventBundle/Entity/EventType.php | 34 +-- .../ChillEventBundle/Entity/Participation.php | 44 ++-- src/Bundle/ChillEventBundle/Entity/Role.php | 30 +-- src/Bundle/ChillEventBundle/Entity/Status.php | 30 +-- .../Controller/ExportController.php | 5 +- .../Controller/LoginController.php | 4 +- .../Controller/PasswordController.php | 2 - .../Doctrine/Model/TrackCreationTrait.php | 12 +- .../Doctrine/Model/TrackUpdateTrait.php | 12 +- src/Bundle/ChillMainBundle/Entity/Address.php | 94 +++----- .../Entity/AddressReference.php | 73 ++---- src/Bundle/ChillMainBundle/Entity/Center.php | 36 +-- .../ChillMainBundle/Entity/Civility.php | 33 +-- src/Bundle/ChillMainBundle/Entity/Country.php | 24 +- .../Entity/CronJobExecution.php | 32 +-- .../Entity/DashboardConfigItem.php | 35 +-- .../Entity/Embeddable/CommentEmbeddable.php | 15 +- .../Embeddable/PrivateCommentEmbeddable.php | 7 +- .../Entity/GeographicalUnit.php | 39 +-- .../Entity/GeographicalUnitLayer.php | 34 +-- .../ChillMainBundle/Entity/GroupCenter.php | 49 ++-- .../ChillMainBundle/Entity/Language.php | 18 +- .../ChillMainBundle/Entity/Location.php | 73 ++---- .../ChillMainBundle/Entity/LocationType.php | 46 ++-- .../ChillMainBundle/Entity/NewsItem.php | 35 +-- .../ChillMainBundle/Entity/Notification.php | 88 +++---- .../Entity/NotificationComment.php | 65 ++--- .../Entity/PermissionsGroup.php | 42 +--- .../ChillMainBundle/Entity/PostalCode.php | 70 ++---- .../ChillMainBundle/Entity/Regroupment.php | 34 +-- .../ChillMainBundle/Entity/RoleScope.php | 44 ++-- .../ChillMainBundle/Entity/SavedExport.php | 39 +-- src/Bundle/ChillMainBundle/Entity/Scope.php | 34 +-- src/Bundle/ChillMainBundle/Entity/User.php | 100 +++----- .../Entity/User/UserJobHistory.php | 35 +-- .../Entity/User/UserScopeHistory.php | 35 +-- src/Bundle/ChillMainBundle/Entity/UserJob.php | 25 +- .../Entity/Workflow/EntityWorkflow.php | 42 ++-- .../Entity/Workflow/EntityWorkflowComment.php | 27 +-- .../Entity/Workflow/EntityWorkflowStep.php | 79 ++---- .../Tests/Export/SortExportElementTest.php | 2 +- .../Entity/AccompanyingPeriod.php | 203 +++++----------- .../AccompanyingPeriodInfo.php | 27 +-- .../AccompanyingPeriodLocationHistory.php | 39 +-- .../AccompanyingPeriodStepHistory.php | 43 ++-- .../AccompanyingPeriodWork.php | 119 +++------ .../AccompanyingPeriodWorkEvaluation.php | 84 ++----- ...companyingPeriodWorkEvaluationDocument.php | 39 +-- .../AccompanyingPeriodWorkGoal.php | 35 +-- .../AccompanyingPeriodWorkReferrerHistory.php | 33 +-- .../AccompanyingPeriod/ClosingMotive.php | 41 +--- .../Entity/AccompanyingPeriod/Comment.php | 57 ++--- .../Entity/AccompanyingPeriod/Origin.php | 26 +- .../Entity/AccompanyingPeriod/Resource.php | 60 ++--- .../Entity/AccompanyingPeriod/UserHistory.php | 43 ++-- .../AccompanyingPeriodParticipation.php | 39 +-- .../Entity/Household/Household.php | 52 ++-- .../Entity/Household/HouseholdComposition.php | 53 ++-- .../Household/HouseholdCompositionType.php | 28 +-- .../Entity/Household/HouseholdMember.php | 56 ++--- .../Household/PersonHouseholdAddress.php | 45 ++-- .../Entity/Household/Position.php | 34 +-- .../Entity/MaritalStatus.php | 18 +- .../ChillPersonBundle/Entity/Person.php | 228 +++++------------- .../Entity/Person/PersonCenterCurrent.php | 28 +-- .../Entity/Person/PersonCenterHistory.php | 31 +-- .../Entity/Person/PersonCurrentAddress.php | 27 +-- .../Entity/Person/PersonResource.php | 51 ++-- .../Entity/Person/PersonResourceKind.php | 26 +- .../Entity/Person/ResidentialAddress.php | 59 ++--- .../Entity/PersonAltName.php | 30 +-- .../Entity/PersonNotDuplicate.php | 26 +- .../ChillPersonBundle/Entity/PersonPhone.php | 45 +--- .../Entity/Relationships/Relation.php | 29 +-- .../Entity/Relationships/Relationship.php | 65 ++--- .../Entity/SocialWork/Evaluation.php | 44 +--- .../Entity/SocialWork/Goal.php | 33 +-- .../Entity/SocialWork/Result.php | 38 +-- .../Entity/SocialWork/SocialAction.php | 58 ++--- .../Entity/SocialWork/SocialIssue.php | 41 +--- .../ByStepAggregatorTest.php | 2 +- .../ByStepFilterTest.php | 2 +- .../ChillReportBundle/Entity/Report.php | 42 +--- .../ChillTaskBundle/Entity/AbstractTask.php | 47 +--- .../ChillTaskBundle/Entity/RecurringTask.php | 41 +--- .../ChillTaskBundle/Entity/SingleTask.php | 64 ++--- .../Entity/Task/AbstractTaskPlaceEvent.php | 22 +- .../Entity/Task/SingleTaskPlaceEvent.php | 40 +-- .../Entity/ThirdParty.php | 121 +++------- .../Entity/ThirdPartyCategory.php | 27 +-- .../Entity/ThirdPartyProfession.php | 27 +-- 124 files changed, 1724 insertions(+), 3770 deletions(-) diff --git a/rector.php b/rector.php index ec3020ddf..b5d6ad6ef 100644 --- a/rector.php +++ b/rector.php @@ -42,6 +42,7 @@ return static function (RectorConfig $rectorConfig): void { \Rector\Symfony\Set\SymfonySetList::SYMFONY_53, \Rector\Symfony\Set\SymfonySetList::SYMFONY_54, \Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY, + \Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, ]); // migrate for phpunit diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index ec1ae23e2..bac5df2e0 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -44,11 +44,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class Activity. * - * @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository") * - * @ORM\Table(name="activity") * - * @ORM\HasLifecycleCallbacks * * @ActivityValidator\ActivityValidity * @@ -59,6 +56,9 @@ use Symfony\Component\Validator\Constraints as Assert; * path="scope") */ #[DiscriminatorMap(typeProperty: 'type', mapping: ['activity' => Activity::class])] +#[ORM\Entity(repositoryClass: \Chill\ActivityBundle\Repository\ActivityRepository::class)] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activity')] class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, HasCentersInterface, HasScopesInterface, TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -69,157 +69,121 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac final public const SENTRECEIVED_SENT = 'sent'; - /** - * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") - */ #[Groups(['read'])] + #[ORM\ManyToOne(targetEntity: \Chill\PersonBundle\Entity\AccompanyingPeriod::class)] private ?AccompanyingPeriod $accompanyingPeriod = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") - * - * @ORM\JoinColumn(name="type_id") - */ + #[Groups(['read', 'docgen:read'])] #[SerializedName('activityType')] + #[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\ActivityType::class)] + #[ORM\JoinColumn(name: 'type_id')] private ActivityType $activityType; - /** - * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") - */ #[Groups(['docgen:read'])] + #[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\ActivityPresence::class)] private ?ActivityPresence $attendee = null; - /** - * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") - */ #[Groups(['docgen:read'])] + #[ORM\Embedded(class: \Chill\MainBundle\Entity\Embeddable\CommentEmbeddable::class, columnPrefix: 'comment_')] private CommentEmbeddable $comment; - /** - * @ORM\Column(type="datetime") - */ #[Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] private \DateTime $date; /** - * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"}) - * * @var Collection */ #[Assert\Valid(traverse: true)] + #[ORM\ManyToMany(targetEntity: \Chill\DocStoreBundle\Entity\StoredObject::class, cascade: ['persist'])] private Collection $documents; - /** - * @ORM\Column(type="time", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)] private ?\DateTime $durationTime = null; - /** - * @ORM\Column(type="boolean", options={"default": false}) - */ #[Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] private bool $emergency = false; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Location::class)] private ?Location $location = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") - */ + #[ORM\ManyToOne(targetEntity: \Chill\PersonBundle\Entity\Person::class)] private ?Person $person = null; /** - * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") - * * @var Collection */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\PersonBundle\Entity\Person::class)] private Collection $persons; - /** - * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_") - */ + #[ORM\Embedded(class: \Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable::class, columnPrefix: 'privateComment_')] private PrivateCommentEmbeddable $privateComment; /** - * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") - * * @var Collection */ #[Groups(['docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\ActivityBundle\Entity\ActivityReason::class)] private Collection $reasons; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") - */ #[Groups(['docgen:read'])] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Scope::class)] private ?Scope $scope = null; - /** - * @ORM\Column(type="string", options={"default": ""}) - */ #[Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, options: ['default' => ''])] private string $sentReceived = ''; /** - * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction") * - * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") * * @var Collection */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\PersonBundle\Entity\SocialWork\SocialAction::class)] + #[ORM\JoinTable(name: 'chill_activity_activity_chill_person_socialaction')] private Collection $socialActions; /** - * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue") * - * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") * * @var Collection */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class)] + #[ORM\JoinTable(name: 'chill_activity_activity_chill_person_socialissue')] private Collection $socialIssues; /** - * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") - * * @var Collection */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\ThirdPartyBundle\Entity\ThirdParty::class)] private Collection $thirdParties; - /** - * @ORM\Column(type="time", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)] private ?\DateTime $travelTime = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - */ #[Groups(['docgen:read'])] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)] private ?User $user = null; /** - * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") - * * @var Collection */ #[Groups(['read', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\MainBundle\Entity\User::class)] private Collection $users; public function __construct() diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index 0a558c51b..e89158abd 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -17,35 +17,29 @@ use Symfony\Component\Serializer\Annotation as Serializer; /** * Class ActivityPresence. * - * @ORM\Entity * - * @ORM\Table(name="activitytpresence") * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activitytpresence')] class ActivityPresence { - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[Serializer\Groups(['docgen:read'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** - * @ORM\Column(type="json") - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ #[Serializer\Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $name = []; /** diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php index 90d088f6f..6219acb9e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php @@ -16,38 +16,27 @@ use Doctrine\ORM\Mapping as ORM; /** * Class ActivityReason. * - * @ORM\Entity * - * @ORM\Table(name="activityreason") * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activityreason')] class ActivityReason { - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\ManyToOne( - * targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory", - * inversedBy="reasons") - */ + #[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\ActivityReasonCategory::class, inversedBy: 'reasons')] private ?ActivityReasonCategory $category = null; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; - /** - * @ORM\Column(type="json") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $name; /** diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php index 64d7f9672..bd0cecf5a 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php @@ -18,44 +18,35 @@ use Doctrine\ORM\Mapping as ORM; /** * Class ActivityReasonCategory. * - * @ORM\Entity * - * @ORM\Table(name="activityreasoncategory") * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activityreasoncategory')] class ActivityReasonCategory implements \Stringable { - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** * @var string - * - * @ORM\Column(type="json") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private $name; /** * Array of ActivityReason. * * @var Collection - * - * @ORM\OneToMany( - * targetEntity="Chill\ActivityBundle\Entity\ActivityReason", - * mappedBy="category") */ + #[ORM\OneToMany(targetEntity: \Chill\ActivityBundle\Entity\ActivityReason::class, mappedBy: 'category')] private Collection $reasons; /** diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 404cda36c..fd9a38c95 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -20,12 +20,12 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Class ActivityType. * - * @ORM\Entity * - * @ORM\Table(name="activitytype") * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activitytype')] class ActivityType { final public const FIELD_INVISIBLE = 0; @@ -36,247 +36,161 @@ class ActivityType /** * @deprecated not in use - * - * @ORM\Column(type="string", nullable=false, options={"default": ""}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $accompanyingPeriodLabel = ''; /** * @deprecated not in use - * - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE; - /** - * @ORM\Column(type="boolean") - */ #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $attendeeLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $attendeeVisible = self::FIELD_OPTIONAL; - /** - * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityTypeCategory") - */ + #[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\ActivityTypeCategory::class)] private ?ActivityTypeCategory $category = null; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $commentLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $commentVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $dateLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 2}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 2])] private int $dateVisible = self::FIELD_REQUIRED; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $documentsLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $documentsVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $durationTimeLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $durationTimeVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $emergencyLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $emergencyVisible = self::FIELD_INVISIBLE; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + #[Groups(['docgen:read'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $locationLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $locationVisible = self::FIELD_INVISIBLE; /** - * @ORM\Column(type="json") - * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ #[Groups(['read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $name = []; - /** - * @ORM\Column(type="float", options={"default": "0.0"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.0'])] private float $ordering = 0.0; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $personLabel = ''; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $personsLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $personsVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 2}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 2])] private int $personVisible = self::FIELD_REQUIRED; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $privateCommentLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $privateCommentVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $reasonsLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $reasonsVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $sentReceivedLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $sentReceivedVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $socialActionsLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $socialActionsVisible = self::FIELD_INVISIBLE; /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - * * @deprecated not in use */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $socialDataLabel = ''; /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - * * @deprecated not in use */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $socialDataVisible = self::FIELD_INVISIBLE; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $socialIssuesLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $socialIssuesVisible = self::FIELD_INVISIBLE; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $thirdPartiesLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $thirdPartiesVisible = self::FIELD_INVISIBLE; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $travelTimeLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $travelTimeVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $userLabel = ''; - /** - * @ORM\Column(type="string", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: false, options: ['default' => ''])] private string $usersLabel = ''; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - */ #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 1])] private int $usersVisible = self::FIELD_OPTIONAL; - /** - * @ORM\Column(type="smallint", nullable=false, options={"default": 2}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::SMALLINT, nullable: false, options: ['default' => 2])] private int $userVisible = self::FIELD_REQUIRED; #[Assert\Callback] diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index 680a15fa7..d70535bbf 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -13,37 +13,25 @@ namespace Chill\ActivityBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table(name="activitytypecategory") - * - * @ORM\HasLifecycleCallbacks - */ + +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'activitytypecategory')] class ActivityTypeCategory { - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; - /** - * @ORM\Column(type="json") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $name = []; - /** - * @ORM\Column(type="float", options={"default": "0.0"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.0'])] private float $ordering = 0.0; /** diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 02da401bc..ee58f31b7 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -18,79 +18,54 @@ use Chill\MainBundle\Entity\Location; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @ORM\Table(schema="chill_asideactivity") - */ + +#[ORM\Entity] +#[ORM\Table(schema: 'chill_asideactivity')] class AsideActivity implements TrackCreationInterface, TrackUpdateInterface { - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=false) - */ + #[Assert\NotBlank] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: false)] private User $agent; - /** - * @ORM\Column(type="datetime") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $createdAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=false) - */ + + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: false)] private User $createdBy; - /** - * @ORM\Column(type="datetime") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $date = null; - /** - * @ORM\Column(type="time", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $duration = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=Location::class) - * - * @ORM\JoinColumn(nullable=true) - */ + + #[ORM\ManyToOne(targetEntity: Location::class)] + #[ORM\JoinColumn(nullable: true)] private ?Location $location = null; - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $note = null; - /** - * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities") - * - * @ORM\JoinColumn(nullable=false) - */ + + #[ORM\ManyToOne(targetEntity: AsideActivityCategory::class, inversedBy: 'asideActivities')] + #[ORM\JoinColumn(nullable: false)] private ?AsideActivityCategory $type = null; - /** - * @ORM\Column(type="datetime", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $updatedAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private User $updatedBy; public function getAgent(): ?User diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index e5eb044d9..ebf09e59c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -17,51 +17,37 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; -/** - * @ORM\Entity - * - * @ORM\Table(schema="chill_asideactivity") - */ + +#[ORM\Entity] +#[ORM\Table(schema: 'chill_asideactivity')] class AsideActivityCategory { /** - * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") - * * @var Collection */ + #[ORM\OneToMany(targetEntity: AsideActivityCategory::class, mappedBy: 'parent')] private Collection $children; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private int $id; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $isActive = true; private AsideActivityCategory $oldParent; - /** - * @ORM\Column(type="float", options={"default": 0.00}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.00'])] private float $ordering = 0.00; - /** - * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children") - * - * @ORM\JoinColumn(nullable=true) - */ + + #[ORM\ManyToOne(targetEntity: AsideActivityCategory::class, inversedBy: 'children')] + #[ORM\JoinColumn(nullable: true)] private ?AsideActivityCategory $parent = null; - /** - * @ORM\Column(type="json", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255)] private array $title; public function __construct() diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index e57438f0f..a348a0d07 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -20,52 +20,33 @@ use Symfony\Component\Validator\Constraints as Assert; /** * AbstractElement. - * - * @ORM\MappedSuperclass */ +#[ORM\MappedSuperclass] abstract class AbstractElement { - /** - * @ORM\Column(name="amount", type="decimal", precision=10, scale=2) - */ #[Assert\GreaterThan(value: 0)] #[Assert\NotNull(message: 'The amount cannot be empty')] + #[ORM\Column(name: 'amount', type: \Doctrine\DBAL\Types\Types::DECIMAL, precision: 10, scale: 2)] private string $amount; - /** - * @ORM\Column(name="comment", type="text", nullable=true) - */ + #[ORM\Column(name: 'comment', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $comment = null; - /** - * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) - */ #[Assert\GreaterThan(propertyPath: 'startDate', message: "The budget element's end date must be after the start date")] + #[ORM\Column(name: 'endDate', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $endDate = null; - /** - * @ORM\ManyToOne( - * targetEntity="\Chill\PersonBundle\Entity\Household\Household" - * ) - */ + #[ORM\ManyToOne(targetEntity: Household::class)] private ?Household $household = null; - /** - * @ORM\ManyToOne( - * targetEntity="\Chill\PersonBundle\Entity\Person" - * ) - */ + #[ORM\ManyToOne(targetEntity: Person::class)] private ?Person $person = null; - /** - * @ORM\Column(name="startDate", type="datetime_immutable") - */ #[Assert\Date] + #[ORM\Column(name: 'startDate', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] private \DateTimeImmutable $startDate; - /** - * @ORM\Column(name="type", type="string", length=255) - */ + #[ORM\Column(name: 'type', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $type = ''; /* Getters and Setters */ diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index d6af5cc1e..5c78398b5 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -18,10 +18,10 @@ use Doctrine\ORM\Mapping as ORM; /** * Charge. * - * @ORM\Table(name="chill_budget.charge") * - * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository") */ +#[ORM\Entity(repositoryClass: \Chill\BudgetBundle\Repository\ChargeRepository::class)] +#[ORM\Table(name: 'chill_budget.charge')] class Charge extends AbstractElement implements HasCentersInterface { final public const HELP_ASKED = 'running'; @@ -39,25 +39,18 @@ class Charge extends AbstractElement implements HasCentersInterface self::HELP_NOT_RELEVANT, ]; - /** - * @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement") - * - * @ORM\JoinColumn - */ + + #[ORM\ManyToOne(targetEntity: ChargeKind::class, inversedBy: 'AbstractElement')] + #[ORM\JoinColumn] private ?ChargeKind $charge = null; - /** - * @ORM\Column(name="help", type="string", nullable=true) - */ + #[ORM\Column(name: 'help', type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] private ?string $help = self::HELP_NOT_RELEVANT; - /** - * @ORM\Column(name="id", type="integer") - * - * @ORM\Id - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; public function __construct() diff --git a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php index 4150d09cc..7d8037802 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php @@ -18,49 +18,35 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Type of charge. * - * @ORM\Table(name="chill_budget.charge_type", - * uniqueConstraints={@ORM\UniqueConstraint(name="charge_kind_unique_type_idx", fields={"kind"})} - * ) * - * @ORM\Entity */ #[UniqueEntity(fields: ['kind'])] +#[ORM\Entity] +#[ORM\Table(name: 'chill_budget.charge_type')] +#[ORM\UniqueConstraint(name: 'charge_kind_unique_type_idx', fields: ['kind'])] class ChargeKind { - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="boolean", options={"default": true}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $isActive = true; - /** - * @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false) - */ #[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')] #[Assert\Length(min: 3)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, options: ['default' => ''], nullable: false)] private string $kind = ''; - /** - * @ORM\Column(type="json", length=255, options={"default": "[]"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])] private array $name = []; - /** - * @ORM\Column(type="float", options={"default": 0.00}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.00'])] private float $ordering = 0.00; - /** - * @ORM\Column(type="json", length=255, options={"default": "[]"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])] private array $tags = []; public function getId(): ?int diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index c4845ed1b..c482424a8 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -18,26 +18,21 @@ use Doctrine\ORM\Mapping as ORM; /** * Resource. * - * @ORM\Table(name="chill_budget.resource") * - * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository") */ +#[ORM\Entity(repositoryClass: \Chill\BudgetBundle\Repository\ResourceRepository::class)] +#[ORM\Table(name: 'chill_budget.resource')] class Resource extends AbstractElement implements HasCentersInterface { - /** - * @ORM\Column(name="id", type="integer") - * - * @ORM\Id - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=ResourceKind::class, inversedBy="AbstractElement") - * - * @ORM\JoinColumn - */ + + #[ORM\ManyToOne(targetEntity: ResourceKind::class, inversedBy: 'AbstractElement')] + #[ORM\JoinColumn] private ?ResourceKind $resource = null; public function __construct() diff --git a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php index 2e0e360d9..30c1ac3d3 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php @@ -18,52 +18,37 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Type of resource. * - * @ORM\Table(name="chill_budget.resource_type", uniqueConstraints={ * - * @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"}) - * }) - * @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"}) - * }) - * - * @ORM\Entity */ #[UniqueEntity(fields: ['kind'])] +#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])] // @ORM\Entity +#[ORM\Table(name: 'chill_budget.resource_type')] +#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])] +#[ORM\UniqueConstraint(name: 'resource_kind_unique_type_idx', fields: ['kind'])] +#[ORM\Entity] // @ORM\Entity class ResourceKind { - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="boolean", options={"default": true}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $isActive = true; - /** - * @ORM\Column(type="string", length=255, nullable=false, options={"default": ""}) - */ #[Assert\Regex(pattern: '/^[a-z0-9\-_]{1,}$/', message: 'budget.admin.form.kind.only_alphanumeric')] #[Assert\Length(min: 3)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => ''])] private string $kind = ''; - /** - * @ORM\Column(type="json", length=255, options={"default": "[]"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])] private array $name = []; - /** - * @ORM\Column(type="float", options={"default": 0.00}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, options: ['default' => '0.00'])] private float $ordering = 0.00; - /** - * @ORM\Column(type="json", length=255, options={"default": "[]"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255, options: ['default' => '[]'])] private array $tags = []; public function getId(): ?int diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 38a7e29f0..ee148820e 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -36,15 +36,11 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Mapping\ClassMetadata; -/** - * @ORM\Table( - * name="chill_calendar.calendar", - * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} - * ) - * - * @ORM\Entity - */ + #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_calendar_calendar' => Calendar::class])] +#[ORM\Entity] +#[ORM\Table(name: 'chill_calendar.calendar')] +#[ORM\UniqueConstraint(name: 'idx_calendar_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])] class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCentersInterface { use RemoteCalendarTrait; @@ -86,105 +82,75 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente public ?User $previousMainUser = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars") - */ #[Serializer\Groups(['calendar:read', 'read'])] + #[ORM\ManyToOne(targetEntity: \Chill\PersonBundle\Entity\AccompanyingPeriod::class, inversedBy: 'calendars')] private ?AccompanyingPeriod $accompanyingPeriod = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\Activity") - */ + #[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\Activity::class)] private ?Activity $activity = null; - /** - * @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar") - */ #[Serializer\Groups(['calendar:read', 'read'])] + #[ORM\OneToOne(targetEntity: \CalendarRange::class, inversedBy: 'calendar')] private ?CalendarRange $calendarRange = null; - /** - * @ORM\ManyToOne(targetEntity="CancelReason") - */ + #[ORM\ManyToOne(targetEntity: \CancelReason::class)] private ?CancelReason $cancelReason = null; - /** - * @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_") - */ #[Serializer\Groups(['calendar:read', 'read', 'docgen:read'])] + #[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')] private CommentEmbeddable $comment; - /** - * @ORM\Column(type="integer", nullable=false, options={"default": 0}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 0])] private int $dateTimeVersion = 0; /** * @var Collection - * - * @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true) */ + #[ORM\OneToMany(targetEntity: CalendarDoc::class, mappedBy: 'calendar', orphanRemoval: true)] private Collection $documents; - /** - * @ORM\Column(type="datetime_immutable", nullable=false) - */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.An end date is required')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] private ?\DateTimeImmutable $endDate = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; /** - * @ORM\OneToMany( - * targetEntity=Invite::class, - * mappedBy="calendar", - * orphanRemoval=true, - * cascade={"persist", "remove", "merge", "detach"} - * ) * - * @ORM\JoinTable(name="chill_calendar.calendar_to_invites") * * @var Collection&Selectable */ #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\OneToMany(targetEntity: Invite::class, mappedBy: 'calendar', orphanRemoval: true, cascade: ['persist', 'remove', 'merge', 'detach'])] + #[ORM\JoinTable(name: 'chill_calendar.calendar_to_invites')] private Collection&Selectable $invites; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - */ #[Serializer\Groups(['read', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.A location is required')] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Location::class)] private ?Location $location = null; /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.A main user is mandatory')] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)] private ?User $mainUser = null; - /** - * @ORM\ManyToOne(targetEntity=Person::class) - * - * @ORM\JoinColumn(nullable=true) - */ + + #[ORM\ManyToOne(targetEntity: Person::class)] + #[ORM\JoinColumn(nullable: true)] private ?Person $person = null; /** - * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") * - * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * @@ -192,58 +158,50 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')] + #[ORM\ManyToMany(targetEntity: \Chill\PersonBundle\Entity\Person::class, inversedBy: 'calendars')] + #[ORM\JoinTable(name: 'chill_calendar.calendar_to_persons')] private Collection $persons; - /** - * @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_") - */ #[Serializer\Groups(['calendar:read'])] + #[ORM\Embedded(class: PrivateCommentEmbeddable::class, columnPrefix: 'privateComment_')] private PrivateCommentEmbeddable $privateComment; /** * @var Collection * - * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * - * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] + #[ORM\ManyToMany(targetEntity: \Chill\ThirdPartyBundle\Entity\ThirdParty::class)] + #[ORM\JoinTable(name: 'chill_calendar.calendar_to_thirdparties')] private Collection $professionals; - /** - * @ORM\Column(type="boolean", nullable=true) - */ #[Serializer\Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] private ?bool $sendSMS = false; - /** - * @ORM\Column(type="text", nullable=false, options={"default": Calendar::SMS_PENDING}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => Calendar::SMS_PENDING])] private string $smsStatus = self::SMS_PENDING; /** - * @ORM\Column(type="datetime_immutable", nullable=false) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.A start date is required')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] private ?\DateTimeImmutable $startDate = null; /** - * @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"}) - * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ #[Serializer\Groups(['calendar:read', 'read', 'calendar:light'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => 'valid'])] private string $status = self::STATUS_VALID; - /** - * @ORM\Column(type="boolean", nullable=true) - */ #[Serializer\Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] private ?bool $urgent = false; public function __construct() diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php index 5ea958fab..00493787b 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php @@ -20,50 +20,35 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table( - * name="chill_calendar.calendar_doc", - * ) - */ + +#[ORM\Entity] +#[ORM\Table(name: 'chill_calendar.calendar_doc')] class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; use TrackUpdateTrait; - /** - * @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="documents") - * - * @ORM\JoinColumn(nullable=false) - */ + + #[ORM\ManyToOne(targetEntity: Calendar::class, inversedBy: 'documents')] + #[ORM\JoinColumn(nullable: false)] private Calendar $calendar; - /** - * @ORM\Column(type="integer", nullable=false, options={"default": 0}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 0])] private int $datetimeVersion = 0; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="boolean", nullable=false, options={"default": false}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => false])] private bool $trackDateTimeVersion = false; - public function __construct(Calendar $calendar, /** - * @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}) - * - * @ORM\JoinColumn(nullable=false) - */ + public function __construct(Calendar $calendar, + #[ORM\ManyToOne(targetEntity: StoredObject::class, cascade: ['persist'])] + #[ORM\JoinColumn(nullable: false)] private ?StoredObject $storedObject) { $this->setCalendar($calendar); diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 3e2cf1eb0..633a5c1f8 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -21,14 +21,10 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Table( - * name="chill_calendar.calendar_range", - * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_range_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} - * ) - * - * @ORM\Entity - */ + +#[ORM\Entity] +#[ORM\Table(name: 'chill_calendar.calendar_range')] +#[ORM\UniqueConstraint(name: 'idx_calendar_range_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])] class CalendarRange implements TrackCreationInterface, TrackUpdateInterface { use RemoteCalendarTrait; @@ -37,49 +33,36 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface use TrackUpdateTrait; - /** - * @ORM\OneToOne(targetEntity=Calendar::class, mappedBy="calendarRange") - */ + #[ORM\OneToOne(targetEntity: Calendar::class, mappedBy: 'calendarRange')] private ?Calendar $calendar = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=false) - */ #[Groups(['read', 'write', 'calendar:read'])] #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] private ?\DateTimeImmutable $endDate = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + #[Groups(['read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=Location::class) - * - * @ORM\JoinColumn(nullable=false) - */ + #[Groups(['read', 'write', 'calendar:read'])] #[Assert\NotNull] + #[ORM\ManyToOne(targetEntity: Location::class)] + #[ORM\JoinColumn(nullable: false)] private ?Location $location = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=false) - */ #[Groups(['read', 'write', 'calendar:read'])] #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] private ?\DateTimeImmutable $startDate = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - */ #[Groups(['read', 'write', 'calendar:read'])] #[Assert\NotNull] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)] private ?User $user = null; public function getCalendar(): ?Calendar diff --git a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php index cff54e70b..75fb311fe 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php @@ -14,11 +14,9 @@ namespace Chill\CalendarBundle\Entity; use Chill\CalendarBundle\Repository\CancelReasonRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Table(name="chill_calendar.cancel_reason") - * - * @ORM\Entity(repositoryClass=CancelReasonRepository::class) - */ + +#[ORM\Entity(repositoryClass: CancelReasonRepository::class)] +#[ORM\Table(name: 'chill_calendar.cancel_reason')] class CancelReason { final public const CANCELEDBY_DONOTCOUNT = 'CANCELEDBY_DONOTCOUNT'; @@ -27,28 +25,19 @@ class CancelReason final public const CANCELEDBY_USER = 'CANCELEDBY_USER'; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private ?bool $active = null; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private ?string $canceledBy = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="json") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $name = []; public function getActive(): ?bool diff --git a/src/Bundle/ChillCalendarBundle/Entity/Invite.php b/src/Bundle/ChillCalendarBundle/Entity/Invite.php index 40024c52d..25da8fcd3 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Invite.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Invite.php @@ -25,13 +25,11 @@ use Symfony\Component\Serializer\Annotation as Serializer; * The event/calendar in the user may have a different id than the mainUser. We add then fields to store the * remote id of this event in the remote calendar. * - * @ORM\Table( - * name="chill_calendar.invite", - * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_invite_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} - * ) * - * @ORM\Entity */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_calendar.invite')] +#[ORM\UniqueConstraint(name: 'idx_calendar_invite_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])] class Invite implements TrackUpdateInterface, TrackCreationInterface { use RemoteCalendarTrait; @@ -58,33 +56,24 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface final public const TENTATIVELY_ACCEPTED = 'tentative'; - /** - * @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="invites") - */ + #[ORM\ManyToOne(targetEntity: Calendar::class, inversedBy: 'invites')] private ?Calendar $calendar = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - */ + #[Serializer\Groups(groups: ['calendar:read', 'read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="text", nullable=false, options={"default": "pending"}) - */ #[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => 'pending'])] private string $status = self::PENDING; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - * - * @ORM\JoinColumn(nullable=false) - */ + #[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])] + #[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)] + #[ORM\JoinColumn(nullable: false)] private ?User $user = null; public function getCalendar(): ?Calendar diff --git a/src/Bundle/ChillCalendarBundle/Entity/RemoteCalendarTrait.php b/src/Bundle/ChillCalendarBundle/Entity/RemoteCalendarTrait.php index 31282fb0b..b02875eed 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/RemoteCalendarTrait.php +++ b/src/Bundle/ChillCalendarBundle/Entity/RemoteCalendarTrait.php @@ -30,14 +30,10 @@ trait RemoteCalendarTrait */ public bool $preventEnqueueChanges = false; - /** - * @ORM\Column(type="json", options={"default": "[]"}, nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]'], nullable: false)] private array $remoteAttributes = []; - /** - * @ORM\Column(type="text", options={"default": ""}, nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''], nullable: false)] private string $remoteId = ''; public function addRemoteAttributes(array $remoteAttributes): self diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php index 6d1373fb0..fa60f6b91 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php @@ -16,69 +16,49 @@ use Doctrine\ORM\Mapping as ORM; /** * CustomField. * - * @ORM\Entity * - * @ORM\Table(name="customfield") * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'customfield')] class CustomField { final public const ONE_TO_MANY = 2; final public const ONE_TO_ONE = 1; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\ManyToOne( - * targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup", - * inversedBy="customFields") - */ + #[ORM\ManyToOne(targetEntity: \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class, inversedBy: 'customFields')] private ?CustomFieldsGroup $customFieldGroup = null; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - */ + + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** * @var array - * - * @ORM\Column(type="json") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private $name; - /** - * @ORM\Column(type="json") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $options = []; - /** - * @ORM\Column(type="float") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] private ?float $ordering = null; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private false $required = false; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private ?string $slug = null; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private ?string $type = null; /** diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php index 2d9889066..8afd96f81 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php @@ -15,61 +15,41 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity( - * repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository") - * - * @ORM\Table(name="custom_field_long_choice_options") - */ + +#[ORM\Entity(repositoryClass: \Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository::class)] +#[ORM\Table(name: 'custom_field_long_choice_options')] class Option { - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; /** * @var Collection