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" diff --git a/.changes/unreleased/Fixed-20240410-103736.yaml b/.changes/unreleased/Fixed-20240410-103736.yaml new file mode 100644 index 000000000..355d24b1e --- /dev/null +++ b/.changes/unreleased/Fixed-20240410-103736.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix resolving of centers for an household, which will fix in turn the access + control +time: 2024-04-10T10:37:36.462484988+02:00 +custom: + Issue: "" 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/.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/.gitlab-ci.yml b/.gitlab-ci.yml index 43f687649..e355d95de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ services: # Set any variables we need variables: + APP_ENV: test GIT_DEPTH: 1 # Configure postgres environment variables (https://hub.docker.com/r/_/postgres/) POSTGRES_USER: postgres @@ -35,7 +36,7 @@ variables: # force a timezone TZ: Europe/Brussels # avoid direct deprecations (using symfony phpunit bridge: https://symfony.com/doc/4.x/components/phpunit_bridge.html#internal-deprecations - SYMFONY_DEPRECATIONS_HELPER: max[total]=99999999&max[self]=0&max[direct]=0&verbose=1 + SYMFONY_DEPRECATIONS_HELPER: max[total]=99999999&max[self]=0&max[direct]=45&verbose=0 stages: - Composer install @@ -120,7 +121,7 @@ unit_tests: - php tests/console doctrine:migrations:migrate -n --env=test - php tests/console chill:db:sync-views --env=test - php -d memory_limit=2G tests/console cache:clear --env=test - - php -d memory_limit=3G tests/console doctrine:fixtures:load -n + - php -d memory_limit=3G tests/console doctrine:fixtures:load -n --env=test - php -d memory_limit=4G bin/phpunit --colors=never --exclude-group dbIntensive artifacts: expire_in: 1 day diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9aae1c43f..d58586b79 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -112,6 +112,7 @@ $rules = array_merge( ], 'sort_algorithm' => 'alpha', ], + 'single_line_empty_body' => true, ], $rules, $riskyRules, diff --git a/MIGRATION.md b/MIGRATION.md new file mode 100644 index 000000000..e823f0b22 --- /dev/null +++ b/MIGRATION.md @@ -0,0 +1,117 @@ + +# Switch to symfony 5.0 + +- the tag `chill.role` is now renamed to `chill_main.provide_role`. + + **Note**: It is not necessary to apply this tag on service definition: the tag is automatically applyied if the + service implements `\Chill\MainBundle\Security\ProvideRoleInterface`. + +- those annotation can be converted to attribute: + + - `Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity` + - `Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential` + - `Chill\PersonBundle\Validator\Constraints\Household\MaxHolder` + - `Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer` + - `Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity` + - `Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap` + - `Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck` + - `Chill\PersonBundle\Validator\Constraints\Person\Birthdate` + - `Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter` + - `Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate` + - `Chill\ActivityBundle\Validator\Constraints\ActivityValidity` + - `Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists` + - `Chill\MainBundle\Validation\Constraint\PhonenumberConstraint` + - `Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency` + - `Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation` + + Here is the rector rule that can be used to switch attributes to annotations: + + ```php + $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [ + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\MaxHolder'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\Birthdate'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\ActivityBundle\Validator\Constraints\ActivityValidity'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validation\Constraint\PhonenumberConstraint'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency'), + new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation'), + ]); + ``` + +- to keep cleaner definition in container's dependency injection and framework bundle, the definition of crud or api + requires to define explicitly a controller. + + Before: + + ```php + $container->prependExtensionConfig('chill_main', [ + 'apis' => [ + [ + 'class' => ThirdParty::class, + 'name' => 'thirdparty', + 'base_path' => '/api/1.0/thirdparty/thirdparty', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + Request::METHOD_POST => true, + Request::METHOD_PUT => true, + Request::METHOD_PATCH => true, + ], + 'roles' => [ + Request::METHOD_GET => ThirdPartyVoter::SHOW, + Request::METHOD_HEAD => ThirdPartyVoter::SHOW, + Request::METHOD_POST => ThirdPartyVoter::CREATE, + Request::METHOD_PUT => ThirdPartyVoter::CREATE, + Request::METHOD_PATCH => ThirdPartyVoter::CREATE, + ], + ], + ], + ], + ], + ]); + + After: + + ```php + $container->prependExtensionConfig('chill_main', [ + 'apis' => [ + [ + 'class' => ThirdParty::class, + 'controller' => ThirdPartyApiController::class, + 'name' => 'thirdparty', + 'base_path' => '/api/1.0/thirdparty/thirdparty', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + Request::METHOD_POST => true, + Request::METHOD_PUT => true, + Request::METHOD_PATCH => true, + ], + 'roles' => [ + Request::METHOD_GET => ThirdPartyVoter::SHOW, + Request::METHOD_HEAD => ThirdPartyVoter::SHOW, + Request::METHOD_POST => ThirdPartyVoter::CREATE, + Request::METHOD_PUT => ThirdPartyVoter::CREATE, + Request::METHOD_PATCH => ThirdPartyVoter::CREATE, + ], + ], + ], + ], + ], + ]); + + ``` + + diff --git a/composer.json b/composer.json index ffe87edb1..142dd8e5f 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,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", @@ -34,27 +33,47 @@ "ramsey/uuid-doctrine": "^1.7", "sensio/framework-extra-bundle": "^5.5", "spomky-labs/base64url": "^2.0", - "symfony/browser-kit": "^4.4", + "symfony/asset": "^5.4", + "symfony/browser-kit": "^5.4", + "symfony/cache": "^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/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", + "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/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", "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", @@ -74,16 +93,14 @@ "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", + "rector/rector": "^1.0.0", + "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/runtime": "^5.4", + "symfony/stopwatch": "^5.4", + "symfony/var-dumper": "^5.4" }, "conflict": { "symfony/symfony": "*" @@ -98,6 +115,8 @@ "Chill\\DocGeneratorBundle\\": "src/Bundle/ChillDocGeneratorBundle", "Chill\\DocStoreBundle\\": "src/Bundle/ChillDocStoreBundle", "Chill\\EventBundle\\": "src/Bundle/ChillEventBundle", + "Chill\\FranceTravailApiBundle\\": "src/Bundle/ChillFranceTravailApiBundle/src", + "Chill\\JobBundle\\": "src/Bundle/ChillJobBundle/src", "Chill\\MainBundle\\": "src/Bundle/ChillMainBundle", "Chill\\PersonBundle\\": "src/Bundle/ChillPersonBundle", "Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle", diff --git a/docs/source/_static/code/exports/BirthdateFilter.php b/docs/source/_static/code/exports/BirthdateFilter.php index e25d8b42f..fca768ab3 100644 --- a/docs/source/_static/code/exports/BirthdateFilter.php +++ b/docs/source/_static/code/exports/BirthdateFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface { // add specific role for this filter - public function addRole() + public function addRole(): ?string { // we do not need any new role for this filter, so we return null return null; diff --git a/docs/source/development/pagination/example.php b/docs/source/development/pagination/example.php index 964da8764..ef565e941 100644 --- a/docs/source/development/pagination/example.php +++ b/docs/source/development/pagination/example.php @@ -15,9 +15,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; class example extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { + public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) + { + } public function yourAction() { - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); // first, get the number of total item are available $total = $em ->createQuery('SELECT COUNT (item.id) FROM ChillMyBundle:Item item') diff --git a/docs/source/development/useful-snippets/controller-secured-for-person.php b/docs/source/development/useful-snippets/controller-secured-for-person.php index da2078a7a..35028f524 100644 --- a/docs/source/development/useful-snippets/controller-secured-for-person.php +++ b/docs/source/development/useful-snippets/controller-secured-for-person.php @@ -18,6 +18,9 @@ use Symfony\Component\Security\Core\Role\Role; class ConsultationController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController { + public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) + { + } /** * @param int $id personId * @@ -48,7 +51,7 @@ class ConsultationController extends \Symfony\Bundle\FrameworkBundle\Controller\ ); // create a query which take circles into account - $consultations = $this->getDoctrine()->getManager() + $consultations = $this->managerRegistry->getManager() ->createQuery('SELECT c FROM ChillHealthBundle:Consultation c ' . 'WHERE c.patient = :person AND c.circle IN(:circles) ' . 'ORDER BY c.date DESC') diff --git a/package.json b/package.json index 6b494a68d..634cee4b6 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,15 @@ "@ckeditor/ckeditor5-vue": "^4.0.1", "@symfony/webpack-encore": "^4.1.0", "@tsconfig/node14": "^1.0.1", + "@types/dompurify": "^3.0.5", "bindings": "^1.5.0", "bootstrap": "5.2.3", "chokidar": "^3.5.1", + "dompurify": "^3.1.0", "fork-awesome": "^1.1.7", "jquery": "^3.6.0", "node-sass": "^8.0.0", + "marked": "^12.0.1", "popper.js": "^1.16.1", "postcss-loader": "^7.0.2", "raw-loader": "^4.0.2", @@ -46,7 +49,7 @@ "es6-promise": "^4.2.8", "leaflet": "^1.7.1", "masonry-layout": "^4.2.2", - "mime": "^3.0.0", + "mime": "^4.0.0", "swagger-ui": "^4.15.5", "vis-network": "^9.1.0", "vue": "^3.2.37", diff --git a/phpstan-baseline-deprecations-doctrine-orm.neon b/phpstan-baseline-deprecations-doctrine-orm.neon new file mode 100644 index 000000000..824c0371f --- /dev/null +++ b/phpstan-baseline-deprecations-doctrine-orm.neon @@ -0,0 +1,58 @@ +# See https://github.com/doctrine/orm/issues/11313 for a follow-up +parameters: + ignoreErrors: + - + message: """ + #^Fetching deprecated class constant ASC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Ascending instead$# + """ + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php + + - + message: """ + #^Fetching deprecated class constant ASC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Ascending instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Entity/Notification.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 2 + path: src/Bundle/ChillPersonBundle/Entity/Household/Household.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 2 + path: src/Bundle/ChillPersonBundle/Entity/Person.php + + - + message: """ + #^Fetching deprecated class constant DESC of class Doctrine\\\\Common\\\\Collections\\\\Criteria\\: + use Order\\:\\:Descending instead$# + """ + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php diff --git a/phpstan-baseline-level-5.neon b/phpstan-baseline-level-5.neon index 23321ba68..34e2825a3 100644 --- a/phpstan-baseline-level-5.neon +++ b/phpstan-baseline-level-5.neon @@ -100,11 +100,6 @@ parameters: count: 1 path: src/Bundle/ChillEventBundle/Controller/EventController.php - - - message: "#^Parameter \\#1 \\$name of method Symfony\\\\Component\\\\Form\\\\FormFactoryInterface\\:\\:createNamedBuilder\\(\\) expects string, null given\\.$#" - count: 1 - path: src/Bundle/ChillEventBundle/Controller/EventController.php - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, Chill\\\\MainBundle\\\\Entity\\\\Center given\\.$#" count: 1 @@ -165,11 +160,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Controller/ExportController.php - - - message: "#^Parameter \\#1 \\$name of method Symfony\\\\Component\\\\Form\\\\FormFactoryInterface\\:\\:createNamedBuilder\\(\\) expects string, null given\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Controller/ExportController.php - - message: "#^Parameter \\#3 \\$alias of method Chill\\\\MainBundle\\\\Controller\\\\ExportController\\:\\:exportFormStep\\(\\) expects string, Symfony\\\\Component\\\\HttpFoundation\\\\Request given\\.$#" count: 1 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a89386f29..641bb5dcd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5,6 +5,26 @@ parameters: count: 1 path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php + + - + message: "#^Property Chill\\\\CustomFieldsBundle\\\\Entity\\\\CustomField\\:\\:\\$required \\(false\\) does not accept bool\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php + + - + message: "#^Parameter \\#1 \\$user of method Chill\\\\DocStoreBundle\\\\Entity\\\\Document\\:\\:setUser\\(\\) expects Chill\\\\MainBundle\\\\Entity\\\\User\\|null, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#" + count: 2 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php + + - + message: "#^Parameter \\#1 \\$user of method Chill\\\\DocStoreBundle\\\\Entity\\\\Document\\:\\:setUser\\(\\) expects Chill\\\\MainBundle\\\\Entity\\\\User\\|null, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#" + count: 2 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php + - message: "#^Variable \\$participation might not be defined\\.$#" count: 3 @@ -15,6 +35,106 @@ parameters: count: 1 path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php + - + message: "#^Comparison operation \"\\>\" between \\(bool\\|int\\|Redis\\) and 0 results in an error\\.$#" + count: 1 + path: src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php + + - + message: "#^Variable \\$response might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php + + - + message: "#^Function GuzzleHttp\\\\Psr7\\\\get not found\\.$#" + count: 1 + path: src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php + + - + message: "#^Function GuzzleHttp\\\\Psr7\\\\str not found\\.$#" + count: 2 + path: src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php + + - + message: "#^Parameter \\#1 \\$seconds of function sleep expects int, string given\\.$#" + count: 1 + path: src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Controller/CSPersonController.php + + - + message: "#^Parameter \\#1 \\$interval of method DateTimeImmutable\\:\\:add\\(\\) expects DateInterval, string\\|null given\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Entity/Immersion.php + + - + message: "#^Parameter \\#1 \\$object of static method DateTimeImmutable\\:\\:createFromMutable\\(\\) expects DateTime, DateTimeInterface given\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Entity/Immersion.php + + - + message: "#^Property Chill\\\\JobBundle\\\\Entity\\\\Rome\\\\Metier\\:\\:\\$appellations is never read, only written\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Entity/Rome/Metier.php + + - + message: "#^Method Chill\\\\JobBundle\\\\Export\\\\ListCSPerson\\:\\:splitArrayToColumns\\(\\) never returns Closure so it can be removed from the return type\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php + + - + message: "#^Variable \\$f might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Export/ListCSPerson.php + + - + message: "#^Method Chill\\\\JobBundle\\\\Export\\\\ListFrein\\:\\:splitArrayToColumns\\(\\) never returns Closure so it can be removed from the return type\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Export/ListFrein.php + + - + message: "#^Method Chill\\\\JobBundle\\\\Export\\\\ListProjetProfessionnel\\:\\:splitArrayToColumns\\(\\) never returns Closure so it can be removed from the return type\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php + + - + message: "#^Property Chill\\\\JobBundle\\\\Form\\\\ChoiceLoader\\\\RomeAppellationChoiceLoader\\:\\:\\$appellationRepository \\(Chill\\\\JobBundle\\\\Repository\\\\Rome\\\\AppellationRepository\\) does not accept Doctrine\\\\ORM\\\\EntityRepository\\\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php + + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php + + - + message: "#^Strict comparison using \\=\\=\\= between array\\{\\} and Symfony\\\\Component\\\\Validator\\\\ConstraintViolationListInterface will always evaluate to false\\.$#" + count: 2 + path: src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php + + - + message: "#^Variable \\$metier might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Form/ChoiceLoader/RomeAppellationChoiceLoader.php + + - + message: "#^Parameter \\#1 \\$interval of method DateTimeImmutable\\:\\:add\\(\\) expects DateInterval, string\\|null given\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Security/Authorization/CSConnectesVoter.php + + - + message: "#^Parameter \\#1 \\$object of static method DateTimeImmutable\\:\\:createFromMutable\\(\\) expects DateTime, DateTimeInterface given\\.$#" + count: 1 + path: src/Bundle/ChillJobBundle/src/Security/Authorization/CSConnectesVoter.php + - message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#" count: 1 @@ -40,11 +160,31 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Repository/NotificationRepository.php + + - + message: "#^Parameter \\#1 \\$user of method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:userHasAccessForCenter\\(\\) expects Chill\\\\MainBundle\\\\Entity\\\\User, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php + - message: "#^Foreach overwrites \\$value with its value variable\\.$#" count: 1 path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/PersonType.php + - message: "#^Foreach overwrites \\$value with its value variable\\.$#" count: 1 diff --git a/phpstan-deprecations-sf54.neon b/phpstan-deprecations-sf54.neon new file mode 100644 index 000000000..e2e5e85a6 --- /dev/null +++ b/phpstan-deprecations-sf54.neon @@ -0,0 +1,153 @@ +parameters: + ignoreErrors: + - + 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 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 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 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 getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 2 + 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: """ + #^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 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 getUsername\\(\\) of class Chill\\\\MainBundle\\\\Entity\\\\User\\: + since Symfony 5\\.3, use getUserIdentifier\\(\\) instead$# + """ + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.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: """ + #^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: """ + #^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 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 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 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 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..e09bb5081 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -31,4 +31,5 @@ includes: - phpstan-baseline-level-3.neon - phpstan-baseline-level-4.neon - phpstan-baseline-level-5.neon - + - phpstan-deprecations-sf54.neon + - phpstan-baseline-deprecations-doctrine-orm.neon diff --git a/phpunit.rector.xml b/phpunit.rector.xml index f8d9d3a11..25e0d25aa 100644 --- a/phpunit.rector.xml +++ b/phpunit.rector.xml @@ -1,29 +1,13 @@ - - - - utils/rector/tests - - - - - - utils/rector/src - - + + + + utils/rector/tests + + + + + utils/rector/src + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa519e376..336877a0c 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/ - - - - - - - - - + +

Projets professionnels

+ + {% if projet_professionnels|length == 0 %} +

{{ null|chill_print_or_message("Aucun rapport enregistré") }}

+ {% else %} + + + + + + + + + + + {% for pr in projet_professionnels %} + + + + + + + + {% endfor %} + +
Date de créationProjet validé ou souhaitéType de contrat 
{{ pr.reportDate|format_date('short') }} + {% set romes = [] %} + {% if pr.valide|length > 0 %} +

Projet validé :

+ {% set romes = pr.valide %} + {% elseif pr.souhait|length > 0 %} +

Projet souhaité :

+ {% set romes = pr.souhait %} + {% else %} +

Aucun souhait rempli

+ {% endif %} + +
    + {% for a in romes %} +
  • {{ a.libelle }} ({{ a.metier.code }} - {{ a.metier.libelle }})
  • + {% endfor %} +
+
+
    + {% for type in pr.typeContrat %} +
  • {{ ('projet_prof.type_contrat.' ~ type)|trans }}
  • + {% endfor %} +
+
+
    +
  • + +
  • +
  • + +
  • + {% if is_granted('CHILL_JOB_REPORT_DELETE', pr) %} +
  • + +
  • + {% endif %} +
+
+ {% endif %} + + + {% endif %} + + +{% endblock %} diff --git a/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsJobVoter.php b/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsJobVoter.php new file mode 100644 index 000000000..af4935893 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/Security/Authorization/ExportsJobVoter.php @@ -0,0 +1,122 @@ +authorizationHelper = $authorizationHelper; + } + + /** + * @return bool + */ + protected function supports($attribute, $subject) + { + if ($subject instanceof Center) { + return self::EXPORT === $attribute; + } + if (null === $subject) { + return self::EXPORT === $attribute; + } + + return false; + } + + /** + * @return bool + */ + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) + { + $user = $token->getUser(); + + if (!$user instanceof User) { + return false; + } + + $centers = $this->authorizationHelper->getReachableCenters($user, $attribute); + + if (null === $subject) { + return count($centers) > 0; + } + + return $this->authorizationHelper->userHasAccess($user, $subject, $attribute); + } + + /** + * Return an array of roles, where keys are the hierarchy, and values + * an array of roles. + * + * Example: + * + * ``` + * [ 'Title' => [ 'CHILL_FOO_SEE', 'CHILL_FOO_UPDATE' ] ] + * ``` + */ + public function getRolesWithHierarchy(): array + { + return ['JobBundle' => $this->getRoles()]; + } + + /** + * return an array of role provided by the object. + * + * @return string[] array of roles (as string) + */ + public function getRoles(): array + { + return $this->getAttributes(); + } + + /** + * return roles which doesn't need. + * + * @return string[] array of roles without scopes + */ + public function getRolesWithoutScope(): array + { + return $this->getAttributes(); + } + + /** + * @return array + */ + private function getAttributes() + { + return [self::EXPORT]; + } +} diff --git a/src/Bundle/ChillJobBundle/src/Security/Authorization/JobVoter.php b/src/Bundle/ChillJobBundle/src/Security/Authorization/JobVoter.php new file mode 100644 index 000000000..54de180f5 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/Security/Authorization/JobVoter.php @@ -0,0 +1,119 @@ +date15DaysAgo = new \DateTime('-15 days'); + $this->authorizationHelper = $authorizationHelper; + } + + protected function supports($attribute, $subject) + { + if (!\in_array($attribute, self::ALL, true)) { + return false; + } + + if ($subject instanceof Frein + || $subject instanceof CV + || $subject instanceof Immersion + || $subject instanceof ProjetProfessionnel + || $subject instanceof Person) { + return true; + } + + return false; + } + + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) + { + if ($subject instanceof Person) { + $center = $subject->getCenter(); + } else { + $center = $subject->getPerson()->getCenter(); + } + + switch ($attribute) { + case self::REPORT_NEW: + return $this->authorizationHelper->userHasAccess($token->getUser(), $center, $attribute); + + case self::REPORT_CV: + if (! ($subject instanceof CV || $subject instanceof Person)) { + return false; + } + + return $this->authorizationHelper->userHasAccess($token->getUser(), $center, $attribute); + + case self::REPORT_DELETE: + if ($subject instanceof Immersion) { + $date = \DateTimeImmutable::createFromMutable($subject->getDebutDate())->add($subject->getDuration()); + } else { + $date = $subject->getReportDate(); + } + + if (!$this->authorizationHelper->userHasAccess($token->getUser(), $center, $attribute)) { + return false; + } + + return $this->date15DaysAgo < $date; + } + + return true; + } + + public function getRoles(): array + { + return self::ALL; + } + + public function getRolesWithHierarchy(): array + { + return ['JobBundle' => $this->getRoles()]; + } + + public function getRolesWithoutScope(): array + { + return $this->getRoles(); + } +} diff --git a/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php b/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php new file mode 100644 index 000000000..a6b19e648 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/Tests/Controller/CSPersonControllerTest.php @@ -0,0 +1,21 @@ +addSql('CREATE SCHEMA chill_job'); + $this->addSql('CREATE SEQUENCE chill_job.cv_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.cv_experience_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.cv_formation_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.frein_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.immersion_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.projet_professionnel_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.rome_appellation_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_job.rome_metier_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_job.cs_person (id INT NOT NULL, person_id INT DEFAULT NULL, prescripteur_id INT DEFAULT NULL, situationLogement VARCHAR(255) DEFAULT NULL, situationLogementPrecision TEXT DEFAULT NULL, enfantACharge INT DEFAULT NULL, niveauMaitriseLangue JSON DEFAULT NULL, vehiculePersonnel BOOLEAN DEFAULT NULL, permisConduire JSON DEFAULT NULL, situationProfessionnelle VARCHAR(255) DEFAULT NULL, dateFinDernierEmploi DATE DEFAULT NULL, typeContrat JSON DEFAULT NULL, typeContratAide TEXT DEFAULT NULL, ressources JSON DEFAULT NULL, ressourcesComment TEXT DEFAULT NULL, ressourceDate1Versement DATE DEFAULT NULL, CPFMontant NUMERIC(10, 2) DEFAULT NULL, acomptedif NUMERIC(10, 2) DEFAULT NULL, accompagnement JSON DEFAULT NULL, accompagnementRQTHDate DATE DEFAULT NULL, accompagnementComment VARCHAR(255) DEFAULT NULL, poleEmploiId VARCHAR(255) DEFAULT NULL, poleEmploiInscriptionDate DATE DEFAULT NULL, cafId VARCHAR(255) DEFAULT NULL, cafInscriptionDate DATE DEFAULT NULL, CERInscriptionDate DATE DEFAULT NULL, PPAEInscriptionDate DATE DEFAULT NULL, CERSignataire TEXT DEFAULT NULL, PPAESignataire TEXT DEFAULT NULL, NEETEligibilite VARCHAR(255) DEFAULT NULL, NEETCommissionDate DATE DEFAULT NULL, FSEMaDemarcheCode TEXT DEFAULT NULL, datecontratIEJ DATE DEFAULT NULL, dateavenantIEJ DATE DEFAULT NULL, dispositifs_notes TEXT DEFAULT NULL, handicap BOOLEAN DEFAULT NULL, handicapnotes TEXT DEFAULT NULL, handicapRecommandation VARCHAR(50) DEFAULT NULL, mobilitemoyentransport JSON DEFAULT NULL, mobilitenotes TEXT DEFAULT NULL, handicapAccompagnement_id INT DEFAULT NULL, documentCV_id INT DEFAULT NULL, documentAgrementIAE_id INT DEFAULT NULL, documentRQTH_id INT DEFAULT NULL, documentAttestationNEET_id INT DEFAULT NULL, documentCI_id INT DEFAULT NULL, documentTitreSejour_id INT DEFAULT NULL, documentAttestationFiscale_id INT DEFAULT NULL, documentPermis_id INT DEFAULT NULL, documentAttestationCAAF_id INT DEFAULT NULL, documentContraTravail_id INT DEFAULT NULL, documentAttestationFormation_id INT DEFAULT NULL, documentQuittanceLoyer_id INT DEFAULT NULL, documentFactureElectricite_id INT DEFAULT NULL, documentAttestationSecuriteSociale_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_10864F31217BBB47 ON chill_job.cs_person (person_id)'); + $this->addSql('CREATE INDEX IDX_10864F312654B57D ON chill_job.cs_person (handicapAccompagnement_id)'); + $this->addSql('CREATE INDEX IDX_10864F3154866550 ON chill_job.cs_person (documentCV_id)'); + $this->addSql('CREATE INDEX IDX_10864F318825E118 ON chill_job.cs_person (documentAgrementIAE_id)'); + $this->addSql('CREATE INDEX IDX_10864F31A396AFAC ON chill_job.cs_person (documentRQTH_id)'); + $this->addSql('CREATE INDEX IDX_10864F3187541764 ON chill_job.cs_person (documentAttestationNEET_id)'); + $this->addSql('CREATE INDEX IDX_10864F315CFC2299 ON chill_job.cs_person (documentCI_id)'); + $this->addSql('CREATE INDEX IDX_10864F3134FDF11D ON chill_job.cs_person (documentTitreSejour_id)'); + $this->addSql('CREATE INDEX IDX_10864F315742C99D ON chill_job.cs_person (documentAttestationFiscale_id)'); + $this->addSql('CREATE INDEX IDX_10864F31166494D4 ON chill_job.cs_person (documentPermis_id)'); + $this->addSql('CREATE INDEX IDX_10864F3172820D66 ON chill_job.cs_person (documentAttestationCAAF_id)'); + $this->addSql('CREATE INDEX IDX_10864F31AFA5E636 ON chill_job.cs_person (documentContraTravail_id)'); + $this->addSql('CREATE INDEX IDX_10864F3161E05C22 ON chill_job.cs_person (documentAttestationFormation_id)'); + $this->addSql('CREATE INDEX IDX_10864F316F744BB0 ON chill_job.cs_person (documentQuittanceLoyer_id)'); + $this->addSql('CREATE INDEX IDX_10864F31AC39B1B ON chill_job.cs_person (documentFactureElectricite_id)'); + $this->addSql('CREATE INDEX IDX_10864F3172A75B6D ON chill_job.cs_person (documentAttestationSecuriteSociale_id)'); + $this->addSql('CREATE INDEX IDX_10864F31D486E642 ON chill_job.cs_person (prescripteur_id)'); + $this->addSql('CREATE TABLE chill_job.cv (id INT NOT NULL, person_id INT DEFAULT NULL, reportDate DATE NOT NULL, formationLevel VARCHAR(255) DEFAULT NULL, formationType VARCHAR(255) DEFAULT NULL, spokenLanguages JSON DEFAULT NULL, notes TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_3F24F812217BBB47 ON chill_job.cv (person_id)'); + $this->addSql('CREATE TABLE chill_job.cv_experience (id INT NOT NULL, poste TEXT DEFAULT NULL, structure TEXT DEFAULT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, contratType VARCHAR(100) NOT NULL, notes TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_102A1262AE1799D8 ON chill_job.cv_experience (CV_id)'); + $this->addSql('CREATE TABLE chill_job.cv_formation (id INT NOT NULL, title TEXT NOT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, diplomaObtained VARCHAR(255) DEFAULT NULL, diplomaReconnue VARCHAR(50) DEFAULT NULL, organisme TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_20BE09E2AE1799D8 ON chill_job.cv_formation (CV_id)'); + $this->addSql('CREATE TABLE chill_job.frein (id INT NOT NULL, reportDate DATE NOT NULL, freinsPerso JSON NOT NULL, notesPerso TEXT NOT NULL, freinsEmploi JSON NOT NULL, notesEmploi TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.immersion (id INT NOT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, structureAccEmail TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSON DEFAULT NULL, objectifsAutre TEXT DEFAULT NULL, is_bilan_fullfilled BOOLEAN DEFAULT false NOT NULL, savoirEtre JSON DEFAULT NULL, savoirEtreNote TEXT DEFAULT NULL, noteimmersion TEXT NOT NULL, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, ponctualite_salarie TEXT DEFAULT NULL, ponctualite_salarie_note TEXT DEFAULT NULL, assiduite TEXT DEFAULT NULL, assiduite_note TEXT DEFAULT NULL, interet_activite TEXT DEFAULT NULL, interet_activite_note TEXT DEFAULT NULL, integre_regle TEXT DEFAULT NULL, integre_regle_note TEXT DEFAULT NULL, esprit_initiative TEXT DEFAULT NULL, esprit_initiative_note TEXT DEFAULT NULL, organisation TEXT DEFAULT NULL, organisation_note TEXT DEFAULT NULL, capacite_travail_equipe TEXT DEFAULT NULL, capacite_travail_equipe_note TEXT DEFAULT NULL, style_vestimentaire TEXT DEFAULT NULL, style_vestimentaire_note TEXT DEFAULT NULL, langage_prof TEXT DEFAULT NULL, langage_prof_note TEXT DEFAULT NULL, applique_consigne TEXT DEFAULT NULL, applique_consigne_note TEXT DEFAULT NULL, respect_hierarchie TEXT DEFAULT NULL, respect_hierarchie_note TEXT DEFAULT NULL, structureAccAddress_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4A4AEAFEA ON chill_job.immersion (entreprise_id)'); + $this->addSql('CREATE INDEX IDX_FBB3CBB435E47E35 ON chill_job.immersion (referent_id)'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4B5E04267 ON chill_job.immersion (structureAccAddress_id)'); + $this->addSql('COMMENT ON COLUMN chill_job.immersion.duration IS \'(DC2Type:dateinterval)\''); + $this->addSql('CREATE TABLE chill_job.projet_professionnel (id INT NOT NULL, reportDate DATE NOT NULL, domaineActiviteSouhait TEXT DEFAULT NULL, typeContrat JSON DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, volumeHoraire JSON DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, domaineActiviteValide TEXT DEFAULT NULL, valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.projetprofessionnel_souhait (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); + $this->addSql('CREATE INDEX IDX_3280B96DB87BF7B5 ON chill_job.projetprofessionnel_souhait (projetprofessionnel_id)'); + $this->addSql('CREATE INDEX IDX_3280B96D7CDE30DD ON chill_job.projetprofessionnel_souhait (appellation_id)'); + $this->addSql('CREATE TABLE chill_job.projetprofessionnel_valide (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); + $this->addSql('CREATE INDEX IDX_E0501BE0B87BF7B5 ON chill_job.projetprofessionnel_valide (projetprofessionnel_id)'); + $this->addSql('CREATE INDEX IDX_E0501BE07CDE30DD ON chill_job.projetprofessionnel_valide (appellation_id)'); + $this->addSql('CREATE TABLE chill_job.rome_appellation (id INT NOT NULL, metier_id INT DEFAULT NULL, code VARCHAR(40) NOT NULL, libelle TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_D9E9CABC77153098 ON chill_job.rome_appellation (code)'); + $this->addSql('CREATE INDEX IDX_D9E9CABCED16FA20 ON chill_job.rome_appellation (metier_id)'); + $this->addSql('CREATE TABLE chill_job.rome_metier (id INT NOT NULL, libelle TEXT NOT NULL, code VARCHAR(20) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_3274952577153098 ON chill_job.rome_metier (code)'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F312654B57D FOREIGN KEY (handicapAccompagnement_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3154866550 FOREIGN KEY (documentCV_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F318825E118 FOREIGN KEY (documentAgrementIAE_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31A396AFAC FOREIGN KEY (documentRQTH_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3187541764 FOREIGN KEY (documentAttestationNEET_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F315CFC2299 FOREIGN KEY (documentCI_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3134FDF11D FOREIGN KEY (documentTitreSejour_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F315742C99D FOREIGN KEY (documentAttestationFiscale_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31166494D4 FOREIGN KEY (documentPermis_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3172820D66 FOREIGN KEY (documentAttestationCAAF_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31AFA5E636 FOREIGN KEY (documentContraTravail_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3161E05C22 FOREIGN KEY (documentAttestationFormation_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F316F744BB0 FOREIGN KEY (documentQuittanceLoyer_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31AC39B1B FOREIGN KEY (documentFactureElectricite_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F3172A75B6D FOREIGN KEY (documentAttestationSecuriteSociale_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cs_person ADD CONSTRAINT FK_10864F31D486E642 FOREIGN KEY (prescripteur_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cv ADD CONSTRAINT FK_3F24F812217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cv_experience ADD CONSTRAINT FK_102A1262AE1799D8 FOREIGN KEY (CV_id) REFERENCES chill_job.cv (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.cv_formation ADD CONSTRAINT FK_20BE09E2AE1799D8 FOREIGN KEY (CV_id) REFERENCES chill_job.cv (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.immersion ADD CONSTRAINT FK_FBB3CBB4A4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.immersion ADD CONSTRAINT FK_FBB3CBB435E47E35 FOREIGN KEY (referent_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.immersion ADD CONSTRAINT FK_FBB3CBB4B5E04267 FOREIGN KEY (structureAccAddress_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_souhait ADD CONSTRAINT FK_3280B96DB87BF7B5 FOREIGN KEY (projetprofessionnel_id) REFERENCES chill_job.projet_professionnel (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_souhait ADD CONSTRAINT FK_3280B96D7CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_job.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE0B87BF7B5 FOREIGN KEY (projetprofessionnel_id) REFERENCES chill_job.projet_professionnel (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE07CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_job.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_job.rome_appellation ADD CONSTRAINT FK_D9E9CABCED16FA20 FOREIGN KEY (metier_id) REFERENCES chill_job.rome_metier (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP SEQUENCE chill_job.cv_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.cv_experience_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.cv_formation_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.frein_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.immersion_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.projet_professionnel_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.rome_appellation_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_job.rome_metier_id_seq CASCADE'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31217BBB47'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F312654B57D'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3154866550'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F318825E118'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31A396AFAC'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3187541764'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F315CFC2299'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3134FDF11D'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F315742C99D'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31166494D4'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3172820D66'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31AFA5E636'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3161E05C22'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F316F744BB0'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31AC39B1B'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F3172A75B6D'); + $this->addSql('ALTER TABLE chill_job.cs_person DROP CONSTRAINT FK_10864F31D486E642'); + $this->addSql('ALTER TABLE chill_job.cv DROP CONSTRAINT FK_3F24F812217BBB47'); + $this->addSql('ALTER TABLE chill_job.cv_experience DROP CONSTRAINT FK_102A1262AE1799D8'); + $this->addSql('ALTER TABLE chill_job.cv_formation DROP CONSTRAINT FK_20BE09E2AE1799D8'); + $this->addSql('ALTER TABLE chill_job.immersion DROP CONSTRAINT FK_FBB3CBB4A4AEAFEA'); + $this->addSql('ALTER TABLE chill_job.immersion DROP CONSTRAINT FK_FBB3CBB435E47E35'); + $this->addSql('ALTER TABLE chill_job.immersion DROP CONSTRAINT FK_FBB3CBB4B5E04267'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_souhait DROP CONSTRAINT FK_3280B96DB87BF7B5'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_souhait DROP CONSTRAINT FK_3280B96D7CDE30DD'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_valide DROP CONSTRAINT FK_E0501BE0B87BF7B5'); + $this->addSql('ALTER TABLE chill_job.projetprofessionnel_valide DROP CONSTRAINT FK_E0501BE07CDE30DD'); + $this->addSql('ALTER TABLE chill_job.rome_appellation DROP CONSTRAINT FK_D9E9CABCED16FA20'); + $this->addSql('DROP TABLE chill_job.cs_person'); + $this->addSql('DROP TABLE chill_job.cv'); + $this->addSql('DROP TABLE chill_job.cv_experience'); + $this->addSql('DROP TABLE chill_job.cv_formation'); + $this->addSql('DROP TABLE chill_job.frein'); + $this->addSql('DROP TABLE chill_job.immersion'); + $this->addSql('DROP TABLE chill_job.projet_professionnel'); + $this->addSql('DROP TABLE chill_job.projetprofessionnel_souhait'); + $this->addSql('DROP TABLE chill_job.projetprofessionnel_valide'); + $this->addSql('DROP TABLE chill_job.rome_appellation'); + $this->addSql('DROP TABLE chill_job.rome_metier'); + $this->addSql('DROP SCHEMA chill_job'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20240424140641.php b/src/Bundle/ChillJobBundle/src/migrations/Version20240424140641.php new file mode 100644 index 000000000..87c9d3623 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20240424140641.php @@ -0,0 +1,46 @@ +addSql('ALTER TABLE chill_job.frein ADD person_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_job.frein ADD CONSTRAINT FK_172EAC0A217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_172EAC0A217BBB47 ON chill_job.frein (person_id)'); + $this->addSql('ALTER TABLE chill_job.immersion ADD person_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_job.immersion ADD CONSTRAINT FK_FBB3CBB4217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4217BBB47 ON chill_job.immersion (person_id)'); + $this->addSql('ALTER TABLE chill_job.projet_professionnel ADD person_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_job.projet_professionnel ADD CONSTRAINT FK_12E4FFBF217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_12E4FFBF217BBB47 ON chill_job.projet_professionnel (person_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_job.projet_professionnel DROP CONSTRAINT FK_12E4FFBF217BBB47'); + $this->addSql('ALTER TABLE chill_job.projet_professionnel DROP person_id'); + $this->addSql('ALTER TABLE chill_job.immersion DROP CONSTRAINT FK_FBB3CBB4217BBB47'); + $this->addSql('ALTER TABLE chill_job.immersion DROP person_id'); + $this->addSql('ALTER TABLE chill_job.frein DROP CONSTRAINT FK_172EAC0A217BBB47'); + $this->addSql('ALTER TABLE chill_job.frein DROP person_id'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20240429111628.php b/src/Bundle/ChillJobBundle/src/migrations/Version20240429111628.php new file mode 100644 index 000000000..e12318d7c --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20240429111628.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_job.immersion ALTER tuteurphonenumber TYPE VARCHAR(35)'); + $this->addSql('COMMENT ON COLUMN chill_job.immersion.tuteurPhoneNumber IS \'(DC2Type:phone_number)\''); + + $this->addSql('ALTER TABLE chill_job.immersion ALTER structureAccPhonenumber TYPE VARCHAR(35)'); + $this->addSql('COMMENT ON COLUMN chill_job.immersion.structureAccPhonenumber IS \'(DC2Type:phone_number)\''); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_job.immersion ALTER tuteurPhoneNumber TYPE TEXT'); + $this->addSql('COMMENT ON COLUMN chill_job.immersion.tuteurphonenumber IS NULL'); + + $this->addSql('ALTER TABLE chill_job.immersion ALTER structureAccPhonenumber TYPE TEXT'); + $this->addSql('COMMENT ON COLUMN chill_job.immersion.structureAccPhonenumber IS NULL'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20191119172511.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20191119172511.php new file mode 100644 index 000000000..6dccbec42 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20191119172511.php @@ -0,0 +1,114 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SCHEMA chill_csconnectes'); + $this->addSql('CREATE TABLE chill_csconnectes.cs_person ( + id INT NOT NULL, + person_id INT NOT NULL, + prescripteur_id INT DEFAULT NULL, + situationLogement VARCHAR(255) DEFAULT NULL, + enfantACharge INT DEFAULT NULL, + niveauMaitriseLangue JSONB DEFAULT NULL, + vehiculePersonnel BOOLEAN DEFAULT NULL, + permisConduire JSONB DEFAULT NULL, + situationProfessionnelle VARCHAR(255) DEFAULT NULL, + dateFinDernierEmploi DATE DEFAULT NULL, + typeContrat JSONB DEFAULT NULL, + ressources JSONB DEFAULT NULL, + ressourcesComment TEXT DEFAULT NULL, + ressourceDate1Versement DATE DEFAULT NULL, + CPFNombreHeures INT DEFAULT NULL, + accompagnement JSONB DEFAULT NULL, + accompagnementRQTHDate DATE DEFAULT NULL, + accompagnementComment VARCHAR(255) DEFAULT NULL, + poleEmploiId VARCHAR(255) DEFAULT NULL, + poleEmploiInscriptionDate DATE DEFAULT NULL, + cafId VARCHAR(255) DEFAULT NULL, + cafInscriptionDate DATE DEFAULT NULL, + CERInscriptionDate DATE DEFAULT NULL, + PPAEInscriptionDate DATE DEFAULT NULL, + NEETEligibilite BOOLEAN DEFAULT NULL, + NEETCommissionDate DATE DEFAULT NULL, + FSEMaDemarcheCode TEXT DEFAULT NULL, + documentCV_id INT DEFAULT NULL, + documentAgrementIAE_id INT DEFAULT NULL, + documentRQTH_id INT DEFAULT NULL, + documentAttestationNEET_id INT DEFAULT NULL, + documentCI_id INT DEFAULT NULL, + documentTitreSejour_id INT DEFAULT NULL, + documentAttestationFiscale_id INT DEFAULT NULL, + documentPermis_id INT DEFAULT NULL, + documentAttestationCAAF_id INT DEFAULT NULL, + documentContraTravail_id INT DEFAULT NULL, + documentAttestationFormation_id INT DEFAULT NULL, + documentQuittanceLoyer_id INT DEFAULT NULL, + documentFactureElectricite_id INT DEFAULT NULL, + PRIMARY KEY(id, person_id))'); + $this->addSql('CREATE INDEX IDX_10864F31217BBB47 ON chill_csconnectes.cs_person (person_id)'); + $this->addSql('CREATE INDEX IDX_10864F3154866550 ON chill_csconnectes.cs_person (documentCV_id)'); + $this->addSql('CREATE INDEX IDX_10864F318825E118 ON chill_csconnectes.cs_person (documentAgrementIAE_id)'); + $this->addSql('CREATE INDEX IDX_10864F31A396AFAC ON chill_csconnectes.cs_person (documentRQTH_id)'); + $this->addSql('CREATE INDEX IDX_10864F3187541764 ON chill_csconnectes.cs_person (documentAttestationNEET_id)'); + $this->addSql('CREATE INDEX IDX_10864F315CFC2299 ON chill_csconnectes.cs_person (documentCI_id)'); + $this->addSql('CREATE INDEX IDX_10864F3134FDF11D ON chill_csconnectes.cs_person (documentTitreSejour_id)'); + $this->addSql('CREATE INDEX IDX_10864F315742C99D ON chill_csconnectes.cs_person (documentAttestationFiscale_id)'); + $this->addSql('CREATE INDEX IDX_10864F31166494D4 ON chill_csconnectes.cs_person (documentPermis_id)'); + $this->addSql('CREATE INDEX IDX_10864F3172820D66 ON chill_csconnectes.cs_person (documentAttestationCAAF_id)'); + $this->addSql('CREATE INDEX IDX_10864F31AFA5E636 ON chill_csconnectes.cs_person (documentContraTravail_id)'); + $this->addSql('CREATE INDEX IDX_10864F3161E05C22 ON chill_csconnectes.cs_person (documentAttestationFormation_id)'); + $this->addSql('CREATE INDEX IDX_10864F316F744BB0 ON chill_csconnectes.cs_person (documentQuittanceLoyer_id)'); + $this->addSql('CREATE INDEX IDX_10864F31AC39B1B ON chill_csconnectes.cs_person (documentFactureElectricite_id)'); + $this->addSql('CREATE INDEX IDX_10864F31D486E642 ON chill_csconnectes.cs_person (prescripteur_id)'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F3154866550 FOREIGN KEY (documentCV_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F318825E118 FOREIGN KEY (documentAgrementIAE_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31A396AFAC FOREIGN KEY (documentRQTH_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F3187541764 FOREIGN KEY (documentAttestationNEET_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F315CFC2299 FOREIGN KEY (documentCI_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F3134FDF11D FOREIGN KEY (documentTitreSejour_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F315742C99D FOREIGN KEY (documentAttestationFiscale_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31166494D4 FOREIGN KEY (documentPermis_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F3172820D66 FOREIGN KEY (documentAttestationCAAF_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31AFA5E636 FOREIGN KEY (documentContraTravail_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F3161E05C22 FOREIGN KEY (documentAttestationFormation_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F316F744BB0 FOREIGN KEY (documentQuittanceLoyer_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31AC39B1B FOREIGN KEY (documentFactureElectricite_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CONSTRAINT FK_10864F31D486E642 FOREIGN KEY (prescripteur_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.niveauMaitriseLangue IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.permisConduire IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.typeContrat IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.ressources IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.accompagnement IS NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP TABLE chill_csconnectes.cs_person'); + $this->addSql('DROP SCHEMA chill_csconnectes CASCADE'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20191129112321.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20191129112321.php new file mode 100644 index 000000000..85ca4e137 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20191129112321.php @@ -0,0 +1,60 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX chill_csconnectes.IDX_10864f31217bbb47'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD CERSignataire TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD PPAESignataire TEXT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.niveauMaitriseLangue IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.permisConduire IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.typeContrat IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.ressources IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.accompagnement IS NULL'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_10864F31217BBB47 ON chill_csconnectes.cs_person (person_id)'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP CONSTRAINT cs_person_pkey'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD PRIMARY KEY (id)'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ALTER person_id DROP NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->throwIrreversibleMigrationException('this migration is not reversible (' + .'actions on primary keys)'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX UNIQ_10864F31217BBB47'); + $this->addSql('DROP INDEX cs_person_pkey'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP CERSignataire'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP PPAESignataire'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ALTER person_id SET NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.niveaumaitriselangue IS \'(DC2Type:json_array)\''); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.permisconduire IS \'(DC2Type:json_array)\''); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.typecontrat IS \'(DC2Type:json_array)\''); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.ressources IS \'(DC2Type:json_array)\''); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.cs_person.accompagnement IS \'(DC2Type:json_array)\''); + $this->addSql('CREATE INDEX idx_10864f31217bbb47 ON chill_csconnectes.cs_person (person_id)'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD PRIMARY KEY (id, person_id)'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113104411.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113104411.php new file mode 100644 index 000000000..1fb74f5f0 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113104411.php @@ -0,0 +1,53 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SEQUENCE chill_csconnectes.immersion_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_csconnectes.immersion (id INT NOT NULL, person_id INT DEFAULT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSONB DEFAULT NULL, savoirEtre JSONB DEFAULT NULL, noteimmersion TEXT NOT NULL, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4217BBB47 ON chill_csconnectes.immersion (person_id)'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4A4AEAFEA ON chill_csconnectes.immersion (entreprise_id)'); + $this->addSql('CREATE INDEX IDX_FBB3CBB435E47E35 ON chill_csconnectes.immersion (referent_id)'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.duration IS \'(DC2Type:dateinterval)\''); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB4217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB4A4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB435E47E35 FOREIGN KEY (referent_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('CREATE TABLE chill_csconnectes.cv_formation (id INT NOT NULL, title TEXT NOT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, diplomaObtained VARCHAR(255) DEFAULT NULL, diplomaReconnue VARCHAR(50) DEFAULT NULL, organisme TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_20BE09E2AE1799D8 ON chill_csconnectes.cv_formation (CV_id)'); + $this->addSql('ALTER TABLE chill_csconnectes.cv_formation ADD CONSTRAINT FK_20BE09E2AE1799D8 FOREIGN KEY (CV_id) REFERENCES chill_csconnectes.cv (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP SEQUENCE chill_csconnectes.immersion_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_csconnectes.immersion'); + + $this->addSql('DROP SEQUENCE chill_csconnectes.cv_formation_id_seq CASCADE'); + $this->addSql('ALTER TABLE chill_csconnectes.cv_formation DROP CONSTRAINT FK_20BE09E2AE1799D8'); + $this->addSql('DROP TABLE chill_csconnectes.cv_formation'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113142525.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113142525.php new file mode 100644 index 000000000..cabc97d59 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200113142525.php @@ -0,0 +1,43 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD structureAccEmail TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD structureAccAddress_id INT DEFAULT NULL'); + $this->addSql('CREATE INDEX IDX_FBB3CBB4B5E04267 ON chill_csconnectes.immersion (structureAccAddress_id)'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP structureAccEmail'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP structureAccAddress_id'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200114081435.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200114081435.php new file mode 100644 index 000000000..a03263bf3 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200114081435.php @@ -0,0 +1,44 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD is_bilan_fullfilled BOOLEAN DEFAULT \'false\' NOT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD savoirEtreNote TEXT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.savoirEtre IS NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD CONSTRAINT FK_FBB3CBB4B5E04267 FOREIGN KEY (structureAccAddress_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP CONSTRAINT FK_FBB3CBB4B5E04267'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP is_bilan_fullfilled'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP savoirEtreNote'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124130244.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124130244.php new file mode 100644 index 000000000..dd1e669ae --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124130244.php @@ -0,0 +1,36 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD datecontratIEJ DATE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP datecontratIEJ'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124132321.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124132321.php new file mode 100644 index 000000000..3cf1b3019 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200124132321.php @@ -0,0 +1,36 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD typeContratAide TEXT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP typeContratAide'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200127132932.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200127132932.php new file mode 100644 index 000000000..2907c2155 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200127132932.php @@ -0,0 +1,36 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD objectifsAutre TEXT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP objectifsAutre'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200205132532.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200205132532.php new file mode 100644 index 000000000..1372aa308 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200205132532.php @@ -0,0 +1,83 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + // $this->addSql('DROP SEQUENCE report_id_seq CASCADE'); + $this->addSql('CREATE SEQUENCE chill_csconnectes.rome_appellation_id_seq ' + .'INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_csconnectes.rome_metier_id_seq ' + .'INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_csconnectes.projet_professionnel_id_seq ' + .'INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_csconnectes.cv_formation_id_seq ' + .'INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_csconnectes.rome_appellation (' + .'id INT NOT NULL, metier_id INT DEFAULT NULL, code VARCHAR(40) NOT NULL, ' + .'libelle TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_D9E9CABCED16FA20 ON chill_csconnectes.rome_appellation (metier_id)'); + $this->addSql('CREATE TABLE chill_csconnectes.rome_metier (id INT NOT NULL, ' + .'libelle TEXT NOT NULL, code VARCHAR(20) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_csconnectes.projet_professionnel (id INT NOT NULL, ' + .'person_id INT DEFAULT NULL, reportDate DATE NOT NULL, ' + .'typeContrat JSONB DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, ' + .'volumeHoraire JSONB DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, ' + .'idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, ' + .'valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, ' + .'PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_12E4FFBF217BBB47 ON chill_csconnectes.projet_professionnel (person_id)'); + $this->addSql('CREATE TABLE chill_csconnectes.projetprofessionnel_souhait (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); + $this->addSql('CREATE INDEX IDX_3280B96DB87BF7B5 ON chill_csconnectes.projetprofessionnel_souhait (projetprofessionnel_id)'); + $this->addSql('CREATE INDEX IDX_3280B96D7CDE30DD ON chill_csconnectes.projetprofessionnel_souhait (appellation_id)'); + $this->addSql('CREATE TABLE chill_csconnectes.projetprofessionnel_valide (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); + $this->addSql('CREATE INDEX IDX_E0501BE0B87BF7B5 ON chill_csconnectes.projetprofessionnel_valide (projetprofessionnel_id)'); + $this->addSql('CREATE INDEX IDX_E0501BE07CDE30DD ON chill_csconnectes.projetprofessionnel_valide (appellation_id)'); + $this->addSql('ALTER TABLE chill_csconnectes.rome_appellation ADD CONSTRAINT FK_D9E9CABCED16FA20 FOREIGN KEY (metier_id) REFERENCES chill_csconnectes.rome_metier (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel ADD CONSTRAINT FK_12E4FFBF217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait ADD CONSTRAINT FK_3280B96DB87BF7B5 FOREIGN KEY (projetprofessionnel_id) REFERENCES chill_csconnectes.projet_professionnel (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait ADD CONSTRAINT FK_3280B96D7CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_csconnectes.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE0B87BF7B5 FOREIGN KEY (projetprofessionnel_id) REFERENCES chill_csconnectes.projet_professionnel (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide ADD CONSTRAINT FK_E0501BE07CDE30DD FOREIGN KEY (appellation_id) REFERENCES chill_csconnectes.rome_appellation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait DROP CONSTRAINT FK_3280B96D7CDE30DD'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide DROP CONSTRAINT FK_E0501BE07CDE30DD'); + $this->addSql('ALTER TABLE chill_csconnectes.rome_appellation DROP CONSTRAINT FK_D9E9CABCED16FA20'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_souhait DROP CONSTRAINT FK_3280B96DB87BF7B5'); + $this->addSql('ALTER TABLE chill_csconnectes.projetprofessionnel_valide DROP CONSTRAINT FK_E0501BE0B87BF7B5'); + $this->addSql('DROP SEQUENCE chill_csconnectes.rome_appellation_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_csconnectes.rome_metier_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_csconnectes.projet_professionnel_id_seq CASCADE'); + + $this->addSql('DROP TABLE chill_csconnectes.rome_appellation'); + $this->addSql('DROP TABLE chill_csconnectes.rome_metier'); + $this->addSql('DROP TABLE chill_csconnectes.projet_professionnel'); + $this->addSql('DROP TABLE chill_csconnectes.projetprofessionnel_souhait'); + $this->addSql('DROP TABLE chill_csconnectes.projetprofessionnel_valide'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200207224152.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200207224152.php new file mode 100644 index 000000000..6fecfda82 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200207224152.php @@ -0,0 +1,38 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE INDEX code_appellation_idx ON chill_csconnectes.rome_appellation (code)'); + $this->addSql('CREATE INDEX code_metier_idx ON chill_csconnectes.rome_metier (code)'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX code_appellation_idx ON chill_csconnectes.rome_appellation'); + $this->addSql('DROP INDEX code_metier_idx ON chill_csconnectes.rome_metier'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200210105342.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200210105342.php new file mode 100644 index 000000000..53d88ec2b --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200210105342.php @@ -0,0 +1,36 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_D9E9CABC77153098 ON chill_csconnectes.rome_appellation (code);'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_3274952577153098 ON chill_csconnectes.rome_metier (code);'); + $this->addSql('DROP INDEX IF EXISTS chill_csconnectes.code_metier_idx '); + $this->addSql('DROP INDEX IF EXISTS chill_csconnectes.code_appellation_idx '); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP INDEX chill_csconnectes.UNIQ_D9E9CABC77153098'); + $this->addSql('DROP INDEX chill_csconnectes.UNIQ_3274952577153098'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200313124323.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200313124323.php new file mode 100644 index 000000000..1c3ef3be4 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200313124323.php @@ -0,0 +1,87 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + $this->addSql('ALTER TABLE chill_csconnectes.cv_formation ALTER diplomaobtained TYPE VARCHAR(255)'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD ponctualite_salarie TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD ponctualite_salarie_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD assiduite TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD assiduite_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD interet_activite TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD interet_activite_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD integre_regle TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD integre_regle_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD esprit_initiative TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD esprit_initiative_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD organisation TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD organisation_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD capacite_travail_equipe TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD capacite_travail_equipe_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD style_vestimentaire TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD style_vestimentaire_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD langage_prof TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD langage_prof_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD applique_consigne TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD applique_consigne_note TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD respect_hierarchie TEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion ADD respect_hierarchie_note TEXT DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.objectifs IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.savoirEtre IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.frein.freinsPerso IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.frein.freinsEmploi IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.projet_professionnel.typeContrat IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.projet_professionnel.volumeHoraire IS NULL'); + $this->addSql('COMMENT ON COLUMN chill_3party.third_party.types IS NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP ponctualite_salarie'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP ponctualite_salarie_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP assiduite'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP assiduite_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP interet_activite'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP interet_activite_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP integre_regle'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP integre_regle_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP esprit_initiative'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP esprit_initiative_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP organisation'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP organisation_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP capacite_travail_equipe'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP capacite_travail_equipe_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP style_vestimentaire'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP style_vestimentaire_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP langage_prof'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP langage_prof_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP applique_consigne'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP applique_consigne_note'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP respect_hierarchie'); + $this->addSql('ALTER TABLE chill_csconnectes.immersion DROP respect_hierarchie_note'); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.objectifs IS \'(DC2Type:json_array)\''); + $this->addSql('COMMENT ON COLUMN chill_csconnectes.immersion.savoiretre IS \'(DC2Type:json_array)\''); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403114520.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403114520.php new file mode 100644 index 000000000..ab80c48d7 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403114520.php @@ -0,0 +1,35 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteSouhait TEXT DEFAULT NULL;'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel ADD domaineActiviteValide TEXT DEFAULT NULL;'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteSouhait'); + $this->addSql('ALTER TABLE chill_csconnectes.projet_professionnel DROP domaineActiviteValide'); + } +} diff --git a/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403123148.php b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403123148.php new file mode 100644 index 000000000..307cd14c7 --- /dev/null +++ b/src/Bundle/ChillJobBundle/src/migrations/old/Version20200403123148.php @@ -0,0 +1,32 @@ +skipIf(true, 'Skipping this old migration. Replaced by migration Version20240424095147'); + $this->addSql('ALTER TABLE chill_csconnectes.cs_person ADD dateavenantIEJ DATE DEFAULT NULL;'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_csconnectes.cs_person DROP dateavenantIEJ'); + } +} diff --git a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php index c3c7b9dc1..601dc9833 100644 --- a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php +++ b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php @@ -11,6 +11,9 @@ declare(strict_types=1); namespace Chill\MainBundle\CRUD\CompilerPass; +use Chill\MainBundle\CRUD\Controller\ApiController; +use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\CRUD\Exception\InvalidCrudConfiguration; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -38,6 +41,9 @@ class CRUDControllerCompilerPass implements CompilerPassInterface private function configureCrudController(ContainerBuilder $container, array $crudEntry, string $apiOrCrud): void { $controllerClass = $crudEntry['controller']; + if (ApiController::class === $controllerClass || CRUDController::class === $controllerClass) { + throw InvalidCrudConfiguration::configurationRequiresControllerDefinition($crudEntry['class'], $apiOrCrud); + } $controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller'; // create config parameter in container diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php index 9ee0d9e19..ea5e55a69 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php @@ -18,10 +18,13 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Doctrine\DBAL\LockMode; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\ConflictHttpException; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -60,7 +63,7 @@ abstract class AbstractCRUDController extends AbstractController parent::getSubscribedServices(), [ 'chill_main.paginator_factory' => PaginatorFactory::class, - + ManagerRegistry::class => ManagerRegistry::class, 'translator' => TranslatorInterface::class, AuthorizationHelper::class => AuthorizationHelper::class, EventDispatcherInterface::class => EventDispatcherInterface::class, @@ -95,7 +98,7 @@ abstract class AbstractCRUDController extends AbstractController */ protected function buildQueryEntities(string $action, Request $request) { - $qb = $this->getDoctrine()->getManager() + $qb = $this->getManagerRegistry()->getManager() ->createQueryBuilder() ->select('e') ->from($this->getEntityClass(), 'e'); @@ -116,7 +119,7 @@ abstract class AbstractCRUDController extends AbstractController * * @param mixed|null $entity * - * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException + * @throws AccessDeniedHttpException */ protected function checkACL(string $action, Request $request, string $_format, $entity = null) { @@ -145,9 +148,7 @@ abstract class AbstractCRUDController extends AbstractController return new $class(); } - protected function customizeQuery(string $action, Request $request, $query): void - { - } + protected function customizeQuery(string $action, Request $request, $query): void {} protected function getActionConfig(string $action) { @@ -169,8 +170,7 @@ abstract class AbstractCRUDController extends AbstractController */ protected function getEntity(mixed $action, string $id, Request $request): object { - $e = $this - ->getDoctrine() + $e = $this->getManagerRegistry() ->getRepository($this->getEntityClass()) ->find($id); @@ -181,7 +181,7 @@ abstract class AbstractCRUDController extends AbstractController $expectedVersion = $request->query->getInt('entity_version'); try { - $manager = $this->getDoctrine()->getManagerForClass($this->getEntityClass()); + $manager = $this->getManagerRegistry()->getManagerForClass($this->getEntityClass()); if ($manager instanceof EntityManagerInterface) { $manager->lock($e, LockMode::OPTIMISTIC, $expectedVersion); @@ -211,6 +211,11 @@ abstract class AbstractCRUDController extends AbstractController return $this->container->get('chill_main.paginator_factory'); } + protected function getManagerRegistry(): ManagerRegistry + { + return $this->container->get(ManagerRegistry::class); + } + /** * Get the result of the query. */ diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index a6675424e..6533da243 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -80,8 +80,8 @@ class ApiController extends AbstractCRUDController return $response; } - $this->getDoctrine()->getManager()->remove($entity); - $this->getDoctrine()->getManager()->flush(); + $this->getManagerRegistry()->getManager()->remove($entity); + $this->getManagerRegistry()->getManager()->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); @@ -153,7 +153,7 @@ class ApiController extends AbstractCRUDController return $response; } - $this->getDoctrine()->getManagerForClass($this->getEntityClass())->flush(); + $this->getManagerRegistry()->getManagerForClass($this->getEntityClass())->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); @@ -269,10 +269,10 @@ class ApiController extends AbstractCRUDController } if ($forcePersist && Request::METHOD_POST === $request->getMethod()) { - $this->getDoctrine()->getManager()->persist($postedData); + $this->getManagerRegistry()->getManager()->persist($postedData); } - $this->getDoctrine()->getManager()->flush(); + $this->getManagerRegistry()->getManager()->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors, [$postedData]); @@ -373,7 +373,7 @@ class ApiController extends AbstractCRUDController try { $entity = $this->deserialize($action, $request, $_format, $entity); } catch (NotEncodableValueException $e) { - throw new BadRequestHttpException('invalid json', 400, $e); + throw new BadRequestHttpException('invalid json', $e, 400); } $errors = $this->validate($action, $request, $_format, $entity); @@ -403,8 +403,8 @@ class ApiController extends AbstractCRUDController return $response; } - $this->getDoctrine()->getManager()->persist($entity); - $this->getDoctrine()->getManager()->flush(); + $this->getManagerRegistry()->getManager()->persist($entity); + $this->getManagerRegistry()->getManager()->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 213efba24..f4c9538c7 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -19,16 +19,40 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * The CRUDController class is an abstract class that provides basic CRUD (Create, Read, Update, Delete) functionality for entities in a Symfony application. It extends the Abstract + *Controller class. + * + * For the class \Chill\MainBundle\CRUD\Controller\CRUDController, the dependency injection system does not work as in + * the usual way, where dependencies are provided via the constructor method. Instead, it utilizes the capabilities + * provided by the \Symfony\Contracts\Service\ServiceSubscriberInterface. + * + * The \Symfony\Contracts\Service\ServiceSubscriberInterface is an interface that is used by objects needing explicit + * service references. It means this class has a direct dependency on the Symfony service container, allowing it to + * request specific services it needs for execution. + * + * By implementing the ServiceSubscriberInterface, this class effectively defines a method called getSubscribedServices, + * which returns an array mapping service IDs to their classes or interfaces. Symfony's service container uses this + * method to preconfigure the services required, optimizing the dependency injection process. + * + * This model can be used to keep the class itself concise by preventing the need to define a constructor and inject + * services through method calls. This approach also allows for more flexible service usage, as services can be fetched + * as and when required, rather than all services being loaded whether they are used or not. This makes for a more + * efficient and maintainable solution especially when dealing with larger services. + * + * For more details about how this works, you can refer to Symfony's Documentation + * on Service Subscribers & Service Locators: https://symfony.com/doc/current/service_container/service_subscribers_locators.html + */ class CRUDController extends AbstractController { /** @@ -78,6 +102,7 @@ class CRUDController extends AbstractController Resolver::class => Resolver::class, SerializerInterface::class => SerializerInterface::class, FilterOrderHelperFactoryInterface::class => FilterOrderHelperFactoryInterface::class, + ManagerRegistry::class => ManagerRegistry::class, ] ); } @@ -150,8 +175,7 @@ class CRUDController extends AbstractController */ protected function buildQueryEntities(string $action, Request $request) { - $query = $this - ->getDoctrine() + $query = $this->getManagerRegistry() ->getManager() ->createQueryBuilder() ->select('e') @@ -224,13 +248,9 @@ class CRUDController extends AbstractController /** * Customize the form created by createFormFor. */ - protected function customizeForm(string $action, FormInterface $form) - { - } + protected function customizeForm(string $action, FormInterface $form) {} - protected function customizeQuery(string $action, Request $request, $query): void - { - } + protected function customizeQuery(string $action, Request $request, $query): void {} /** * @param null $formClass @@ -269,7 +289,7 @@ class CRUDController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($action, $entity, $form, $request); - $em = $this->getDoctrine()->getManager(); + $em = $this->getManagerRegistry()->getManager(); $this->onPreRemove($action, $entity, $form, $request); $this->removeEntity($action, $entity, $form, $request); @@ -314,7 +334,7 @@ class CRUDController extends AbstractController $id = $request->query->get('duplicate_id', 0); $originalEntity = $this->getEntity($action, $id, $request); - $this->getDoctrine()->getManager() + $this->getManagerRegistry()->getManager() ->detach($originalEntity); return $originalEntity; @@ -386,7 +406,7 @@ class CRUDController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($action, $entity, $form, $request); - $em = $this->getDoctrine()->getManager(); + $em = $this->getManagerRegistry()->getManager(); $this->onPrePersist($action, $entity, $form, $request); $em->persist($entity); @@ -489,7 +509,7 @@ class CRUDController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($action, $entity, $form, $request); - $em = $this->getDoctrine()->getManager(); + $em = $this->getManagerRegistry()->getManager(); $this->onPreFlush($action, $entity, $form, $request); $em->flush(); @@ -603,7 +623,7 @@ class CRUDController extends AbstractController */ protected function getEntity(mixed $action, $id, Request $request): ?object { - return $this->getDoctrine() + return $this->getManagerRegistry() ->getRepository($this->getEntityClass()) ->find($id); } @@ -652,6 +672,11 @@ class CRUDController extends AbstractController return $this->container->get('chill_main.paginator_factory'); } + protected function getManagerRegistry(): ManagerRegistry + { + return $this->container->get(ManagerRegistry::class); + } + /** * Get the result of the query. */ @@ -844,9 +869,7 @@ class CRUDController extends AbstractController }; } - protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) - { - } + protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) {} protected function onPostCheckACL($action, Request $request, $entity): ?Response { @@ -858,58 +881,36 @@ class CRUDController extends AbstractController return null; } - protected function onPostFlush(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPostFlush(string $action, $entity, FormInterface $form, Request $request) {} /** * method used by indexAction. */ - protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query) - { - } + protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query) {} /** * method used by indexAction. */ - protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities) - { - } + protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities) {} - protected function onPostPersist(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPostPersist(string $action, $entity, FormInterface $form, Request $request) {} - protected function onPostRemove(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPostRemove(string $action, $entity, FormInterface $form, Request $request) {} - protected function onPreDelete(string $action, Request $request) - { - } + protected function onPreDelete(string $action, Request $request) {} - protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request) {} - protected function onPreIndex(string $action, Request $request) - { - } + protected function onPreIndex(string $action, Request $request) {} /** * method used by indexAction. */ - protected function onPreIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator) - { - } + protected function onPreIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator) {} - protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) {} - protected function onPreRemove(string $action, $entity, FormInterface $form, Request $request) - { - } + protected function onPreRemove(string $action, $entity, FormInterface $form, Request $request) {} /** * Add ordering fields in the query build by self::queryEntities. @@ -946,7 +947,7 @@ class CRUDController extends AbstractController protected function removeEntity(string $action, $entity, FormInterface $form, Request $request) { - $this->getDoctrine() + $this->getManagerRegistry() ->getManager() ->remove($entity); } diff --git a/src/Bundle/ChillMainBundle/CRUD/Exception/InvalidCrudConfiguration.php b/src/Bundle/ChillMainBundle/CRUD/Exception/InvalidCrudConfiguration.php new file mode 100644 index 000000000..350eced43 --- /dev/null +++ b/src/Bundle/ChillMainBundle/CRUD/Exception/InvalidCrudConfiguration.php @@ -0,0 +1,25 @@ + $controller.':'.($action['controller_action'] ?? $controllerAction), + '_controller' => $controller.'::'.($action['controller_action'] ?? $controllerAction), ]; // path are rewritten diff --git a/src/Bundle/ChillMainBundle/ChillMainBundle.php b/src/Bundle/ChillMainBundle/ChillMainBundle.php index b7cf4e289..ff721784a 100644 --- a/src/Bundle/ChillMainBundle/ChillMainBundle.php +++ b/src/Bundle/ChillMainBundle/ChillMainBundle.php @@ -22,7 +22,6 @@ use Chill\MainBundle\DependencyInjection\CompilerPass\ShortMessageCompilerPass; use Chill\MainBundle\DependencyInjection\CompilerPass\TimelineCompilerClass; use Chill\MainBundle\DependencyInjection\CompilerPass\WidgetsCompilerPass; use Chill\MainBundle\DependencyInjection\ConfigConsistencyCompilerPass; -use Chill\MainBundle\DependencyInjection\RoleProvidersCompilerPass; use Chill\MainBundle\Notification\NotificationHandlerInterface; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Search\SearchApiInterface; @@ -44,8 +43,6 @@ class ChillMainBundle extends Bundle $container->registerForAutoconfiguration(LocalMenuBuilderInterface::class) ->addTag('chill.menu_builder'); - $container->registerForAutoconfiguration(ProvideRoleInterface::class) - ->addTag('chill.role'); $container->registerForAutoconfiguration(CenterResolverInterface::class) ->addTag('chill_main.center_resolver'); $container->registerForAutoconfiguration(ScopeResolverInterface::class) @@ -64,11 +61,12 @@ class ChillMainBundle extends Bundle ->addTag('chill_main.cron_job'); $container->registerForAutoconfiguration(ViewEntityInfoProviderInterface::class) ->addTag('chill_main.entity_info_provider'); + $container->registerForAutoconfiguration(ProvideRoleInterface::class) + ->addTag('chill_main.provide_role'); $container->addCompilerPass(new SearchableServicesCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->addCompilerPass(new ConfigConsistencyCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->addCompilerPass(new TimelineCompilerClass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); - $container->addCompilerPass(new RoleProvidersCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->addCompilerPass(new ExportsCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->addCompilerPass(new WidgetsCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->addCompilerPass(new NotificationCounterCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); 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 fe11f8b9f..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) @@ -194,14 +195,8 @@ class LoadPostalCodesCommand extends Command } } -class ExistingPostalCodeException extends \Exception -{ -} +class ExistingPostalCodeException extends \Exception {} -class CountryCodeNotFoundException extends \Exception -{ -} +class CountryCodeNotFoundException extends \Exception {} -class PostalCodeNotValidException extends \Exception -{ -} +class PostalCodeNotValidException extends \Exception {} 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 809b7b901..3961c9f3a 100644 --- a/src/Bundle/ChillMainBundle/Controller/AbsenceController.php +++ b/src/Bundle/ChillMainBundle/Controller/AbsenceController.php @@ -12,28 +12,25 @@ 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 { - /** - * @Route( - * "/{_locale}/absence", - * name="chill_main_user_absence_index", - * methods={"GET", "POST"} - * ) - */ + public function __construct(private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} + + #[Route(path: '/{_locale}/absence', name: 'chill_main_user_absence_index', methods: ['GET', 'POST'])] public function setAbsence(Request $request) { - $user = $this->getUser(); + $user = $this->security->getUser(); $form = $this->createForm(AbsenceType::class, $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->flush(); return $this->redirectToRoute('chill_main_user_absence_index'); @@ -45,19 +42,13 @@ 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->getUser(); + $user = $this->security->getUser(); $user->setAbsenceStart(null); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->flush(); return $this->redirectToRoute('chill_main_user_absence_index'); diff --git a/src/Bundle/ChillMainBundle/Controller/AddressApiController.php b/src/Bundle/ChillMainBundle/Controller/AddressApiController.php index 6bc952923..5ea68cdbc 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressApiController.php @@ -20,18 +20,18 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; class AddressApiController extends ApiController { + public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {} + /** * 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'); $new = Address::createFromAddress($address); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->persist($new); $em->flush(); diff --git a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php index edc58bed5..e50cea6bb 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php @@ -26,13 +26,9 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; final class AddressReferenceAPIController extends ApiController { - public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory) - { - } + 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 079f4783b..680a63859 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php @@ -23,13 +23,9 @@ use Symfony\Component\Serializer\SerializerInterface; class AddressToReferenceMatcherController { - public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer) - { - } + 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')) { @@ -50,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')) { @@ -75,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/CountryApiController.php b/src/Bundle/ChillMainBundle/Controller/CountryApiController.php new file mode 100644 index 000000000..12e5258fd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/CountryApiController.php @@ -0,0 +1,16 @@ +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..c23ebfda2 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 */ @@ -107,12 +105,9 @@ class ExportController extends AbstractController * This action must work with GET queries. * * @param string $alias - * - * @return Response - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/generate/{alias}", name="chill_main_export_generate", methods={"GET"}) */ - public function generateAction(Request $request, $alias) + #[Route(path: '/{_locale}/exports/generate/{alias}', name: 'chill_main_export_generate', methods: ['GET'])] + public function generateAction(Request $request, $alias): Response { /** @var ExportManager $exportManager */ $exportManager = $this->exportManager; @@ -130,10 +125,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 +148,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 +172,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 +197,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 +217,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'); @@ -300,7 +288,7 @@ class ExportController extends AbstractController $builder = $this->formFactory ->createNamedBuilder( - null, + '', FormType::class, $defaultFormData, [ diff --git a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitApiController.php b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitApiController.php new file mode 100644 index 000000000..19a1da160 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitApiController.php @@ -0,0 +1,16 @@ + 'json'])] public function getGeographicalUnitCoveringAddress(Address $address): JsonResponse { if (!$this->security->isGranted('ROLE_USER')) { diff --git a/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php b/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php index bc28f9d12..418f49578 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php @@ -13,6 +13,4 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\CRUDController; -class LocationTypeController extends CRUDController -{ -} +class LocationTypeController extends CRUDController {} diff --git a/src/Bundle/ChillMainBundle/Controller/LoginController.php b/src/Bundle/ChillMainBundle/Controller/LoginController.php index e04f478a8..ca4717728 100644 --- a/src/Bundle/ChillMainBundle/Controller/LoginController.php +++ b/src/Bundle/ChillMainBundle/Controller/LoginController.php @@ -33,12 +33,9 @@ class LoginController extends AbstractController /** * Show a login form. - * - * @return Response - * - * @\Symfony\Component\Routing\Annotation\Route(path="/login", name="login") */ - public function loginAction(Request $request) + #[\Symfony\Component\Routing\Annotation\Route(path: '/login', name: 'login')] + public function loginAction(Request $request): Response { return $this->render('@ChillMain/Login/login.html.twig', [ 'last_username' => $this->helper->getLastUsername(), @@ -46,7 +43,5 @@ class LoginController extends AbstractController ]); } - public function LoginCheckAction(Request $request) - { - } + public function LoginCheckAction(Request $request) {} } diff --git a/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php b/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php index 786a7e0f1..c687acc2f 100644 --- a/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NewsItemApiController.php @@ -25,14 +25,12 @@ class NewsItemApiController private readonly NewsItemRepository $newsItemRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory - ) { - } + ) {} /** * 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 cf1f4922b..78b7077ee 100644 --- a/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php +++ b/src/Bundle/ChillMainBundle/Controller/NewsItemHistoryController.php @@ -28,12 +28,9 @@ final readonly class NewsItemHistoryController private readonly PaginatorFactory $paginatorFactory, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, 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(); @@ -49,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 42f0e5469..2fb7969cf 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php @@ -26,34 +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) - { - } + 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 4d962248c..162c099ef 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,30 +32,19 @@ 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; -/** - * @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 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, 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'); - 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'); } @@ -70,13 +59,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 { @@ -109,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); @@ -139,17 +126,11 @@ 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'); - 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"); @@ -170,7 +151,7 @@ class NotificationController extends AbstractController $notification->addAddressee($this->security->getUser()); - $this->getDoctrine()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); $logMsg = '[Notification] a user is granted access to notification trough an access key'; $context = [ @@ -185,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'); @@ -211,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'); @@ -237,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); @@ -310,8 +285,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..7b9a89a76 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,8 +25,8 @@ 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; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -33,70 +34,23 @@ 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 \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)) { @@ -110,7 +64,7 @@ class PasswordController extends AbstractController $hash = $query->getAlnum(TokenManager::HASH); $token = $query->getAlnum(TokenManager::TOKEN); $timestamp = $query->getAlnum(TokenManager::TIMESTAMP); - $user = $this->getDoctrine()->getRepository(User::class) + $user = $this->managerRegistry->getRepository(User::class) ->findOneByUsernameCanonical($username); if (null === $user) { @@ -138,7 +92,7 @@ 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 @@ -149,7 +103,7 @@ class PasswordController extends AbstractController ] ); - $this->getDoctrine()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); return $this->redirectToRoute('password_request_recover_changed'); } @@ -162,9 +116,8 @@ class PasswordController extends AbstractController /** * @throws \Doctrine\ORM\NoResultException * @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)) { @@ -179,7 +132,7 @@ class PasswordController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { /** @var \Doctrine\ORM\QueryBuilder $qb */ - $qb = $this->getDoctrine()->getManager() + $qb = $this->managerRegistry->getManager() ->createQueryBuilder(); $qb->select('u') ->from(User::class, 'u') @@ -235,9 +188,8 @@ 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'); @@ -245,13 +197,15 @@ 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')) { + throw new AccessDeniedHttpException(); + } // get authentified user - $user = $this->getUser(); + $user = $this->security->getUser(); // create a form for password_encoder $form = $this->passwordForm($user); @@ -269,13 +223,13 @@ class PasswordController extends AbstractController 'update password for an user', [ 'method' => $request->getMethod(), - 'user' => $user->getUsername(), + 'user' => $user->getUserIdentifier(), ] ); - $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + $user->setPassword($this->passwordEncoder->hashPassword($user, $password)); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->flush(); $this->addFlash('success', $this->translator->trans('Password successfully updated!')); @@ -301,7 +255,7 @@ class PasswordController extends AbstractController 'constraints' => [ new Callback([ 'callback' => function ($pattern, ExecutionContextInterface $context, $payload) { - $qb = $this->getDoctrine()->getManager() + $qb = $this->managerRegistry->getManager() ->createQueryBuilder(); $qb->select('COUNT(u)') ->from(User::class, 'u') diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php index 97b255a85..2abb7333f 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php @@ -21,15 +21,12 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; class PermissionApiController extends AbstractController { - public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security) - { - } + 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 42d0d6a78..fc5d7d061 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -47,12 +47,9 @@ final class PermissionsGroupController extends AbstractController private readonly EntityManagerInterface $em, private readonly PermissionsGroupRepository $permissionsGroupRepository, 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: ['POST'])] public function addLinkRoleScopeAction(Request $request, int $id): Response { $permissionsGroup = $this->permissionsGroupRepository->find($id); @@ -64,7 +61,9 @@ final class PermissionsGroupController extends AbstractController $form = $this->createAddRoleScopeForm($permissionsGroup); $form->handleRequest($request); - if ($form->isValid()) { + dump($form->isSubmitted()); + + if ($form->isSubmitted() && $form->isValid()) { $roleScope = $this->getPersistentRoleScopeBy( $form['composed_role_scope']->getData()->getRole(), $form['composed_role_scope']->getData()->getScope() @@ -77,7 +76,7 @@ final class PermissionsGroupController extends AbstractController $this->em->flush(); $this->addFlash( - 'notice', + 'success', $this->translator->trans('The permissions have been added') ); @@ -130,9 +129,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(); @@ -154,9 +152,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); @@ -212,9 +209,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); @@ -260,9 +256,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(); @@ -274,9 +269,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(); @@ -290,9 +284,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); @@ -317,8 +310,8 @@ final class PermissionsGroupController extends AbstractController } return strcmp( - $translatableStringHelper->localize($a->getScope()->getName()), - $translatableStringHelper->localize($b->getScope()->getName()) + (string) $translatableStringHelper->localize($a->getScope()->getName()), + (string) $translatableStringHelper->localize($b->getScope()->getName()) ); } ); @@ -343,9 +336,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 @@ -426,7 +418,6 @@ final class PermissionsGroupController extends AbstractController 'admin_permissionsgroup_add_role_scope', ['id' => $permissionsGroup->getId()] )) - ->setMethod('PUT') ->add('composed_role_scope', ComposedRoleScopeType::class) ->add('submit', SubmitType::class, ['label' => 'Add permission']) ->getForm(); diff --git a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php index e51f74e40..cd13ad455 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php @@ -26,13 +26,9 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; final class PostalCodeAPIController extends ApiController { - public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory) - { - } + 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 f186561d5..edd8efda8 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeController.php @@ -29,18 +29,15 @@ class PostalCodeController extends AbstractController */ protected $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(TranslatableStringHelper $translatableStringHelper, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) { $this->translatableStringHelper = $translatableStringHelper; } /** - * @Route( - * "{_locale}/postalcode/search" - * ) - * * @return JsonResponse */ + #[Route(path: '{_locale}/postalcode/search')] public function searchAction(Request $request) { $pattern = $request->query->getAlnum('q', ''); @@ -49,7 +46,7 @@ class PostalCodeController extends AbstractController return new JsonResponse(['results' => [], 'pagination' => ['more' => false]]); } - $query = $this->getDoctrine()->getManager() + $query = $this->managerRegistry->getManager() ->createQuery( sprintf( 'SELECT p.id AS id, p.name AS name, p.code AS code, ' diff --git a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php index 0269ff0f5..82d41a9e1 100644 --- a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php @@ -34,13 +34,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; 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) - { - } + 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)) { @@ -73,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)) { @@ -106,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 3ccf13c07..5e932063a 100644 --- a/src/Bundle/ChillMainBundle/Controller/ScopeController.php +++ b/src/Bundle/ChillMainBundle/Controller/ScopeController.php @@ -13,20 +13,27 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Form\ScopeType; +use Doctrine\ORM\EntityManagerInterface; 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\HttpFoundation\Response; /** * Class ScopeController. */ class ScopeController extends AbstractController { + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry + ) {} + /** * 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(); @@ -34,7 +41,7 @@ class ScopeController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->persist($scope); $em->flush(); @@ -49,20 +56,18 @@ 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") */ - public function editAction(mixed $id) + #[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/{id}/edit', name: 'admin_scope_edit')] + public function editAction(Scope $scope, Request $request): Response { - $em = $this->getDoctrine()->getManager(); - - $scope = $em->getRepository(Scope::class)->find($id); - - if (!$scope) { - throw $this->createNotFoundException('Unable to find Scope entity.'); - } - $editForm = $this->createEditForm($scope); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $this->entityManager->flush(); + + return $this->redirectToRoute('admin_scope_edit', ['id' => $scope->getId()]); + } return $this->render('@ChillMain/Scope/edit.html.twig', [ 'entity' => $scope, @@ -72,12 +77,11 @@ 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->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $entities = $em->getRepository(Scope::class)->findAll(); @@ -88,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(); @@ -107,7 +110,7 @@ class ScopeController extends AbstractController */ public function showAction(mixed $id) { - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $scope = $em->getRepository(Scope::class)->find($id); @@ -120,44 +123,12 @@ class ScopeController extends AbstractController ]); } - /** - * Edits an existing Scope entity. - * - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/{id}/update", name="admin_scope_update", methods={"POST", "PUT"}) - */ - public function updateAction(Request $request, mixed $id) - { - $em = $this->getDoctrine()->getManager(); - - $scope = $em->getRepository(Scope::class)->find($id); - - if (!$scope) { - throw $this->createNotFoundException('Unable to find Scope entity.'); - } - - $editForm = $this->createEditForm($scope); - $editForm->handleRequest($request); - - if ($editForm->isSubmitted() && $editForm->isValid()) { - $em->flush(); - - return $this->redirectToRoute('admin_scope_edit', ['id' => $id]); - } - - return $this->render('@ChillMain/Scope/edit.html.twig', [ - 'entity' => $scope, - 'edit_form' => $editForm->createView(), - ]); - } - /** * Creates a form to create a Scope entity. * * @param Scope $scope The entity - * - * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Scope $scope) + private function createCreateForm(Scope $scope): FormInterface { $form = $this->createForm(ScopeType::class, $scope, [ 'action' => $this->generateUrl('admin_scope_create'), @@ -173,15 +144,10 @@ class ScopeController extends AbstractController * Creates a form to edit a Scope entity. * * @param Scope $scope The entity - * - * @return \Symfony\Component\Form\Form The form */ - private function createEditForm(Scope $scope) + private function createEditForm(Scope $scope): FormInterface { - $form = $this->createForm(ScopeType::class, $scope, [ - 'action' => $this->generateUrl('admin_scope_update', ['id' => $scope->getId()]), - 'method' => 'PUT', - ]); + $form = $this->createForm(ScopeType::class, $scope); $form->add('submit', SubmitType::class, ['label' => 'Update']); diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index b5d359a53..90fa6e1b5 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -32,13 +32,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SearchController extends AbstractController { - public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi) - { - } + 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 { @@ -83,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 */ @@ -102,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', '')); @@ -194,14 +186,12 @@ 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 $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/TimelineCenterController.php b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php index 7999cb697..97507739e 100644 --- a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php @@ -20,16 +20,9 @@ use Symfony\Component\Security\Core\Security; class TimelineCenterController extends AbstractController { - public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security) - { - } + 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 6809d3289..262bfdfde 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -13,41 +13,33 @@ 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 { - /** - * @Route( - * "/api/1.0/main/user-current-location.{_format}", - * name="chill_main_user_current_location", - * requirements={ - * "_format": "json" - * } - * ) - */ + public function __construct(private readonly ChillSecurity $security) {} + + #[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')) { + throw new AccessDeniedHttpException(); + } + return $this->json( - $this->getUser()->getCurrentLocation(), + $this->security->getUser()->getCurrentLocation(), JsonResponse::HTTP_OK, [], ['groups' => ['read']] ); } - /** - * @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 b335b356a..cc1666494 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; @@ -30,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; @@ -38,17 +38,21 @@ 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 \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, + private readonly UserRepository $userRepository, + protected ParameterBagInterface $parameterBag, + private readonly TranslatorInterface $translator, + private readonly ChillSecurity $security, + 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->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $user = $em->getRepository(User::class)->find($uid); @@ -94,13 +98,10 @@ 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->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $user = $em->getRepository(User::class)->find($uid); @@ -158,7 +159,7 @@ class UserController extends CRUDController if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($action, $entity, $form, $request); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $this->onPreFlush($action, $entity, $form, $request); $em->flush(); @@ -194,12 +195,11 @@ 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->getUser(); + $user = $this->security->getUser(); $form = $this->createForm(UserCurrentLocationType::class, $user) ->add('submit', SubmitType::class, ['label' => 'Save']) ->handleRequest($request); @@ -209,7 +209,7 @@ class UserController extends CRUDController $user->setCurrentLocation($currentLocation); - $this->getDoctrine()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); $this->addFlash('success', $this->translator->trans('Current location successfully updated')); return $this->redirect( @@ -226,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); @@ -243,9 +242,9 @@ class UserController extends CRUDController 'user' => $user->getUsername(), ]); - $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + $user->setPassword($this->passwordEncoder->hashPassword($user, $password)); - $this->getDoctrine()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); $this->addFlash('success', $this->translator->trans('Password successfully updated!')); return $this->redirect( @@ -352,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 @@ -424,7 +423,7 @@ class UserController extends CRUDController private function getPersistedGroupCenter(GroupCenter $groupCenter) { - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $groupCenterManaged = $em->getRepository(GroupCenter::class) ->findOneBy([ diff --git a/src/Bundle/ChillMainBundle/Controller/UserExportController.php b/src/Bundle/ChillMainBundle/Controller/UserExportController.php index 41c2d1a85..64b89a6f5 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserExportController.php @@ -27,16 +27,14 @@ final readonly class UserExportController private UserRepositoryInterface $userRepository, private Security $security, private TranslatorInterface $translator, - ) { - } + ) {} /** * @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')) { @@ -95,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 144c27688..1bbf5c0c1 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserJobScopeHistoriesController.php @@ -21,12 +21,9 @@ class UserJobScopeHistoriesController extends AbstractController { public function __construct( 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 3b83069bb..a48d1a1e2 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserProfileController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserProfileController.php @@ -12,29 +12,35 @@ 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, + private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, + ) {} /** * 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) { - $user = $this->getUser(); + if (!$this->security->isGranted('ROLE_USER')) { + throw new AccessDeniedHttpException(); + } + + $user = $this->security->getUser(); $editForm = $this->createPhonenumberEditForm($user); $editForm->handleRequest($request); @@ -43,7 +49,7 @@ class UserProfileController extends AbstractController $user->setPhonenumber($phonenumber); - $this->getDoctrine()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); $this->addFlash('success', $this->translator->trans('user.profile.Phonenumber successfully updated!')); return $this->redirectToRoute('chill_main_user_profile'); diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php index dd7d642c9..28dca8016 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php @@ -29,15 +29,12 @@ use Symfony\Component\Serializer\SerializerInterface; class WorkflowApiController { - public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) - { - } + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {} /** * 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) { @@ -74,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) { @@ -111,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 a88248c1a..d75e42012 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,13 +38,9 @@ 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, 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')) { @@ -64,7 +60,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']); @@ -81,16 +77,14 @@ class WorkflowController extends AbstractController $this->denyAccessUnlessGranted(EntityWorkflowVoter::CREATE, $entityWorkflow); - $em = $this->getDoctrine()->getManager(); + $em = $this->managerRegistry->getManager(); $em->persist($entityWorkflow); $em->flush(); 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); @@ -115,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)) { @@ -125,17 +117,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')); } @@ -145,18 +137,17 @@ 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'); - $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() @@ -175,18 +166,17 @@ 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'); - $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() @@ -203,18 +193,16 @@ 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'); - $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() @@ -230,18 +218,16 @@ 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'); - $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() @@ -257,18 +243,16 @@ 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'); - $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() @@ -284,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/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index 14878235d..ded78903d 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -55,8 +55,7 @@ final readonly class CronManager implements CronManagerInterface private EntityManagerInterface $entityManager, private iterable $jobs, private LoggerInterface $logger - ) { - } + ) {} public function run(?string $forceJob = null): void { diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php index c8010f604..29ee21ca6 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php @@ -344,11 +344,11 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface ->findOneBy(['countryCode' => $countryCode]); foreach ($lines as $line) { - $code = str_getcsv($line); + $code = str_getcsv((string) $line); $c = new PostalCode(); $c->setCountry($country) ->setCode($code[0]) - ->setName(\ucwords(\strtolower($code[1]))); + ->setName(\ucwords(\strtolower((string) $code[1]))); if (null !== ($code[3] ?? null)) { $c->setRefPostalCodeId($code[3]); 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/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 6dfae2fbd..4dde2076c 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -15,7 +15,9 @@ use Chill\MainBundle\Controller\AddressApiController; use Chill\MainBundle\Controller\CenterController; use Chill\MainBundle\Controller\CivilityApiController; use Chill\MainBundle\Controller\CivilityController; +use Chill\MainBundle\Controller\CountryApiController; use Chill\MainBundle\Controller\CountryController; +use Chill\MainBundle\Controller\GeographicalUnitApiController; use Chill\MainBundle\Controller\LanguageController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; @@ -667,6 +669,7 @@ class ChillMainExtension extends Extension implements ], [ 'class' => Country::class, + 'controller' => CountryApiController::class, 'name' => 'country', 'base_path' => '/api/1.0/main/country', 'base_role' => 'ROLE_USER', @@ -787,6 +790,7 @@ class ChillMainExtension extends Extension implements ], [ 'class' => GeographicalUnitLayer::class, + 'controller' => GeographicalUnitApiController::class, 'name' => 'geographical-unit-layer', 'base_path' => '/api/1.0/main/geographical-unit-layer', 'base_role' => 'ROLE_USER', diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/RoleProvidersCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/RoleProvidersCompilerPass.php deleted file mode 100644 index c4bbc846d..000000000 --- a/src/Bundle/ChillMainBundle/DependencyInjection/RoleProvidersCompilerPass.php +++ /dev/null @@ -1,41 +0,0 @@ -hasDefinition('chill.main.role_provider')) { - throw new \LogicException('service chill.main.role_provider is not defined. It is required by RoleProviderCompilerPass'); - } - - $definition = $container->getDefinition( - 'chill.main.role_provider' - ); - - $taggedServices = $container->findTaggedServiceIds( - 'chill.role' - ); - - foreach ($taggedServices as $id => $tagAttributes) { - $definition->addMethodCall( - 'addProvider', - [new Reference($id)] - ); - } - } -} diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index 907997258..e6ac2308a 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -21,9 +21,7 @@ use Symfony\Component\Security\Core\Security; class TrackCreateUpdateSubscriber implements EventSubscriber { - public function __construct(private readonly Security $security) - { - } + public function __construct(private readonly Security $security) {} public function getSubscribedEvents() { diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index beed15f31..de6af9625 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -15,9 +15,7 @@ class Point implements \JsonSerializable { public static string $SRID = '4326'; - private function __construct(private readonly ?float $lon, private readonly ?float $lat) - { - } + private function __construct(private readonly ?float $lon, private readonly ?float $lat) {} public static function fromArrayGeoJson(array $array): self { diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php index 29f1c2f43..3286390f7 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php @@ -12,26 +12,18 @@ declare(strict_types=1); namespace Chill\MainBundle\Doctrine\Model; use Chill\MainBundle\Entity\User; -use DateTime; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; trait TrackCreationTrait { - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])] private ?\DateTimeImmutable $createdAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] 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..551b5a50f 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php @@ -12,26 +12,18 @@ declare(strict_types=1); namespace Chill\MainBundle\Doctrine\Model; use Chill\MainBundle\Entity\User; -use DateTime; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; trait TrackUpdateTrait { - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])] private ?\DateTimeImmutable $updatedAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] 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..f04783506 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -26,13 +25,10 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Address. - * - * @ORM\Entity - * - * @ORM\Table(name="chill_main_address") - * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'chill_main_address')] class Address implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -55,62 +51,39 @@ class Address implements TrackCreationInterface, TrackUpdateInterface */ final public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed'; - /** - * @ORM\ManyToOne(targetEntity=AddressReference::class) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\ManyToOne(targetEntity: AddressReference::class)] private ?AddressReference $addressReference = null; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $buildingName = ''; - /** - * @ORM\Column(type="boolean", options={"default": false}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] private bool $confidential = false; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $corridor = ''; /** * used for the CEDEX information. - * - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $distribution = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $extra = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $flat = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $floor = ''; /** @@ -122,119 +95,82 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * @var Collection * * @readonly - * - * @ORM\ManyToMany(targetEntity=GeographicalUnit::class) - * - * @ORM\JoinTable( - * name="view_chill_main_address_geographical_unit", - * joinColumns={@ORM\JoinColumn(name="address_id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="geographical_unit_id")} - * ) */ + #[ORM\ManyToMany(targetEntity: GeographicalUnit::class)] + #[ORM\JoinTable(name: 'view_chill_main_address_geographical_unit', joinColumns: [new ORM\JoinColumn(name: 'address_id')], inverseJoinColumns: [new ORM\JoinColumn(name: 'geographical_unit_id')])] private Collection $geographicalUnits; /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"write"}) - * * @readonly */ + #[Groups(['write'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] 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'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] private bool $isNoAddress = false; /** * A ThirdParty reference for person's addresses that are linked to a third party. - * - * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") - * - * @Groups({"write"}) - * - * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") */ + #[Groups(['write'])] + #[ORM\ManyToOne(targetEntity: ThirdParty::class)] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?ThirdParty $linkedToThirdParty = null; /** * A geospatial field storing the coordinates of the Address. - * - * @ORM\Column(type="point", nullable=true) - * - * @Groups({"write"}) */ + #[Groups(['write'])] + #[ORM\Column(type: 'point', nullable: true)] private ?Point $point = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") - * - * @ORM\JoinColumn(nullable=false) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\ManyToOne(targetEntity: PostalCode::class)] + #[ORM\JoinColumn(nullable: false)] private ?PostalCode $postcode = null; /** * @var self::ADDR_REFERENCE_STATUS_* - * - * @ORM\Column(type="text", nullable=false, options={"default": self::ADDR_REFERENCE_STATUS_MATCH}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => self::ADDR_REFERENCE_STATUS_MATCH])] private string $refStatus = self::ADDR_REFERENCE_STATUS_MATCH; - /** - * @ORM\Column(type="datetime_immutable", nullable=false, options={"default": "CURRENT_TIMESTAMP"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false, options: ['default' => 'CURRENT_TIMESTAMP'])] private \DateTimeImmutable $refStatusLastUpdate; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $steps = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $street = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Groups({"write"}) - */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $streetNumber = ''; /** * Indicates when the address starts validation. Used to build an history * of address. By default, the current date. - * - * @ORM\Column(type="date") - * - * @Groups({"write"}) */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE)] private \DateTime $validFrom; /** * Indicates when the address ends. Used to build an history * of address. - * - * @ORM\Column(type="date", nullable=true) - * - * @Groups({"write"}) */ + #[Groups(['write'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)] private ?\DateTime $validTo = null; public function __construct() @@ -510,7 +446,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setLinkedToThirdParty($linkedToThirdParty): self + public function setLinkedToThirdParty(?ThirdParty $linkedToThirdParty): self { $this->linkedToThirdParty = $linkedToThirdParty; diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 49b510f8c..b512162bf 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -15,112 +15,68 @@ use Chill\MainBundle\Doctrine\Model\Point; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; -/** - * @ORM\Entity - * - * @ORM\Table(name="chill_main_address_reference", indexes={ - * - * @ORM\Index(name="address_refid", columns={"refId"}) - * }, - * uniqueConstraints={ - * - * @ORM\UniqueConstraint(name="chill_main_address_reference_unicity", columns={"refId", "source"}) - * }) - * - * @ORM\HasLifecycleCallbacks - */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'chill_main_address_reference')] +#[ORM\Index(name: 'address_refid', columns: ['refId'])] +#[ORM\UniqueConstraint(name: 'chill_main_address_reference_unicity', columns: ['refId', 'source'])] class AddressReference { /** * This is an internal column which is populated by database. * * This column will ease the search operations - * - * @ORM\Column(type="text", options={"default": ""}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])] private string $addressCanonical = ''; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $createdAt = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $deletedAt = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @groups({"read"}) - */ + #[Groups(['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": ""}) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $municipalityCode = ''; /** * A geospatial field storing the coordinates of the Address. - * - * @ORM\Column(type="point") - * - * @groups({"read"}) */ + #[Groups(['read'])] + #[ORM\Column(type: 'point')] private ?Point $point = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\ManyToOne(targetEntity: PostalCode::class)] private ?PostalCode $postcode = null; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $refId = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $source = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $street = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $streetNumber = ''; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] 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..e898fea8c 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -16,51 +16,33 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; -/** - * @ORM\Entity - * - * @ORM\Table(name="centers") - */ +#[ORM\Entity] +#[ORM\Table(name: 'centers')] class Center implements HasCenterInterface, \Stringable { /** * @var Collection - * - * @ORM\OneToMany( - * targetEntity="Chill\MainBundle\Entity\GroupCenter", - * mappedBy="center" - * ) */ + #[ORM\OneToMany(targetEntity: GroupCenter::class, mappedBy: 'center')] private Collection $groupCenters; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"docgen:read"}) - */ + #[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="string", length=255) - * - * @Serializer\Groups({"docgen:read"}) - */ + #[Serializer\Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $name = ''; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $isActive = true; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=Regroupment::class, mappedBy="centers") */ + #[ORM\ManyToMany(targetEntity: Regroupment::class, mappedBy: 'centers')] private Collection $regroupments; /** @@ -100,10 +82,7 @@ class Center implements HasCenterInterface, \Stringable return $this->groupCenters; } - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -132,7 +111,7 @@ class Center implements HasCenterInterface, \Stringable /** * @return $this */ - public function setName($name) + public function setName(string $name) { $this->name = $name; diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 322155fe5..2105c8b87 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -14,54 +14,32 @@ namespace Chill\MainBundle\Entity; use Doctrine\ORM\Mapping as ORM; 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])] +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_civility')] class Civility { - /** - * @ORM\Column(type="json") - * - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])] private array $abbreviation = []; - /** - * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $active = true; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] 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'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])] private array $name = []; - /** - * @ORM\Column(type="float", name="ordering", nullable=true, options={"default": 0.0}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'ordering', nullable: true, options: ['default' => '0.0'])] private float $order = 0; public function getAbbreviation(): array diff --git a/src/Bundle/ChillMainBundle/Entity/Country.php b/src/Bundle/ChillMainBundle/Entity/Country.php index 91484ba46..533caeaec 100644 --- a/src/Bundle/ChillMainBundle/Entity/Country.php +++ b/src/Bundle/ChillMainBundle/Entity/Country.php @@ -17,46 +17,30 @@ use Symfony\Component\Serializer\Annotation\Groups; /** * Country. - * - * @ORM\Entity - * - * @ORM\Table(name="country") - * - * @ORM\Cache(usage="READ_ONLY", region="country_cache_region") - * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\Cache(usage: 'READ_ONLY', region: 'country_cache_region')] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'country')] class Country { - /** - * @ORM\Column(type="string", length=3) - * - * @groups({"read", "docgen:read"}) - * - * @Context({"is-translatable": true}, groups={"docgen:read"}) - */ + #[Groups(['read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 3)] + #[Context(['is-translatable' => true], groups: ['docgen:read'])] private string $countryCode = ''; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @groups({"read", "docgen:read"}) - */ + #[Groups(['read', 'docgen:read'])] + #[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") - * - * @groups({"read", "docgen:read"}) - * - * @Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Context(['is-translatable' => true], groups: ['docgen:read'])] private array $name = []; public function getCountryCode(): string diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index ee6ec9012..180a260b8 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -13,42 +13,29 @@ namespace Chill\MainBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table(name="chill_main_cronjob_execution") - */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_cronjob_execution')] class CronJobExecution { final public const FAILURE = 100; final public const SUCCESS = 1; - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])] private ?\DateTimeImmutable $lastEnd = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] private \DateTimeImmutable $lastStart; - /** - * @ORM\Column(type="integer", nullable=true, options={"default": null}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])] private ?int $lastStatus = null; - /** - * @ORM\Column(type="json", options={"default": "'{}'::jsonb", "jsonb": true}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => "'{}'::jsonb", 'jsonb' => true])] private array $lastExecutionData = []; - public function __construct(/** - * @ORM\Column(type="text", nullable=false) - * - * @ORM\Id - */ + public function __construct( + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)] + #[ORM\Id] private string $key ) { $this->lastStart = new \DateTimeImmutable('now'); diff --git a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php index ed9cc07bf..6fdd34cfc 100644 --- a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php +++ b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php @@ -15,52 +15,31 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @ORM\Table(name="chill_main_dashboard_config_item") - */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_dashboard_config_item')] class DashboardConfigItem { - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) - */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="string") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) - * - * @Assert\NotNull - */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] + #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] private string $type = ''; - /** - * @ORM\Column(type="string") - * - * @Serializer\Groups({"dashboardConfigItem:read", "read"}) - * - * @Assert\NotNull - */ + #[Serializer\Groups(['dashboardConfigItem:read', 'read'])] + #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] private string $position = ''; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private ?User $user = null; - /** - * @ORM\Column(type="json", options={"default": "[]", "jsonb": true}) - * - * @Serializer\Groups({"dashboardConfigItem:read"}) - */ + #[Serializer\Groups(['dashboardConfigItem:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] private array $metadata = []; public function getId(): ?int diff --git a/src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php b/src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php index cf858d60f..ea0d4ec29 100644 --- a/src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php +++ b/src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php @@ -11,29 +11,21 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity\Embeddable; -use DateTime; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Embeddable - */ +#[ORM\Embeddable] class CommentEmbeddable { - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $comment = null; - /** - * @ORM\Column(type="datetime", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTime $date = null; /** * Embeddable does not support associations. - * - * @ORM\Column(type="integer", nullable=true) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true)] private ?int $userId = null; public function getComment(): ?string @@ -69,10 +61,7 @@ class CommentEmbeddable $this->date = $date; } - /** - * @param int $userId - */ - public function setUserId($userId) + public function setUserId(?int $userId) { $this->userId = $userId; } diff --git a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php index 3cfed7844..0c2af22f7 100644 --- a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php +++ b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php @@ -14,16 +14,13 @@ namespace Chill\MainBundle\Entity\Embeddable; use Chill\MainBundle\Entity\User; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Embeddable - */ +#[ORM\Embeddable] class PrivateCommentEmbeddable { /** - * @ORM\Column(type="json", nullable=false, options={"default": "{}"}) - * * @var array */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '{}'])] private array $comments = []; public function getCommentForUser(User $user): string @@ -60,7 +57,7 @@ class PrivateCommentEmbeddable return $this; } - public function setComments($comments) + public function setComments(array $comments) { $this->comments = $comments; diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php index 5c70b7bfe..668f95482 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php @@ -13,43 +13,26 @@ namespace Chill\MainBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Table(name="chill_main_geographical_unit", uniqueConstraints={ - * - * @ORM\UniqueConstraint(name="geographical_unit_refid", columns={"layer_id", "unitRefId"}) - * }) - * - * @ORM\Entity(readOnly=true) - */ +#[ORM\Entity(readOnly: true)] +#[ORM\Table(name: 'chill_main_geographical_unit')] +#[ORM\UniqueConstraint(name: 'geographical_unit_refid', columns: ['layer_id', 'unitRefId'])] class GeographicalUnit { - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private string $geom; - /** - * @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=GeographicalUnitLayer::class, inversedBy="units") - */ + #[ORM\ManyToOne(targetEntity: GeographicalUnitLayer::class, inversedBy: 'units')] private ?GeographicalUnitLayer $layer = null; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $unitName; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $unitRefId; public function getId(): ?int diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php index a36e798a4..196b5140a 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php @@ -25,34 +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..e528ab860 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php @@ -16,46 +16,29 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; -/** - * @ORM\Table(name="chill_main_geographical_unit_layer", uniqueConstraints={ - * - * @ORM\UniqueConstraint(name="geographical_unit_layer_refid", columns={"refId"}) - * }) - * - * @ORM\Entity - */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_geographical_unit_layer')] +#[ORM\UniqueConstraint(name: 'geographical_unit_layer_refid', columns: ['refId'])] class GeographicalUnitLayer { - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="json", nullable=false, options={"default": "[]"}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])] private array $name = []; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $refId = ''; /** * @var Collection - * - * @ORM\OneToMany(targetEntity=GeographicalUnit::class, mappedBy="layer") */ + #[ORM\OneToMany(targetEntity: GeographicalUnit::class, mappedBy: 'layer')] private Collection $units; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/GroupCenter.php b/src/Bundle/ChillMainBundle/Entity/GroupCenter.php index bcd4bc8bd..e93b6d19b 100644 --- a/src/Bundle/ChillMainBundle/Entity/GroupCenter.php +++ b/src/Bundle/ChillMainBundle/Entity/GroupCenter.php @@ -15,51 +15,28 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table(name="group_centers") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - */ +#[ORM\Entity] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'acl_cache_region')] +#[ORM\Table(name: 'group_centers')] class GroupCenter { - /** - * @ORM\ManyToOne( - * targetEntity="Chill\MainBundle\Entity\Center", - * inversedBy="groupCenters" - * ) - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") - */ + #[ORM\ManyToOne(targetEntity: Center::class, inversedBy: 'groupCenters')] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private ?Center $center = 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\ManyToOne( - * targetEntity="Chill\MainBundle\Entity\PermissionsGroup", - * inversedBy="groupCenters") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") - */ + #[ORM\ManyToOne(targetEntity: PermissionsGroup::class, inversedBy: 'groupCenters')] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private ?PermissionsGroup $permissionsGroup = null; /** - * @ORM\ManyToMany( - * targetEntity="Chill\MainBundle\Entity\User", - * mappedBy="groupCenters" - * ) - * * @var Collection */ + #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'groupCenters')] private Collection $users; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Language.php b/src/Bundle/ChillMainBundle/Entity/Language.php index 1a91de7b8..894b929ac 100644 --- a/src/Bundle/ChillMainBundle/Entity/Language.php +++ b/src/Bundle/ChillMainBundle/Entity/Language.php @@ -16,35 +16,24 @@ use Symfony\Component\Serializer\Annotation as Serializer; /** * Language. - * - * @ORM\Entity - * - * @ORM\Table(name="language") - * - * @ORM\Cache(usage="READ_ONLY", region="language_cache_region") - * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\Cache(usage: 'READ_ONLY', region: 'language_cache_region')] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'language')] class Language { - /** - * @ORM\Id - * - * @ORM\Column(type="string") - * - * @Serializer\Groups({"docgen:read"}) - */ + #[Serializer\Groups(['docgen:read'])] + #[ORM\Id] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] private ?string $id = null; /** * @var string array - * - * @ORM\Column(type="json") - * - * @Serializer\Groups({"docgen:read"}) - * - * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])] private array $name = []; /** @@ -70,11 +59,9 @@ class Language /** * Set id. * - * @param string $id - * * @return Language */ - public function setId($id) + public function setId(?string $id) { $this->id = $id; @@ -88,7 +75,7 @@ class Language * * @return Language */ - public function setName($name) + public function setName(array $name) { $this->name = $name; diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index 29a049d35..228fd089f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -20,118 +20,67 @@ use libphonenumber\PhoneNumber; use Symfony\Component\Serializer\Annotation as Serializer; 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])] +#[ORM\Entity(repositoryClass: LocationRepository::class)] +#[ORM\Table(name: 'chill_main_location')] class Location implements TrackCreationInterface, TrackUpdateInterface { - /** - * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] 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'])] + #[ORM\ManyToOne(targetEntity: Address::class, cascade: ['persist'])] + #[ORM\JoinColumn(nullable: true)] private ?Address $address = null; - /** - * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $availableForUsers = false; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $createdAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\ManyToOne(targetEntity: User::class)] private ?User $createdBy = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] private ?string $email = null; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] 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'])] + #[ORM\ManyToOne(targetEntity: LocationType::class)] + #[ORM\JoinColumn(nullable: false)] private ?LocationType $locationType = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - * - * @Serializer\Groups({"read", "write", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'write', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] 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'])] + #[ORM\Column(type: 'phone_number', nullable: true)] + #[PhonenumberConstraint(type: 'any')] 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'])] + #[ORM\Column(type: 'phone_number', nullable: true)] + #[PhonenumberConstraint(type: 'any')] private ?PhoneNumber $phonenumber2 = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $updatedAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\ManyToOne(targetEntity: User::class)] 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..df212646a 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -17,17 +17,10 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Serializer\Annotation as Serializer; 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'])] +#[ORM\Entity(repositoryClass: LocationTypeRepository::class)] +#[ORM\Table(name: 'chill_main_location_type')] class LocationType { final public const DEFAULT_FOR_3PARTY = 'thirdparty'; @@ -40,66 +33,39 @@ class LocationType final public const STATUS_REQUIRED = 'required'; - /** - * @ORM\Column(type="boolean", nullable=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] private bool $active = true; - /** - * @ORM\Column(type="string", length=32, options={"default": "optional"}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 32, options: ['default' => 'optional'])] private string $addressRequired = self::STATUS_OPTIONAL; - /** - * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $availableForUsers = true; - /** - * @ORM\Column(type="string", length=32, options={"default": "optional"}) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 32, options: ['default' => 'optional'])] private string $contactData = self::STATUS_OPTIONAL; - /** - * @ORM\Column(type="string", nullable=true, length=32, unique=true) - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true, length: 32, unique: true)] private ?string $defaultFor = null; - /** - * @ORM\Column(type="boolean") - * - * @Serializer\Groups({"read"}) - */ + #[Serializer\Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $editableByUsers = true; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Serializer\Groups({"read", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] 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'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Serializer\Context(['is-translatable' => true], groups: ['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..7acf2de86 100644 --- a/src/Bundle/ChillMainBundle/Entity/NewsItem.php +++ b/src/Bundle/ChillMainBundle/Entity/NewsItem.php @@ -19,66 +19,40 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @ORM\Table(name="chill_main_news") - */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_news')] class NewsItem implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; use TrackUpdateTrait; - /** - * @ORM\Id - * - * @ORM\GeneratedValue - * - * @ORM\Column(type="integer") - * - * @Groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="text") - * - * @Groups({"read"}) - * - * @Assert\NotBlank - * - * @Assert\NotNull - */ + #[Groups(['read'])] + #[Assert\NotBlank] + #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $title = ''; - /** - * @ORM\Column(type="text") - * - * @Groups({"read"}) - * - * @Assert\NotBlank - * - * @Assert\NotNull - */ + #[Groups(['read'])] + #[Assert\NotBlank] + #[Assert\NotNull] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $content = ''; - /** - * @ORM\Column(type="date_immutable", nullable=false) - * - * @Assert\NotNull - * - * @Groups({"read"}) - */ + #[Assert\NotNull] + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)] 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'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])] 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..4165da3d0 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -18,44 +18,30 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; -/** - * @ORM\Entity - * - * @ORM\Table( - * name="chill_main_notification", - * indexes={ - * - * @ORM\Index(name="chill_main_notification_related_entity_idx", columns={"relatedentityclass", "relatedentityid"}) - * } - * ) - * - * @ORM\HasLifecycleCallbacks - */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'chill_main_notification')] +#[ORM\Index(name: 'chill_main_notification_related_entity_idx', columns: ['relatedentityclass', 'relatedentityid'])] class Notification implements TrackUpdateInterface { - /** - * @ORM\Column(type="text", nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)] private string $accessKey; private array $addedAddresses = []; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_notification_addresses_user") */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_notification_addresses_user')] private Collection $addressees; /** * a list of destinee which will receive notifications. * * @var array|string[] - * - * @ORM\Column(type="json") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $addressesEmails = []; /** @@ -69,75 +55,49 @@ class Notification implements TrackUpdateInterface /** * @var Collection - * - * @ORM\OneToMany(targetEntity=NotificationComment::class, mappedBy="notification", orphanRemoval=true) - * - * @ORM\OrderBy({"createdAt": "ASC"}) */ + #[ORM\OneToMany(targetEntity: NotificationComment::class, mappedBy: 'notification', orphanRemoval: true)] + #[ORM\OrderBy(['createdAt' => \Doctrine\Common\Collections\Criteria::ASC])] private Collection $comments; - /** - * @ORM\Column(type="datetime_immutable") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] private \DateTimeImmutable $date; - /** - * @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="text") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $message = ''; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $relatedEntityClass = ''; - /** - * @ORM\Column(type="integer") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private int $relatedEntityId; private array $removedAddresses = []; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] private ?User $sender = null; - /** - * @ORM\Column(type="text", options={"default": ""}) - * - * @Assert\NotBlank(message="notification.Title must be defined") - */ + #[Assert\NotBlank(message: 'notification.Title must be defined')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])] private string $title = ''; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_notification_addresses_unread") */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_notification_addresses_unread')] private Collection $unreadBy; - /** - * @ORM\Column(type="datetime_immutable") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] private ?\DateTimeImmutable $updatedAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private ?User $updatedBy = null; public function __construct() @@ -187,10 +147,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()))) { @@ -314,9 +273,7 @@ class Notification implements TrackUpdateInterface return $this->addUnreadBy($user); } - /** - * @ORM\PreFlush - */ + #[ORM\PreFlush] public function registerUnread() { foreach ($this->addedAddresses as $addressee) { diff --git a/src/Bundle/ChillMainBundle/Entity/NotificationComment.php b/src/Bundle/ChillMainBundle/Entity/NotificationComment.php index 49d1e859d..53d3fba2f 100644 --- a/src/Bundle/ChillMainBundle/Entity/NotificationComment.php +++ b/src/Bundle/ChillMainBundle/Entity/NotificationComment.php @@ -18,48 +18,29 @@ use Doctrine\ORM\Event\PrePersistEventArgs; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @ORM\Table("chill_main_notification_comment") - * - * @ORM\HasLifecycleCallbacks - */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table('chill_main_notification_comment')] class NotificationComment implements TrackCreationInterface, TrackUpdateInterface { - /** - * @ORM\Column(type="text") - * - * @Assert\NotBlank(message="notification.Comment content might not be blank") - */ + #[Assert\NotBlank(message: 'notification.Comment content might not be blank')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $content = ''; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $createdAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] private ?User $createdBy = 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=Notification::class, inversedBy="comments") - * - * @ORM\JoinColumn(nullable=false) - */ + #[ORM\ManyToOne(targetEntity: Notification::class, inversedBy: 'comments')] + #[ORM\JoinColumn(nullable: false)] private ?Notification $notification = null; /** @@ -71,16 +52,12 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac /** * TODO typo in property (hotfixed). - * - * @ORM\Column(type="datetime_immutable", nullable=true) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $updateAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] private ?User $updatedBy = null; public function getContent(): string @@ -118,9 +95,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac return $this->updatedBy; } - /** - * @ORM\PreFlush - */ + #[ORM\PreFlush] public function onFlushMarkNotificationAsUnread(PreFlushEventArgs $eventArgs): void { if ($this->recentlyPersisted) { @@ -136,9 +111,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac } } - /** - * @ORM\PrePersist - */ + #[ORM\PrePersist] public function onPrePersist(PrePersistEventArgs $eventArgs): void { $this->recentlyPersisted = true; diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 4a28267cd..a52b3f427 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -16,56 +16,36 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Context\ExecutionContextInterface; -/** - * @ORM\Entity - * - * @ORM\Table(name="permission_groups") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - */ +#[ORM\Entity] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'acl_cache_region')] +#[ORM\Table(name: 'permission_groups')] class PermissionsGroup { /** * @var string[] - * - * @ORM\Column(type="json") */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $flags = []; /** * @var Collection - * - * @ORM\OneToMany( - * targetEntity="Chill\MainBundle\Entity\GroupCenter", - * mappedBy="permissionsGroup" - * ) */ + #[ORM\OneToMany(targetEntity: GroupCenter::class, mappedBy: 'permissionsGroup')] private Collection $groupCenters; - /** - * @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="string", length=255, nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => ''])] private string $name = ''; /** * @var Collection - * - * @ORM\ManyToMany( - * targetEntity="Chill\MainBundle\Entity\RoleScope", - * inversedBy="permissionsGroups", - * cascade={ "persist" }) - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ + #[ORM\ManyToMany(targetEntity: RoleScope::class, inversedBy: 'permissionsGroups', cascade: ['persist'])] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private Collection $roleScopes; /** @@ -157,7 +137,7 @@ class PermissionsGroup /** * @return $this */ - public function setName($name) + public function setName(string $name) { $this->name = $name; diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 4d906d6c8..ecab19a5f 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -21,24 +21,16 @@ use Symfony\Component\Serializer\Annotation\Groups; /** * PostalCode. - * - * @ORM\Entity - * - * @ORM\Table( - * name="chill_main_postal_code", - * uniqueConstraints={ - * - * @ORM\UniqueConstraint(name="postal_code_import_unicity", columns={"code", "refpostalcodeid", "postalcodesource"}, - * options={"where": "refpostalcodeid is not null"}) - * }, - * indexes={ - * - * @ORM\Index(name="search_name_code", columns={"code", "label"}), - * @ORM\Index(name="search_by_reference_code", columns={"code", "refpostalcodeid"}) - * }) - * - * @ORM\HasLifecycleCallbacks */ +#[ORM\Entity] +#[ORM\HasLifecycleCallbacks] +#[ORM\Table(name: 'chill_main_postal_code')] +#[ORM\Index(name: 'search_name_code', columns: ['code', 'label'])] +#[ORM\Index(name: 'search_by_reference_code', columns: ['code', 'refpostalcodeid'])] +#[ORM\UniqueConstraint(name: 'postal_code_import_unicity', columns: ['code', 'refpostalcodeid', 'postalcodesource'], options: ['where' => 'refpostalcodeid is not null'])] +#[ORM\UniqueConstraint(name: 'postal_code_import_unicity', columns: ['code', 'refpostalcodeid', 'postalcodesource'], options: ['where' => 'refpostalcodeid is not null'])] // , +#[ORM\Index(name: 'search_name_code', columns: ['code', 'label'])] // , +#[ORM\Index(name: 'search_by_reference_code', columns: ['code', 'refpostalcodeid'])] class PostalCode implements TrackUpdateInterface, TrackCreationInterface { use TrackCreationTrait; @@ -49,74 +41,45 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface * This is an internal column which is populated by database. * * This column will ease the search operations - * - * @ORM\Column(type="text", options={"default": ""}) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])] private string $canonical = ''; - /** - * @ORM\Column(type="point", nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: 'point', nullable: true)] private ?Point $center = null; - /** - * @ORM\Column(type="string", length=100) - * - * @groups({"write", "read"}) - */ + #[Groups(['write', 'read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 100)] private ?string $code = null; - /** - * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country") - * - * @groups({"write", "read"}) - */ + #[Groups(['write', 'read'])] + #[ORM\ManyToOne(targetEntity: Country::class)] private ?Country $country = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])] private ?\DateTimeImmutable $deletedAt = null; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @groups({"write", "read"}) - */ + #[Groups(['write', '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", length=255, name="label") - * - * @groups({"write", "read"}) - */ + #[Groups(['write', 'read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, name: 'label')] private ?string $name = null; - /** - * @ORM\Column(name="origin", type="integer", nullable=true) - * - * @groups({"write", "read"}) - */ + #[Groups(['write', 'read'])] + #[ORM\Column(name: 'origin', type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true)] private int $origin = 0; - /** - * @ORM\Column(type="string", length=255, nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] private ?string $postalCodeSource = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - * - * @groups({"read"}) - */ + #[Groups(['read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] private ?string $refPostalCodeId = null; public function getCenter(): ?Point @@ -194,11 +157,9 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface /** * Set code. * - * @param string $code - * * @return PostalCode */ - public function setCode($code) + public function setCode(?string $code) { $this->code = $code; @@ -220,11 +181,9 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface /** * Set name. * - * @param string $name - * * @return PostalCode */ - public function setName($name) + public function setName(?string $name) { $this->name = $name; @@ -234,11 +193,9 @@ class PostalCode implements TrackUpdateInterface, TrackCreationInterface /** * Set origin. * - * @param int $origin - * * @return PostalCode */ - public function setOrigin($origin) + public function setOrigin(int $origin) { $this->origin = $origin; diff --git a/src/Bundle/ChillMainBundle/Entity/Regroupment.php b/src/Bundle/ChillMainBundle/Entity/Regroupment.php index 4945a62c7..b2d61e34d 100644 --- a/src/Bundle/ChillMainBundle/Entity/Regroupment.php +++ b/src/Bundle/ChillMainBundle/Entity/Regroupment.php @@ -15,42 +15,26 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table(name="regroupment") - */ +#[ORM\Entity] +#[ORM\Table(name: 'regroupment')] class Regroupment { /** - * @ORM\ManyToMany( - * targetEntity=Center::class, - * inversedBy="regroupments" - * ) - * - * @ORM\Id - * * @var Collection
*/ + #[ORM\ManyToMany(targetEntity: Center::class, inversedBy: 'regroupments')] + #[ORM\Id] private Collection $centers; - /** - * @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") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $isActive = true; - /** - * @ORM\Column(type="text", options={"default": ""}, nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''], nullable: false)] private string $name = ''; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/RoleScope.php b/src/Bundle/ChillMainBundle/Entity/RoleScope.php index 4777505f5..3f4047dc8 100644 --- a/src/Bundle/ChillMainBundle/Entity/RoleScope.php +++ b/src/Bundle/ChillMainBundle/Entity/RoleScope.php @@ -15,47 +15,28 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table(name="role_scopes") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - */ +#[ORM\Entity] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'acl_cache_region')] +#[ORM\Table(name: 'role_scopes')] class RoleScope { - /** - * @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 Collection - * - * @ORM\ManyToMany( - * targetEntity="Chill\MainBundle\Entity\PermissionsGroup", - * mappedBy="roleScopes") */ + #[ORM\ManyToMany(targetEntity: PermissionsGroup::class, mappedBy: 'roleScopes')] private Collection $permissionsGroups; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private ?string $role = null; - /** - * @ORM\ManyToOne( - * targetEntity="Chill\MainBundle\Entity\Scope", - * inversedBy="roleScopes") - * - * @ORM\JoinColumn(nullable=true, name="scope_id") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") - */ + #[ORM\ManyToOne(targetEntity: Scope::class, inversedBy: 'roleScopes')] + #[ORM\JoinColumn(nullable: true, name: 'scope_id')] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private ?Scope $scope = null; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/SavedExport.php b/src/Bundle/ChillMainBundle/Entity/SavedExport.php index 224423783..eec6b83e4 100644 --- a/src/Bundle/ChillMainBundle/Entity/SavedExport.php +++ b/src/Bundle/ChillMainBundle/Entity/SavedExport.php @@ -20,53 +20,34 @@ use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidInterface; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @ORM\Table(name="chill_main_saved_export") - */ +#[ORM\Entity] +#[ORM\Table(name: 'chill_main_saved_export')] class SavedExport implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; use TrackUpdateTrait; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Assert\NotBlank - */ + #[Assert\NotBlank] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $description = ''; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $exportAlias; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="uuid", unique="true") - * - * @ORM\GeneratedValue(strategy="NONE") - */ + #[ORM\Id] + #[ORM\Column(name: 'id', type: 'uuid', unique: true)] + #[ORM\GeneratedValue(strategy: 'NONE')] private UuidInterface $id; - /** - * @ORM\Column(type="json", nullable=false, options={"default": "[]"}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])] private array $options = []; - /** - * @ORM\Column(type="text", nullable=false, options={"default": ""}) - * - * @Assert\NotBlank - */ + #[Assert\NotBlank] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])] private string $title = ''; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private User $user; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/Scope.php b/src/Bundle/ChillMainBundle/Entity/Scope.php index 464d60488..3e891062b 100644 --- a/src/Bundle/ChillMainBundle/Entity/Scope.php +++ b/src/Bundle/ChillMainBundle/Entity/Scope.php @@ -18,55 +18,34 @@ use Symfony\Component\Serializer\Annotation\Context; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; -/** - * @ORM\Entity - * - * @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])] +#[ORM\Entity] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'acl_cache_region')] +#[ORM\Table(name: 'scopes')] class Scope { - /** - * @ORM\Column(type="boolean", nullable=false, options={"default": true}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => true])] private bool $active = true; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @Groups({"read", "docgen:read"}) - */ + #[Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** * translatable names. - * - * @ORM\Column(type="json") - * - * @Groups({"read", "docgen:read"}) - * - * @Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Groups(['read', 'docgen:read'])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[Context(['is-translatable' => true], groups: ['docgen:read'])] private array $name = []; /** * @var Collection - * - * @ORM\OneToMany( - * targetEntity="Chill\MainBundle\Entity\RoleScope", - * mappedBy="scope") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ + #[ORM\OneToMany(targetEntity: RoleScope::class, mappedBy: 'scope')] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private Collection $roleScopes; /** diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 05112430c..22b1404e7 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -19,6 +19,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; use libphonenumber\PhoneNumber; +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; @@ -26,150 +27,93 @@ use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint; /** * User. - * - * @ORM\Entity - * - * @ORM\Table(name="users") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region") - * - * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ - * "user": User::class - * }) */ -class User implements UserInterface, \Stringable +#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['user' => User::class])] +#[ORM\Entity] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'acl_cache_region')] +#[ORM\Table(name: 'users')] +class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInterface { - /** - * @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')] protected ?int $id = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $absenceStart = null; /** * Array where SAML attributes's data are stored. - * - * @ORM\Column(type="json", nullable=false) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false)] private array $attributes = []; - /** - * @ORM\ManyToOne(targetEntity=Civility::class) - */ + #[ORM\ManyToOne(targetEntity: Civility::class)] private ?Civility $civility = null; - /** - * @ORM\ManyToOne(targetEntity=Location::class) - */ + #[ORM\ManyToOne(targetEntity: Location::class)] private ?Location $currentLocation = null; - /** - * @ORM\Column(type="string", length=150, nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 150, nullable: true)] private ?string $email = null; - /** - * @ORM\Column( - * type="string", - * length=150, - * nullable=true, - * unique=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 150, nullable: true, unique: true)] private ?string $emailCanonical = null; - /** - * @ORM\Column(type="boolean") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $enabled = true; /** * @var Collection - * - * @ORM\ManyToMany( - * targetEntity="Chill\MainBundle\Entity\GroupCenter", - * inversedBy="users") - * - * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ + #[ORM\ManyToMany(targetEntity: GroupCenter::class, inversedBy: 'users')] + #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] private Collection $groupCenters; - /** - * @ORM\Column(type="string", length=200) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 200)] private string $label = ''; - /** - * @ORM\Column(type="boolean") - * sf4 check: in yml was false by default !? - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] // sf4 check: in yml was false by default !? private bool $locked = true; - /** - * @ORM\ManyToOne(targetEntity=Center::class) - */ + #[ORM\ManyToOne(targetEntity: Center::class)] private ?Center $mainCenter = null; - /** - * @ORM\ManyToOne(targetEntity=Location::class) - */ + #[ORM\ManyToOne(targetEntity: Location::class)] private ?Location $mainLocation = null; /** * @var Collection&Selectable - * - * @ORM\OneToMany(targetEntity=UserScopeHistory::class, - * mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) */ + #[ORM\OneToMany(targetEntity: UserScopeHistory::class, mappedBy: 'user', cascade: ['persist', 'remove'], orphanRemoval: true)] private Collection&Selectable $scopeHistories; - /** - * @ORM\Column(type="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $password = ''; /** * @internal must be set to null if we use bcrypt - * - * @ORM\Column(type="string", length=255, nullable=true) */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)] private ?string $salt = null; /** * @var Collection&Selectable - * - * @ORM\OneToMany(targetEntity=UserJobHistory::class, - * mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) */ + #[ORM\OneToMany(targetEntity: UserJobHistory::class, mappedBy: 'user', cascade: ['persist', 'remove'], orphanRemoval: true)] private Collection&Selectable $jobHistories; - /** - * @ORM\Column(type="string", length=80) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 80)] private string $username = ''; - /** - * @ORM\Column( - * type="string", - * length=80, - * unique=true, - * nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 80, unique: true, nullable: true)] private ?string $usernameCanonical = null; /** * The user's mobile phone number. - * - * @ORM\Column(type="phone_number", nullable=true) - * - * @PhonenumberConstraint() */ + #[ORM\Column(type: 'phone_number', nullable: true)] + #[PhonenumberConstraint] private ?PhoneNumber $phonenumber = null; /** @@ -197,9 +141,7 @@ class User implements UserInterface, \Stringable return $this; } - public function eraseCredentials() - { - } + public function eraseCredentials() {} public function getAbsenceStart(): ?\DateTimeImmutable { @@ -308,10 +250,7 @@ class User implements UserInterface, \Stringable return new ArrayCollection($sortedScopeHistories); } - /** - * @return string - */ - public function getPassword() + public function getPassword(): ?string { return $this->password; } @@ -368,6 +307,11 @@ class User implements UserInterface, \Stringable return $this->username; } + public function getUserIdentifier(): string + { + return $this->username; + } + /** * @return string */ @@ -488,7 +432,7 @@ class User implements UserInterface, \Stringable /** * @return $this */ - public function setEmail($email) + public function setEmail(?string $email) { $this->email = $email; @@ -498,7 +442,7 @@ class User implements UserInterface, \Stringable /** * @return $this */ - public function setEmailCanonical($emailCanonical) + public function setEmailCanonical(?string $emailCanonical) { $this->emailCanonical = $emailCanonical; @@ -549,7 +493,7 @@ class User implements UserInterface, \Stringable $this->scopeHistories[] = $newScope; $criteria = new Criteria(); - $criteria->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Ascending, 'id' => \Doctrine\Common\Collections\Order::Ascending]); + $criteria->orderBy(['startDate' => 'ASC', 'id' => 'ASC']); /** @var \Iterator $scopes */ $scopes = $this->scopeHistories->matching($criteria)->getIterator(); @@ -572,7 +516,7 @@ class User implements UserInterface, \Stringable /** * @return $this */ - public function setPassword($password) + public function setPassword(string $password) { $this->password = $password; @@ -582,7 +526,7 @@ class User implements UserInterface, \Stringable /** * @return $this */ - public function setSalt($salt) + public function setSalt(?string $salt) { $this->salt = $salt; @@ -644,7 +588,7 @@ class User implements UserInterface, \Stringable /** * @return $this */ - public function setUsernameCanonical($usernameCanonical) + public function setUsernameCanonical(?string $usernameCanonical) { $this->usernameCanonical = $usernameCanonical; diff --git a/src/Bundle/ChillMainBundle/Entity/User/UserJobHistory.php b/src/Bundle/ChillMainBundle/Entity/User/UserJobHistory.php index 7916d9891..4437b7356 100644 --- a/src/Bundle/ChillMainBundle/Entity/User/UserJobHistory.php +++ b/src/Bundle/ChillMainBundle/Entity/User/UserJobHistory.php @@ -11,45 +11,29 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity\User; -use App\Repository\UserJobHistoryRepository; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Table(name="chill_main_user_job_history") - * - * @ORM\Entity(repositoryClass=UserJobHistoryRepository::class) - */ +#[ORM\Entity(repositoryClass: \Chill\MainBundle\Repository\User\UserJobHistoryRepository::class)] +#[ORM\Table(name: 'chill_main_user_job_history')] class UserJobHistory { - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $endDate = 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=UserJob::class) - */ + #[ORM\ManyToOne(targetEntity: UserJob::class)] private ?UserJob $job = null; - /** - * @ORM\Column(type="datetime_immutable") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] private \DateTimeImmutable $startDate; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private User $user; public function getEndDate(): ?\DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Entity/User/UserScopeHistory.php b/src/Bundle/ChillMainBundle/Entity/User/UserScopeHistory.php index 6ac768de2..64ecbfd64 100644 --- a/src/Bundle/ChillMainBundle/Entity/User/UserScopeHistory.php +++ b/src/Bundle/ChillMainBundle/Entity/User/UserScopeHistory.php @@ -11,45 +11,30 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity\User; -use App\Repository\UserScopeHistoryRepository; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Repository\User\UserScopeHistoryRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Table(name="chill_main_user_scope_history") - * - * @ORM\Entity(repositoryClass=UserScopeHistoryRepository::class) - */ +#[ORM\Entity(repositoryClass: UserScopeHistoryRepository::class)] +#[ORM\Table(name: 'chill_main_user_scope_history')] class UserScopeHistory { - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $endDate = 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=Scope::class) - */ + #[ORM\ManyToOne(targetEntity: Scope::class)] private ?Scope $scope = null; - /** - * @ORM\Column(type="datetime_immutable") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] private \DateTimeImmutable $startDate; - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ + #[ORM\ManyToOne(targetEntity: User::class)] private User $user; public function getEndDate(): ?\DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Entity/UserJob.php b/src/Bundle/ChillMainBundle/Entity/UserJob.php index 6be1a5efe..2efb85e34 100644 --- a/src/Bundle/ChillMainBundle/Entity/UserJob.php +++ b/src/Bundle/ChillMainBundle/Entity/UserJob.php @@ -14,42 +14,26 @@ namespace Chill\MainBundle\Entity; use Doctrine\ORM\Mapping as ORM; 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])] +#[ORM\Entity] +#[ORM\Table('chill_main_user_job')] class UserJob { - /** - * @ORM\Column(name="active", type="boolean") - */ + #[ORM\Column(name: 'active', type: \Doctrine\DBAL\Types\Types::BOOLEAN)] protected bool $active = true; - /** - * @ORM\Id - * - * @ORM\Column(name="id", type="integer") - * - * @ORM\GeneratedValue(strategy="AUTO") - * - * @Serializer\Groups({"read", "docgen:read"}) - */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Id] + #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\GeneratedValue(strategy: 'AUTO')] protected ?int $id = null; /** * @var array - * - * @ORM\Column(name="label", type="json") - * - * @Serializer\Groups({"read", "docgen:read"}) - * - * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ + #[Serializer\Groups(['read', 'docgen:read'])] + #[ORM\Column(name: 'label', type: \Doctrine\DBAL\Types\Types::JSON)] + #[Serializer\Context(['is-translatable' => true], groups: ['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..6996eacea 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -19,21 +19,15 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Collections\Order; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * - * @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])] +#[ORM\Entity] +#[ORM\Table('chill_main_workflow_entity')] +#[EntityWorkflowCreation(groups: ['creation'])] class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; @@ -70,40 +64,28 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface public array $futureDestUsers = []; /** - * @ORM\OneToMany(targetEntity=EntityWorkflowComment::class, mappedBy="entityWorkflow", orphanRemoval=true) - * * @var Collection */ + #[ORM\OneToMany(targetEntity: EntityWorkflowComment::class, mappedBy: 'entityWorkflow', orphanRemoval: true)] private Collection $comments; - /** - * @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="string", length=255) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $relatedEntityClass = ''; - /** - * @ORM\Column(type="integer") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private int $relatedEntityId; /** - * @ORM\OneToMany(targetEntity=EntityWorkflowStep::class, mappedBy="entityWorkflow", orphanRemoval=true, cascade={"persist"}) - * - * @ORM\OrderBy({"transitionAt": "ASC", "id": "ASC"}) - * - * @Assert\Valid(traverse=true) - * * @var Collection */ + #[Assert\Valid(traverse: true)] + #[ORM\OneToMany(targetEntity: EntityWorkflowStep::class, mappedBy: 'entityWorkflow', orphanRemoval: true, cascade: ['persist'])] + #[ORM\OrderBy(['transitionAt' => Order::Ascending, 'id' => 'ASC'])] private Collection $steps; /** @@ -112,21 +94,17 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface private ?array $stepsChainedCache = null; /** - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_final") - * * @var Collection */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_workflow_entity_subscriber_to_final')] private Collection $subscriberToFinal; /** - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_step") - * * @var Collection */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_workflow_entity_subscriber_to_step')] private Collection $subscriberToStep; /** @@ -134,9 +112,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface */ private ?EntityWorkflowStep $transitionningStep = null; - /** - * @ORM\Column(type="text") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $workflowName; public function __construct() diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowComment.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowComment.php index 9b02bbb9e..2943e5cff 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowComment.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowComment.php @@ -17,34 +17,23 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * - * @ORM\Table("chill_main_workflow_entity_comment") - */ +#[ORM\Entity] +#[ORM\Table('chill_main_workflow_entity_comment')] class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterface { use TrackCreationTrait; use TrackUpdateTrait; - /** - * @ORM\Column(type="text", options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])] private string $comment = ''; - /** - * @ORM\ManyToOne(targetEntity=EntityWorkflow::class, inversedBy="comments") - */ + #[ORM\ManyToOne(targetEntity: EntityWorkflow::class, inversedBy: 'comments')] private ?EntityWorkflow $entityWorkflow = 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; public function getComment(): string diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index 53e4ad945..99b164065 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -18,82 +18,55 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; -/** - * @ORM\Entity - * - * @ORM\Table("chill_main_workflow_entity_step") - */ +#[ORM\Entity] +#[ORM\Table('chill_main_workflow_entity_step')] class EntityWorkflowStep { - /** - * @ORM\Column(type="text", nullable=false) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)] private string $accessKey; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_workflow_entity_step_cc_user") */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_workflow_entity_step_cc_user')] private Collection $ccUser; - /** - * @ORM\Column(type="text", options={"default": ""}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])] private string $comment = ''; - /** - * @ORM\Column(type="text") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private ?string $currentStep = ''; - /** - * @ORM\Column(type="json") - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array $destEmail = []; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_workflow_entity_step_user") */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_workflow_entity_step_user')] private Collection $destUser; /** * @var Collection - * - * @ORM\ManyToMany(targetEntity=User::class) - * - * @ORM\JoinTable(name="chill_main_workflow_entity_step_user_by_accesskey") */ + #[ORM\ManyToMany(targetEntity: User::class)] + #[ORM\JoinTable(name: 'chill_main_workflow_entity_step_user_by_accesskey')] private Collection $destUserByAccessKey; - /** - * @ORM\ManyToOne(targetEntity=EntityWorkflow::class, inversedBy="steps") - */ + #[ORM\ManyToOne(targetEntity: EntityWorkflow::class, inversedBy: 'steps')] private ?EntityWorkflow $entityWorkflow = null; - /** - * @ORM\Column(type="boolean", options={"default": false}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] private bool $freezeAfter = false; - /** - * @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": false}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])] private bool $isFinal = false; /** @@ -106,26 +79,17 @@ class EntityWorkflowStep */ private ?EntityWorkflowStep $previous = null; - /** - * @ORM\Column(type="text", nullable=true, options={"default": null}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true, options: ['default' => null])] private ?string $transitionAfter = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])] private ?\DateTimeImmutable $transitionAt = null; - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] private ?User $transitionBy = null; - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $transitionByEmail = null; public function __construct() @@ -413,9 +377,7 @@ class EntityWorkflowStep return $this; } - /** - * @Assert\Callback - */ + #[Assert\Callback] public function validateOnCreation(ExecutionContextInterface $context, mixed $payload): void { return; diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index c448077e3..4746b6129 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -26,8 +26,7 @@ final readonly class ExportFormHelper private AuthorizationHelperForCurrentUserInterface $authorizationHelper, private ExportManager $exportManager, private FormFactoryInterface $formFactory, - ) { - } + ) {} public function getDefaultData(string $step, DirectExportInterface|ExportInterface $export, array $options = []): array { diff --git a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php index 3be1af08a..0fad30b4f 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php @@ -15,9 +15,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class DateTimeHelper { - public function __construct(private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly TranslatorInterface $translator) {} public function getLabel($header): callable { diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 07a4f9f88..9161316e7 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -79,9 +79,7 @@ class ExportAddressHelper */ private ?array $unitRefsKeysCache = []; - public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {} public function addSelectClauses(int $params, QueryBuilder $queryBuilder, $entityName = 'address', $prefix = 'add') { diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index fc19f7466..1b561390a 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -21,9 +21,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; */ class TranslatableStringExportLabelHelper { - public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {} public function getLabel(string $key, array $values, string $header) { diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 36b126df9..ee164b93c 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -16,9 +16,7 @@ use Chill\MainBundle\Templating\Entity\UserRender; class UserHelper { - public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository) - { - } + public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository) {} /** * Return a callable that will transform a value into a string representing a user. diff --git a/src/Bundle/ChillMainBundle/Export/ListInterface.php b/src/Bundle/ChillMainBundle/Export/ListInterface.php index 53442f0e7..9b88525ca 100644 --- a/src/Bundle/ChillMainBundle/Export/ListInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ListInterface.php @@ -20,6 +20,4 @@ namespace Chill\MainBundle\Export; * * When used, the `ExportManager` will not handle aggregator for this class. */ -interface ListInterface extends ExportInterface -{ -} +interface ListInterface extends ExportInterface {} diff --git a/src/Bundle/ChillMainBundle/Export/SortExportElement.php b/src/Bundle/ChillMainBundle/Export/SortExportElement.php index 0536f6569..6228109ed 100644 --- a/src/Bundle/ChillMainBundle/Export/SortExportElement.php +++ b/src/Bundle/ChillMainBundle/Export/SortExportElement.php @@ -17,8 +17,7 @@ final readonly class SortExportElement { public function __construct( private TranslatorInterface $translator, - ) { - } + ) {} /** * @param array $elements diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php index c88e2275b..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, $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($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 73d048c1a..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, $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($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 10f9c26e3..3f1284db8 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php @@ -19,11 +19,9 @@ use Symfony\Component\Security\Core\Security; final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface { - public function __construct(private readonly Security $security) - { - } + public function __construct(private readonly Security $security) {} - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, \Traversable $forms) { if (null === $viewData) { return null; @@ -38,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(\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 6a139de7b..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, $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($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 267927ff1..d6a0cea20 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php @@ -16,11 +16,9 @@ use Symfony\Component\Form\DataMapperInterface; class ScopePickerDataMapper implements DataMapperInterface { - public function __construct(private readonly ?Scope $scope = null) - { - } + public function __construct(private readonly ?Scope $scope = null) {} - public function mapDataToForms($data, $forms) + public function mapDataToForms($data, \Traversable $forms) { $forms = iterator_to_array($forms); @@ -39,7 +37,7 @@ class ScopePickerDataMapper implements DataMapperInterface } } - public function mapFormsToData($forms, &$data) + public function mapFormsToData(\Traversable $forms, &$data) { $forms = iterator_to_array($forms); diff --git a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php index aba5e2bc4..42606ebd7 100644 --- a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php +++ b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php @@ -17,9 +17,7 @@ class CustomizeFormEvent extends \Symfony\Contracts\EventDispatcher\Event { final public const NAME = 'chill_main.customize_form'; - public function __construct(protected string $type, protected FormBuilderInterface $builder) - { - } + public function __construct(protected string $type, protected FormBuilderInterface $builder) {} public function getBuilder(): FormBuilderInterface { diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index e4748d850..7f61cccce 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -24,9 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class LocationFormType extends AbstractType { - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) - { - } + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php index c04a4b158..04094537b 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php @@ -17,9 +17,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; final readonly class AddressToIdDataTransformer implements DataTransformerInterface { - public function __construct(private AddressRepository $addressRepository) - { - } + public function __construct(private AddressRepository $addressRepository) {} public function reverseTransform($value) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php index 9a8b0a6d7..d328d38f0 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php @@ -20,9 +20,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException; class CenterTransformer implements DataTransformerInterface { - public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false) - { - } + public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false) {} public function reverseTransform($id) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index bd54b0c09..d193ea2ef 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -22,9 +22,7 @@ use Symfony\Component\Serializer\SerializerInterface; class EntityToJsonTransformer implements DataTransformerInterface { - public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type) - { - } + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type) {} public function reverseTransform($value) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php index 436b72ce3..808093278 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php @@ -17,9 +17,7 @@ use Symfony\Component\Form\DataTransformerInterface; class MultipleObjectsToIdTransformer implements DataTransformerInterface { - public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) - { - } + public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {} /** * Transforms a string (id) to an object (item). diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php index ffdee60bd..e56778bf2 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php @@ -17,9 +17,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ObjectToIdTransformer implements DataTransformerInterface { - public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) - { - } + public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {} /** * Transforms a string (id) to an object. diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php index 5f9117577..dde8b7b9e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php @@ -18,9 +18,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class PostalCodeToIdTransformer implements DataTransformerInterface { - public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository) - { - } + public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository) {} public function reverseTransform($value) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php index cb5adec47..2779f2cdd 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php @@ -18,9 +18,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ScopeTransformer implements DataTransformerInterface { - public function __construct(private readonly EntityManagerInterface $em) - { - } + public function __construct(private readonly EntityManagerInterface $em) {} public function reverseTransform($id) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php index 7a70e7ca6..c9bc4dd82 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DateIntervalType.php @@ -55,7 +55,6 @@ class DateIntervalType extends AbstractType { $builder ->add('n', IntegerType::class, [ - 'scale' => 0, 'constraints' => [ new GreaterThan([ 'value' => 0, diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php index 1ea01d5f8..cfcf4a471 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php @@ -19,9 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class AggregatorType extends AbstractType { - public function __construct() - { - } + public function __construct() {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php index 930712084..e5d0887f3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php @@ -29,9 +29,7 @@ class ExportType extends AbstractType final public const PICK_FORMATTER_KEY = 'pick_formatter'; - public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) - { - } + public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php index 8491d8f6a..bcf842e73 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php @@ -22,9 +22,7 @@ class FilterType extends AbstractType { final public const ENABLED_FIELD = 'enabled'; - public function __construct() - { - } + public function __construct() {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 01e3ba60a..a093dda44 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -33,8 +33,7 @@ final class PickCenterType extends AbstractType private readonly ExportManager $exportManager, private readonly RegroupmentRepository $regroupmentRepository, private readonly AuthorizationHelperForCurrentUserInterface $authorizationHelper - ) { - } + ) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php index 8750ee006..190e09f30 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php @@ -41,9 +41,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ final class PickAddressType extends AbstractType { - public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index 12b170a73..ba6cc874d 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -34,9 +34,7 @@ use function count; */ class PickCenterType extends AbstractType { - public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository) - { - } + public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository) {} /** * add a data transformer if user can reach only one center. diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index abe190de5..f9aa09ce8 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -21,9 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickCivilityType extends AbstractType { - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) - { - } + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {} public function configureOptions(OptionsResolver $resolver) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 7fb50fd4a..8aa216da1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -19,9 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickLocationTypeType extends AbstractType { - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) - { - } + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {} public function configureOptions(OptionsResolver $resolver) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php index 041176905..1a1ed4354 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php @@ -21,9 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickPostalCodeType extends AbstractType { - public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer) - { - } + public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index ad23e5655..aab9d4c51 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -27,9 +27,7 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickUserDynamicType extends AbstractType { - public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) - { - } + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index bea96b79b..9d1cdb626 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -20,9 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickUserLocationType extends AbstractType { - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository) - { - } + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository) {} public function configureOptions(OptionsResolver $resolver) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php index 44354922f..0d26b5a95 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php @@ -21,9 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PrivateCommentType extends AbstractType { - public function __construct(protected PrivateCommentDataMapper $dataMapper) - { - } + public function __construct(protected PrivateCommentDataMapper $dataMapper) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index fd27a9bcb..10d083bd8 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -39,9 +39,11 @@ use Symfony\Component\Security\Core\Security; */ class ScopePickerType extends AbstractType { - public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct( + private readonly AuthorizationHelperInterface $authorizationHelper, + private readonly Security $security, + private readonly TranslatableStringHelperInterface $translatableStringHelper + ) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index 370de1137..e9ff503df 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -26,9 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class Select2CountryType extends AbstractType { - public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) - { - } + public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 9d634857a..68a3970ba 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -26,9 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class Select2LanguageType extends AbstractType { - public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) - { - } + public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {} public function buildForm(FormBuilderInterface $builder, array $options) { 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/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 4a6bb8f9a..9d62fbc6a 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -36,9 +36,7 @@ use Symfony\Component\Validator\Constraints\Regex; class UserType extends AbstractType { - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) - { - } + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index f0360d4bb..3a3f1b8d3 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -34,9 +34,7 @@ use Symfony\Component\Workflow\Transition; class WorkflowStepType extends AbstractType { - public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) - { - } + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) {} public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php index e08543e8c..b61f38a35 100644 --- a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php @@ -24,9 +24,7 @@ use Symfony\Component\Security\Core\User\UserInterface; final readonly class NotificationByUserCounter implements NotificationCounterInterface { - public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository) - { - } + public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository) {} public function addNotification(UserInterface $u): int { diff --git a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php index 7eba06242..7b535f1a7 100644 --- a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php @@ -24,9 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class NotificationMailer { - public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) {} public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void { diff --git a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php index fc2cd35ea..3268fee05 100644 --- a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php @@ -18,9 +18,7 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent; class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface { - public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister) - { - } + public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister) {} public static function getSubscribedEvents() { @@ -33,7 +31,7 @@ class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberIn public function onKernelTerminate(TerminateEvent $event): void { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->persistNotifications(); } } diff --git a/src/Bundle/ChillMainBundle/Notification/Exception/NotificationHandlerNotFound.php b/src/Bundle/ChillMainBundle/Notification/Exception/NotificationHandlerNotFound.php index a55104d23..b1acff57b 100644 --- a/src/Bundle/ChillMainBundle/Notification/Exception/NotificationHandlerNotFound.php +++ b/src/Bundle/ChillMainBundle/Notification/Exception/NotificationHandlerNotFound.php @@ -11,6 +11,4 @@ declare(strict_types=1); namespace Chill\MainBundle\Notification\Exception; -class NotificationHandlerNotFound extends \RuntimeException -{ -} +class NotificationHandlerNotFound extends \RuntimeException {} diff --git a/src/Bundle/ChillMainBundle/Notification/Mailer.php b/src/Bundle/ChillMainBundle/Notification/Mailer.php index d62d6bc75..2d50cb850 100644 --- a/src/Bundle/ChillMainBundle/Notification/Mailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Mailer.php @@ -34,9 +34,7 @@ class Mailer * * @param mixed[] $routeParameters */ - public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) - { - } + public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) {} /** * @return string diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php index 04116a434..aa6e700bc 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php @@ -17,9 +17,7 @@ use Doctrine\ORM\EntityManagerInterface; final readonly class NotificationHandlerManager { - public function __construct(private iterable $handlers, private EntityManagerInterface $em) - { - } + public function __construct(private iterable $handlers, private EntityManagerInterface $em) {} /** * @throw NotificationHandlerNotFound if handler is not found diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index 9b606d18d..5c5cb3dcf 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -23,9 +23,7 @@ class NotificationPresence { private array $cache = []; - public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository) - { - } + public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository) {} /** * @param list $more diff --git a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php index 8dd2935dd..a65758f5f 100644 --- a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php @@ -21,9 +21,7 @@ use Twig\Extension\RuntimeExtensionInterface; class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface { - public function __construct(private readonly FormFactoryInterface $formFactory, private readonly NotificationPresence $notificationPresence, private readonly UrlGeneratorInterface $urlGenerator) - { - } + public function __construct(private readonly FormFactoryInterface $formFactory, private readonly NotificationPresence $notificationPresence, private readonly UrlGeneratorInterface $urlGenerator) {} public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): string { diff --git a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php index b887accaa..4c9cb68fe 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php +++ b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php @@ -18,9 +18,7 @@ class PageGenerator implements \Iterator { protected int $current = 1; - public function __construct(protected Paginator $paginator) - { - } + public function __construct(protected Paginator $paginator) {} public function current(): Page { diff --git a/src/Bundle/ChillMainBundle/Pagination/Paginator.php b/src/Bundle/ChillMainBundle/Pagination/Paginator.php index 072437f09..34a405a20 100644 --- a/src/Bundle/ChillMainBundle/Pagination/Paginator.php +++ b/src/Bundle/ChillMainBundle/Pagination/Paginator.php @@ -57,8 +57,7 @@ class Paginator implements PaginatorInterface * the key in the GET parameter to indicate the number of item per page. */ protected string $itemPerPageKey - ) { - } + ) {} public function count(): int { diff --git a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php index f7829b332..6453db4ae 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php +++ b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php @@ -39,8 +39,7 @@ final readonly class PaginatorFactory implements PaginatorFactoryInterface * the request or inside the paginator. */ private int $itemPerPage = 20 - ) { - } + ) {} /** * create a paginator instance. diff --git a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php index 69da56eca..51d57c9e9 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php @@ -16,9 +16,7 @@ use Twig\TwigFilter; class Templating extends AbstractExtension { - public function __construct(protected PhonenumberHelper $phonenumberHelper) - { - } + public function __construct(protected PhonenumberHelper $phonenumberHelper) {} public function formatPhonenumber($phonenumber) { diff --git a/src/Bundle/ChillMainBundle/Redis/ChillRedis.php b/src/Bundle/ChillMainBundle/Redis/ChillRedis.php index 439bb3558..b9e454b46 100644 --- a/src/Bundle/ChillMainBundle/Redis/ChillRedis.php +++ b/src/Bundle/ChillMainBundle/Redis/ChillRedis.php @@ -16,6 +16,4 @@ use Redis; /** * Redis client configured by chill main. */ -class ChillRedis extends \Redis -{ -} +class ChillRedis extends \Redis {} diff --git a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php index 5b830ce27..f14424f6f 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php @@ -19,9 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; class UserACLAwareRepository implements UserACLAwareRepositoryInterface { - public function __construct(private readonly ParentRoleHelper $parentRoleHelper, private readonly EntityManagerInterface $em) - { - } + public function __construct(private readonly ParentRoleHelper $parentRoleHelper, private readonly EntityManagerInterface $em) {} public function findUsersByReachedACL(string $role, $center, $scope = null, bool $onlyEnabled = true): array { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/NewsItem.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/NewsItem.vue index bbad4315c..4c1593aa0 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/NewsItem.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/NewsItem.vue @@ -125,7 +125,7 @@ const preprocess = (markdown: string): string => { } const postprocess = (html: string): string => { - DOMPurify.addHook('afterSanitizeAttributes', (node) => { + DOMPurify.addHook('afterSanitizeAttributes', (node: any) => { if ('target' in node) { node.setAttribute('target', '_blank'); node.setAttribute('rel', 'noopener noreferrer'); @@ -140,7 +140,7 @@ const postprocess = (html: string): string => { const convertMarkdownToHtml = (markdown: string): string => { marked.use({'hooks': {postprocess, preprocess}}); - const rawHtml = marked(markdown); + const rawHtml = marked(markdown) as string; return rawHtml; }; diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig index 0bfa5d54b..a6f139fd7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig @@ -1,5 +1,5 @@ {% set formId = crudMainFormId|default('crud_main_form') %} - + {% block crud_content_header %}

{{ ('crud.'~crud_name~'.title_edit')|trans }}

{% endblock crud_content_header %} @@ -21,9 +21,9 @@