diff --git a/.gitignore b/.gitignore
index c497e28d7..aeec2c4b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,5 @@ docs/build/
.phpunit.result.cache
###< phpunit/phpunit ###
+/.php-cs-fixer.cache
+/.idea/
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 295eb3e0e..f76ec4b98 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,48 +1,87 @@
---
-image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
# Select what we should cache between builds
cache:
- paths:
- - tests/app/vendor/
- - .composer
-
-before_script:
- # add extensions to postgres
- - PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
- # Install and run Composer
- - mkdir -p $COMPOSER_HOME
- - curl -sS https://getcomposer.org/installer | php
- - php -d memory_limit=2G composer.phar install
- - php tests/app/bin/console doctrine:migrations:migrate -n
- - php -d memory_limit=2G tests/app/bin/console doctrine:fixtures:load -n
- - echo "before_script finished"
+ paths:
+ - tests/app/vendor/
+ - .cache
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
services:
- - name: postgis/postgis:12-3.1-alpine
- alias: db
- - name: redis
- alias: redis
+ - name: postgis/postgis:12-3.1-alpine
+ alias: db
+ - name: redis
+ alias: redis
# Set any variables we need
variables:
- # Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- # fetch the chill-app using git submodules
- GIT_SUBMODULE_STRATEGY: recursive
- REDIS_HOST: redis
- REDIS_PORT: 6379
- REDIS_URL: redis://redis:6379
- # change vendor dir to make the app install into tests/apps
- COMPOSER_VENDOR_DIR: tests/app/vendor
- # cache some composer data
- COMPOSER_HOME: .composer
+ GIT_DEPTH: 1
+ # Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
+ POSTGRES_USER: postgres
+ POSTGRES_PASSWORD: postgres
+ # fetch the chill-app using git submodules
+ GIT_SUBMODULE_STRATEGY: recursive
+ REDIS_HOST: redis
+ REDIS_PORT: 6379
+ REDIS_URL: redis://redis:6379
+ # change vendor dir to make the app install into tests/apps
+ COMPOSER_VENDOR_DIR: tests/app/vendor
+stages:
+ - Composer install
+ - Tests
-# Run our tests
-test:
- script:
- - php -d memory_limit=3G bin/phpunit --colors=never
+build:
+ stage: Composer install
+ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
+ before_script:
+ - curl -sS https://getcomposer.org/installer | php
+ - php -d memory_limit=2G composer.phar config -g cache-dir "$(pwd)/.cache"
+ script:
+ - php -d memory_limit=2G composer.phar install --optimize-autoloader --no-ansi --no-interaction --no-progress
+ cache:
+ paths:
+ - .cache/
+ artifacts:
+ expire_in: 30 min
+ paths:
+ - bin
+ - tests/app/vendor/
+
+code_style:
+ stage: Tests
+ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
+ script:
+ - bin/grumphp run --tasks=phpcsfixer
+ artifacts:
+ expire_in: 30 min
+ paths:
+ - bin
+ - tests/app/vendor/
+
+sa_tests:
+ stage: Tests
+ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
+ script:
+ - bin/grumphp run --tasks=phpstan
+ artifacts:
+ expire_in: 30 min
+ paths:
+ - bin
+ - tests/app/vendor/
+
+unit_tests:
+ stage: Tests
+ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
+ script:
+ - php tests/app/bin/console doctrine:migrations:migrate -n
+ - php -d memory_limit=2G tests/app/bin/console cache:clear --env=dev
+ - php -d memory_limit=3G tests/app/bin/console doctrine:fixtures:load -n
+ - php -d memory_limit=2G tests/app/bin/console cache:clear --env=test
+ - php -d memory_limit=3G bin/phpunit --colors=never
+ artifacts:
+ expire_in: 30 min
+ paths:
+ - bin
+ - tests/app/vendor/
diff --git a/.gitlab/merge_request_templates/Default merge request.md b/.gitlab/merge_request_templates/Default merge request.md
new file mode 100644
index 000000000..5d62f91eb
--- /dev/null
+++ b/.gitlab/merge_request_templates/Default merge request.md
@@ -0,0 +1,24 @@
+
+# Description of changes
+
+
+
+
+# Issues related
+
+
+
+* ...
+* ...
+
+# Tests
+
+
+
diff --git a/.php_cs.dist.php b/.php_cs.dist.php
new file mode 100644
index 000000000..4ad5af914
--- /dev/null
+++ b/.php_cs.dist.php
@@ -0,0 +1,79 @@
+getFinder()
+ ->ignoreDotFiles(false)
+ ->notPath('tests/app')
+ ->name(['.php_cs.dist.php']);
+
+$rules = $config->getRules();
+
+$riskyRules = [
+ 'ternary_to_elvis_operator' => false,
+ 'php_unit_mock_short_will_return' => false,
+ 'php_unit_set_up_tear_down_visibility' => false,
+ 'php_unit_construct' => false,
+ 'php_unit_dedicate_assert' => false,
+ 'php_unit_expectation' => false,
+ 'php_unit_mock' => false,
+ 'php_unit_namespaced' => false,
+ 'php_unit_no_expectation_annotation' => false,
+ 'php_unit_test_case_static_method_calls' => false,
+ 'php_unit_test_annotation' => false,
+ // 'final_internal_class' => false,
+ // 'strict_param' => false,
+ // 'declare_strict_types' => false,
+ // 'strict_comparison' => false,
+ // 'no_unreachable_default_argument_value' => false,
+ // 'ereg_to_preg' => false,
+ // 'ordered_interfaces' => false,
+ // 'error_suppression' => false,
+ // 'non_printable_character' => false,
+ // 'ordered_traits' => false,
+ // 'no_useless_sprintf' => false,
+ // 'dir_constant' => false,
+ // 'no_alias_functions' => false,
+ // 'implode_call' => false,
+ // 'combine_nested_dirname' => false,
+ // 'pow_to_exponentiation' => false,
+ // 'comment_to_phpdoc' => false,
+ // 'no_unset_on_property' => false,
+ // 'native_constant_invocation' => false,
+ // 'function_to_constant' => false,
+ // 'is_null' => false,
+ // 'native_function_invocation' => false,
+ // 'no_trailing_whitespace_in_string' => false,
+ // 'array_push' => false,
+ // 'fopen_flag_order' => false,
+ // 'fopen_flags' => false,
+ // 'logical_operators' => false,
+ // 'modernize_types_casting' => false,
+ // 'no_homoglyph_names' => false,
+ // 'no_unneeded_final_method' => false,
+ // 'random_api_migration' => false,
+ // 'static_lambda' => false,
+ // 'set_type_to_cast' => false,
+ // 'string_line_ending' => false,
+ // 'psr_autoloading' => false,
+];
+
+$rules = array_merge(
+ $rules,
+ $riskyRules
+);
+
+$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
+
+return $config->setRules($rules);
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34047e541..209bf858e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,11 +11,162 @@ and this project adheres to
## Unreleased
+* [main] change address format in case the country is France, in Address render box and address normalizer
+* [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76)
+* [activity] fix visibility for location
+* [origin] fix origin: use correctly the translatable strings
+ * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');`
+* [person] redirect bug fixed.
+* [action] add an unrelated issue within action creation.
+* [origin] fix origin: use correctly the translatable strings
+ * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');`
+* [main] change order of civilities in civility fixtures (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [person] set min attr in the minimum of children field (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [person] add marital status date in person view (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [person] show number of children + allow set number of children to null (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [person] show acceptSMS option (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [person] add death information in person render box in twig and vue render boxes (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
+* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262)
+
+## Test releases
+
+### test release 2021-12-06
+
+* [main] address: use search API end points for getting postal code and reference address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/316)
+* [main] address: in edit mode, select the encoded values in multiselect for address reference and city (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/316)
+* [person search] fix bug when using birthdate after and birthdate before
+* [person search] increase pertinence when lastname begins with search pattern
+* [activity/actions] Améliore la cohérence du design entre
+ * la page résumé d'un parcours (liste d'actions récentes et liste d'activités récentes)
+ * la page liste des actions
+ * la page liste des activités (contexte personne / contexte parcours)
+* [household] field to edit wheter person is titulaire of household or not removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/322)
+* [activity] create work if a work with same social action is not associated to the activity
+* [visgraph] improve and fix bugs on vis-network relationship graph
+* [bugfix] posting of birth- and deathdate through api fixed.
+* [suggestions] improve suggestions lists
+* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty
+* [AddPersons] suggestions row are clickable, not only checkbox
+* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl
+* [activity][calendar] concerned groups items are clickable with on-the-fly modal, create specific badge for TMS column
+
+### Test release 2021-11-19 - bis
+
+* [household] do not allow to create two addresses on the same date
+* [activity] handle case when there is no social action associated to social issue
+* [activity] layout for issues / actions
+* [activity][bugfix] in edit mode, the form will now load the social action list
+
+
+### Test release 2021-11-29
+
+* [person] suggest entities (person | thirdparty) when creating/editing the accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/119)
+* [activity] add custom validation on the Activity class, based on what is required from the ActivityType (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/188)
+* [main] translate multiselect messages when selecting/creating address
+* [main] set the coordinates of the city when creating a new address OR choosing "pas d'adresse complète"
+* Use the user.label in accompanying course banner, instead of username;
+* fix: show validation message when closing accompanying course;
+* [thirdparty] link from modal to thirdparty detail page fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/228)
+* [assets] new asset to style suggestions lists (with add/remove item link) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/258)
+* [accompanyingCourseWorkEdit] improves hyphenation and line breaks for long badges
+* [acompanyingCourse] improve Resume page
+ * complete all needed informations,
+ * actions and activities are clickables,
+ * better placement with js masonry blocks on top of content area,
+ * https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/101
+ * https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/295
+* [activity/calendar] on show page, concerned groups of persons table adapt itself to isVisibles options
+* [activity] remove the "plus" button in activity list
+* [activity] check ACL on activity list in person context
+* [list for accompanying course in person] filter list using ACL
+* [validation] toasts are displayed for errors when modifying accompanying course (generalization required).
+* [period] only the user can enable confidentiality
+* add an endpoint for checking permissions. See https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/232
+* [activity] for a new activity: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
+* [calendar] for a new rdv: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
## Test releases
+### Test release 2021-11-22
+
+* [activity] delete admin_user_show in twig template because this route is not defined and should be defined
+* [activity] suggest requestor, user and ressources for adding persons|user|3rdparty
+* [calendar] suggest persons, professionals and invites for adding persons|3rdparty|user
+* [activity] take into account the restrictions on person|thirdparties|users visibilities defined in ActivityType
+* [main] Add currentLocation to the User entity + add a page for selecting this location + add in the user menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/133)
+* [activity] add user current location as default location for a new activity (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/133)
+* [task] Select2 field in task form to allow search for a user (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/167)
+* remove "search by phone configuration option": search by phone is now executed by default
+* remplacer le classement par ordre alphabétique par un classement par ordre de pertinence, qui tient compte:
+ * de la présence d'une string avec le nom de la ville;
+ * de la similarité;
+ * du fait que la recherche commence par une partie du mot recherché
+* ajouter la recherche par numéro de téléphone directement dans la barre de recherche et dans le formulaire recherche avancée;
+* ajouter la recherche par date de naissance directement dans la barre de recherche;
+* ajouter la recherche par ville dans la recherche avancée
+* ajouter un lien vers le ménage dans les résultats de recherche
+* ajouter l'id du parcours dans les résultats de recherche
+* ajouter le demandeur dans les résultats de recherche
+* ajout d'un bouton "recherche avancée" sur la page d'accueil
+* [person] create an accompanying course: add client-side validation if no origin (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/210)
+* [person] fix bounds for computing current person address: the new address appears immediatly
+* [docgen] create a normalizer and serializer for normalization on doc format
+* [person normalization] the key center is now "centers" and is an array. Empty array if no center
+* [accompanyingCourse] Ability to close accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/296)
+* [task] Select2 field in task form to allow search for a user (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/167)
+* [list result] show all courses, except ones with period closed
+* [accompanyingCourse] improve banner with small carousel to display slide social-issues or slide associated persons (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/69)
+
+### Test release 2021-11-15
+
+* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection)
+* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51)
+* [person]: display other phone numbers in view + add message in case no others phone numbers (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/184)
+* unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290)
+* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36)
+* [address]: Display of incomplete address adjusted.
+* [household]: improve relationship graph
+ * add form to create/edit/delete relationship link,
+ * improve graph refresh mechanism
+ * add feature to export canvas as image (png)
+* [person suggest] In widget "add person", improve the pertinence of persons when one of the names starts with the pattern;
+* [person] do not ask for center any more on person creation
+* [3party] do not ask for center any more on 3party creation
+
+## Test releases
+
+### Test release 2021-11-08
+
+* [person]: Display the name of a user when searching after a User (TMS)
+* [person]: Add civility to the person
+* [person]: Various improvements on the edit person form
+* [person]: Set available_languages and available_countries as parameters for use in the edit person form
+* [activity] Bugfix: documents can now be added to an activity.
+* [tasks] improve tasks with filter order
+* [tasks] refactor singleControllerTasks: limit the number of conditions from the context
+* [validations] validation of accompanying period added: no duplicate participations or resources (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/60).
+* [renderbox] If gender of person is not defined, no icon is displayed instead of neuter-icon (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/129).
+* [confidential information] module added to blur confidential information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/248).
+* refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper`
+* [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers
+* [activity]: perform client-side validation & show/hide fields in the "new location" modal
+* [person]: normalize person with CenterResolverDispatcher and handle case where center is null or multiple in PersonRenderBox
+* [docstore] voter for PersonDocument and AccompanyingCourseDocument on the 2.0 way (using VoterHelperFactory)
+* [docstore] add authorization check inside controller and menu
+* [activity]: fix inheritance for role `ACTIVITY FULL` and add missing acl in menu
+* [person] show current address in search results
+* [person] show alt names in search results
+* [admin]: links to activity admin section added again.
+* [household]: endDate field deleted from household edit form.
+* [household]: View accompanying periods of current and old household members.
+* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
+* [admin]: links to activity admin section added again.
+* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top.
+* [socialWorkAction]: display of social issue and parent issues + banner context added.
+* [DBAL dependencies] Upgrade to DBAL 3.1
+
### Test release 2021-10-27
* [person]: delete double actions buttons on search person page
@@ -33,7 +184,10 @@ and this project adheres to
* [3party]: fix address creation
* [household members editor] finalisation of editor
* [AccompanyingCourse banner]: replace translation referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/70)
-* [Location]: add location system in activity and RV (calendar). User can choose in location list or create a new location.
+* [Location]: add location system in activity and RV (calendar). User can choose in location list or create a new location.
+* [household]: add relationship page with dynamic data visualisation graph
+
+## Test releases
### Test release 2021-10-11
@@ -49,7 +203,7 @@ and this project adheres to
* fast creation buttons
* add ordering for types
-* [AccompanyingCourse Resume page] badge-title for AccompanyingCourseWork and for Activities;
+* [AccompanyingCourse Resume page] dashboard for AccompanyingCourseWork and for Activities;
* Improve badges behaviour with small screens;
* [ThirdParty]:
@@ -100,7 +254,7 @@ and this project adheres to
## Test released
-scalarNode('key')->isRequired()->cannotBeEmpty()
- ->info('the key stored in database')
- ->example('student')
- ->end()
- ->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
- ->arrayPrototype()
- ->children()
- ->scalarNode('lang')->isRequired()->cannotBeEmpty()
- ->example('fr')
- ->end()
- ->scalarNode('label')->isRequired()->cannotBeEmpty()
- ->example('Étudiant')
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->arrayNode('familial_situations')->isRequired()
- ->info("the list of familial situations. If empty, the field will not be shown")
- ->arrayPrototype()
- ->children()
-->scalarNode('key')->isRequired()->cannotBeEmpty()
- ->info('the key stored in database')
- ->example('half_time_keeping')
- ->end()
- ->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
- ->arrayPrototype()
- ->children()
- ->scalarNode('lang')->isRequired()->cannotBeEmpty()
- ->example('fr')
- ->end()
- ->scalarNode('label')->isRequired()->cannotBeEmpty()
- ->example('En garde alternée')
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ;
+ ->arrayNode('links')->isRequired()->requiresAtLeastOneElement()
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('key')->isRequired()->cannotBeEmpty()
+ ->info('the key stored in database')
+ ->example('grandson')
+ ->end()
+ ->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('lang')->isRequired()->cannotBeEmpty()
+ ->example('fr')
+ ->end()
+ ->scalarNode('label')->isRequired()->cannotBeEmpty()
+ ->example('Petit-fils')
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->arrayNode('professionnal_situations')->isRequired()
+ ->info('the list of professional situations. If empty, the field will not be shown')
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('key')->isRequired()->cannotBeEmpty()
+ ->info('the key stored in database')
+ ->example('student')
+ ->end()
+ ->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('lang')->isRequired()->cannotBeEmpty()
+ ->example('fr')
+ ->end()
+ ->scalarNode('label')->isRequired()->cannotBeEmpty()
+ ->example('Étudiant')
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->arrayNode('familial_situations')->isRequired()
+ ->info('the list of familial situations. If empty, the field will not be shown')
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('key')->isRequired()->cannotBeEmpty()
+ ->info('the key stored in database')
+ ->example('half_time_keeping')
+ ->end()
+ ->arrayNode('labels')->isRequired()->requiresAtLeastOneElement()
+ ->arrayPrototype()
+ ->children()
+ ->scalarNode('lang')->isRequired()->cannotBeEmpty()
+ ->example('fr')
+ ->end()
+ ->scalarNode('label')->isRequired()->cannotBeEmpty()
+ ->example('En garde alternée')
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end();
return $treeBuilder;
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php b/src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php
index 36da186d0..ac8743af2 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php
@@ -1,53 +1,62 @@
+ * @ORM\MappedSuperclass
*/
abstract class AbstractFamilyMember implements HasCenterInterface
{
- const FAMILIAL_SITUATION = [
- 'a_charge'=> 'A charge',
- 'garde_alternee'=> 'Garde alternée',
- 'droit_de_visite'=> 'Droit de visite et d\'hébergement',
- 'non_a_charge' => 'Non à charge',
- ];
+ public const FAMILIAL_SITUATION = [
+ 'a_charge' => 'A charge',
+ 'garde_alternee' => 'Garde alternée',
+ 'droit_de_visite' => 'Droit de visite et d\'hébergement',
+ 'non_a_charge' => 'Non à charge',
+ ];
-/**
- *
- * @var Person
- * @ORM\ManyToOne(
- * targetEntity="\Chill\PersonBundle\Entity\Person"
- * )
- */
- private $person;
-
/**
+ * @var date_immutable|null
*
- * @var MaritalStatus
- * @ORM\ManyToOne(
- * targetEntity="\Chill\PersonBundle\Entity\MaritalStatus"
+ * @ORM\Column(name="birthdate", type="date_immutable", nullable=true)
+ * @Assert\Date
+ */
+ private $birthdate;
+
+ /**
+ * @var DateTimeImmutable|null
+ *
+ * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
+ * @Assert\Date
+ * @Assert\GreaterThan(
+ * propertyPath="startDate",
+ * message="The membership's end date should be after the start date"
* )
*/
- private $maritalStatus;
+ private $endDate;
/**
* @var string
- *
- * @ORM\Column(name="lastname", type="string", length=255)
+ * @ORM\Column(name="familial_situation", type="string", length=200, nullable=true)
*/
- private $lastname = '';
+ private $familialSituation;
/**
* @var string
@@ -64,12 +73,34 @@ abstract class AbstractFamilyMember implements HasCenterInterface
private $gender = '';
/**
- * @var date_immutable|null
+ * @var string
*
- * @ORM\Column(name="birthdate", type="date_immutable", nullable=true)
- * @Assert\Date()
+ * @ORM\Column(name="lastname", type="string", length=255)
*/
- private $birthdate;
+ private $lastname = '';
+
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="link", type="string", length=255)
+ */
+ private $link = '';
+
+ /**
+ * @var MaritalStatus
+ * @ORM\ManyToOne(
+ * targetEntity="\Chill\PersonBundle\Entity\MaritalStatus"
+ * )
+ */
+ private $maritalStatus;
+
+ /**
+ * @var Person
+ * @ORM\ManyToOne(
+ * targetEntity="\Chill\PersonBundle\Entity\Person"
+ * )
+ */
+ private $person;
/**
* @var string
@@ -79,57 +110,67 @@ abstract class AbstractFamilyMember implements HasCenterInterface
private $professionnalSituation = '';
/**
- * @var string
- *
- * @ORM\Column(name="link", type="string", length=255)
- */
- private $link = '';
-
- /**
- *
- * @var string
- * @ORM\Column(name="familial_situation", type="string", length=200, nullable=true)
- */
- private $familialSituation;
-
- /**
- * @var \DateTimeImmutable
+ * @var DateTimeImmutable
*
* @ORM\Column(name="startDate", type="datetime_immutable")
- * @Assert\NotNull()
- * @Assert\Date()
+ * @Assert\NotNull
+ * @Assert\Date
*/
private $startDate;
- /**
- * @var \DateTimeImmutable|null
- *
- * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
- * @Assert\Date()
- * @Assert\GreaterThan(
- * propertyPath="startDate",
- * message="The membership's end date should be after the start date"
- * )
- */
- private $endDate;
-
public function __construct()
{
- $this->setStartDate(new \DateTimeImmutable('now'));
+ $this->setStartDate(new DateTimeImmutable('now'));
}
-
- /**
- * Set lastname.
- *
- * @param string $lastname
- *
- * @return FamilyMember
- */
- public function setLastname($lastname)
- {
- $this->lastname = (string) $lastname;
- return $this;
+ /**
+ * Get birthdate.
+ *
+ * @return date_immutable|null
+ */
+ public function getBirthdate()
+ {
+ return $this->birthdate;
+ }
+
+ public function getCenter(): \Chill\MainBundle\Entity\Center
+ {
+ return $this->getPerson()->getCenter();
+ }
+
+ /**
+ * Get endDate.
+ *
+ * @return DateTimeImmutable|null
+ */
+ public function getEndDate()
+ {
+ return $this->endDate;
+ }
+
+ public function getFamilialSituation()
+ {
+ return $this->familialSituation;
+ }
+
+ /**
+ * Get firstname.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+ return $this->firstname;
+ }
+
+ /**
+ * Get gender.
+ *
+ * @return string
+ */
+ public function getGender()
+ {
+ return $this->gender;
}
/**
@@ -142,6 +183,91 @@ abstract class AbstractFamilyMember implements HasCenterInterface
return $this->lastname;
}
+ /**
+ * Get link.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+ return $this->link;
+ }
+
+ /**
+ * @return MaritalStatus
+ */
+ public function getMaritalStatus()
+ {
+ return $this->maritalStatus;
+ }
+
+ /**
+ * @return Person
+ */
+ public function getPerson()
+ {
+ return $this->person;
+ }
+
+ /**
+ * Get professionnalSituation.
+ *
+ * @return string
+ */
+ public function getProfessionnalSituation()
+ {
+ return $this->professionnalSituation;
+ }
+
+ /**
+ * Get startDate.
+ *
+ * @return DateTimeImmutable
+ */
+ public function getStartDate()
+ {
+ return $this->startDate;
+ }
+
+ /**
+ * Set birthdate.
+ *
+ * @return FamilyMember
+ */
+ public function setBirthdate(?DateTimeInterface $birthdate = null)
+ {
+ if ($birthdate instanceof DateTime) {
+ $this->birthdate = DateTimeImmutable::createFromMutable($birthdate);
+ } elseif (null === $birthdate || $birthdate instanceof DateTimeImmutable) {
+ $this->birthdate = $birthdate;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set endDate.
+ *
+ * @return FamilyMember
+ */
+ public function setEndDate(?DateTimeInterface $endDate = null)
+ {
+ if ($endDate instanceof DateTime) {
+ $this->endDate = DateTimeImmutable::createFromMutable($endDate);
+ } elseif ($endDate instanceof DateTimeImmutable || null === $endDate) {
+ $this->endDate = $endDate;
+ }
+
+ return $this;
+ }
+
+ public function setFamilialSituation($familialSituation)
+ {
+ $this->familialSituation = $familialSituation;
+
+ return $this;
+ }
+
/**
* Set firstname.
*
@@ -156,16 +282,6 @@ abstract class AbstractFamilyMember implements HasCenterInterface
return $this;
}
- /**
- * Get firstname.
- *
- * @return string
- */
- public function getFirstname()
- {
- return $this->firstname;
- }
-
/**
* Set gender.
*
@@ -181,67 +297,19 @@ abstract class AbstractFamilyMember implements HasCenterInterface
}
/**
- * Get gender.
+ * Set lastname.
*
- * @return string
- */
- public function getGender()
- {
- return $this->gender;
- }
-
- /**
- * Set birthdate.
- *
- * @param \DateTimeInterface|null $birthdate
+ * @param string $lastname
*
* @return FamilyMember
*/
- public function setBirthdate(\DateTimeInterface $birthdate = null)
+ public function setLastname($lastname)
{
- if ($birthdate instanceof \DateTime) {
- $this->birthdate = \DateTimeImmutable::createFromMutable($birthdate);
- } elseif ($birthdate === null || $birthdate instanceof \DateTimeImmutable) {
- $this->birthdate = $birthdate;
- }
+ $this->lastname = (string) $lastname;
return $this;
}
- /**
- * Get birthdate.
- *
- * @return date_immutable|null
- */
- public function getBirthdate()
- {
- return $this->birthdate;
- }
-
- /**
- * Set professionnalSituation.
- *
- * @param string $professionnalSituation
- *
- * @return FamilyMember
- */
- public function setProfessionnalSituation($professionnalSituation)
- {
- $this->professionnalSituation = (string) $professionnalSituation;
-
- return $this;
- }
-
- /**
- * Get professionnalSituation.
- *
- * @return string
- */
- public function getProfessionnalSituation()
- {
- return $this->professionnalSituation;
- }
-
/**
* Set link.
*
@@ -257,127 +325,56 @@ abstract class AbstractFamilyMember implements HasCenterInterface
}
/**
- * Get link.
+ * @param MaritalStatus $maritalStatus
*
- * @return string
+ * @return $this
*/
- public function getLink()
+ public function setMaritalStatus(?MaritalStatus $maritalStatus = null)
{
- return $this->link;
- }
-
- public function getFamilialSituation()
- {
- return $this->familialSituation;
- }
-
- public function setFamilialSituation($familialSituation)
- {
- $this->familialSituation = $familialSituation;
-
- return $this;
- }
-
- /**
- * Set startDate.
- *
- * @param \DateTimeImmutable $startDate
- *
- * @return FamilyMember
- */
- public function setStartDate(\DateTimeInterface $startDate)
- {
- if ($startDate instanceof \DateTime) {
- $this->startDate = \DateTimeImmutable::createFromMutable($startDate);
- } elseif (NULL === $startDate || $startDate instanceof \DateTimeImmutable) {
- $this->startDate = $startDate;
- }
+ $this->maritalStatus = $maritalStatus;
return $this;
}
/**
- * Get startDate.
- *
- * @return \DateTimeImmutable
- */
- public function getStartDate()
- {
- return $this->startDate;
- }
-
- /**
- * Set endDate.
- *
- * @param \DateTimeInterface|null $endDate
- *
- * @return FamilyMember
- */
- public function setEndDate(\DateTimeInterface $endDate = null)
- {
- if ($endDate instanceof \DateTime) {
- $this->endDate = \DateTimeImmutable::createFromMutable($endDate);
- } elseif ($endDate instanceof \DateTimeImmutable || $endDate === null) {
- $this->endDate = $endDate;
- }
-
- return $this;
- }
-
- /**
- * Get endDate.
- *
- * @return \DateTimeImmutable|null
- */
- public function getEndDate()
- {
- return $this->endDate;
- }
-
- /**
- *
- * @return Person
- */
- public function getPerson()
- {
- return $this->person;
- }
-
- /**
- *
- * @return MaritalStatus
- */
- public function getMaritalStatus()
- {
- return $this->maritalStatus;
- }
-
- /**
- *
- * @param Person $person
* @return $this
*/
public function setPerson(Person $person)
{
$this->person = $person;
-
+
return $this;
}
/**
- *
- * @param MaritalStatus $maritalStatus
- * @return $this
+ * Set professionnalSituation.
+ *
+ * @param string $professionnalSituation
+ *
+ * @return FamilyMember
*/
- public function setMaritalStatus(MaritalStatus $maritalStatus = null)
+ public function setProfessionnalSituation($professionnalSituation)
{
- $this->maritalStatus = $maritalStatus;
-
+ $this->professionnalSituation = (string) $professionnalSituation;
+
return $this;
}
- public function getCenter(): \Chill\MainBundle\Entity\Center
+ /**
+ * Set startDate.
+ *
+ * @param DateTimeImmutable $startDate
+ *
+ * @return FamilyMember
+ */
+ public function setStartDate(DateTimeInterface $startDate)
{
- return $this->getPerson()->getCenter();
+ if ($startDate instanceof DateTime) {
+ $this->startDate = DateTimeImmutable::createFromMutable($startDate);
+ } elseif (null === $startDate || $startDate instanceof DateTimeImmutable) {
+ $this->startDate = $startDate;
+ }
+
+ return $this;
}
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Entity/FamilyMember.php b/src/Bundle/ChillFamilyMembersBundle/Entity/FamilyMember.php
index ca2d4af92..9e679454b 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Entity/FamilyMember.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Entity/FamilyMember.php
@@ -1,11 +1,20 @@
configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
-
- /**
- * {@inheritdoc}
- */
public function buildForm(FormBuilderInterface $builder, array $options)
{
-
$builder
->add('lastname', TextType::class, [
- 'label' => 'Last name'
+ 'label' => 'Last name',
])
->add('firstname', TextType::class, [
- 'label' => 'First name'
+ 'label' => 'First name',
])
->add('gender', GenderType::class)
->add('birthdate', ChillDateType::class, [
- 'required' => false
+ 'required' => false,
])
->add('link', ChoiceType::class, [
'choices' => $this->buildChoices($this->configRepository->getLinksLabels()),
'placeholder' => 'Choose a link',
- 'label' => 'Relationship'
+ 'label' => 'Relationship',
])
->add('maritalStatus', Select2MaritalStatusType::class, [
- 'required' => false
- ])
- ;
-
+ 'required' => false,
+ ]);
+
if ($this->configRepository->hasProfessionalSituation()) {
$builder
- ->add('professionnalSituation', ChoiceType::class, [
- 'required' => false,
- 'choices' => $this->buildChoices(
- $this->configRepository->getProfessionalSituationsLabels()
- )
- ]);
+ ->add('professionnalSituation', ChoiceType::class, [
+ 'required' => false,
+ 'choices' => $this->buildChoices(
+ $this->configRepository->getProfessionalSituationsLabels()
+ ),
+ ]);
}
-
+
if ($this->configRepository->hasProfessionalSituation()) {
$builder
- ->add('familialSituation', ChoiceType::class, [
- 'required' => false,
- 'choices' => $this->buildChoices(
- $this->configRepository->getFamilialSituationsLabels()
- )
- ]);
+ ->add('familialSituation', ChoiceType::class, [
+ 'required' => false,
+ 'choices' => $this->buildChoices(
+ $this->configRepository->getFamilialSituationsLabels()
+ ),
+ ]);
}
-
+
if ($options['show_start_date']) {
$builder
->add('startDate', ChillDateType::class, [
- 'label' => 'Arrival date in the family'
+ 'label' => 'Arrival date in the family',
]);
}
-
+
if ($options['show_end_date']) {
$builder
->add('endDate', ChillDateType::class, [
'required' => false,
- 'label' => 'Departure date of the family'
+ 'label' => 'Departure date of the family',
]);
}
+ }
- }/**
- * {@inheritdoc}
- */
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => FamilyMember::class,
'show_start_date' => true,
'show_end_date' => true,
- ));
-
+ ]);
+
$resolver
->setAllowedTypes('show_start_date', 'boolean')
- ->setAllowedTypes('show_end_date', 'boolean')
- ;
- }
-
- private function buildChoices($els)
- {
- $links = $this->configRepository
- ->getLinksLabels();
- $choices = [];
-
- // rewrite labels to filter in language
- foreach ($els as $key => $labels) {
- $choices[$this->translatableStringHelper->localize($labels)] = $key;
- }
-
- return $choices;
+ ->setAllowedTypes('show_end_date', 'boolean');
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix()
{
return 'chill_amli_familymembersbundle_familymember';
}
+ private function buildChoices($els)
+ {
+ $links = $this->configRepository
+ ->getLinksLabels();
+ $choices = [];
+ // rewrite labels to filter in language
+ foreach ($els as $key => $labels) {
+ $choices[$this->translatableStringHelper->localize($labels)] = $key;
+ }
+
+ return $choices;
+ }
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMembersType.php b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMembersType.php
index b8561b633..9ea1f2fa9 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMembersType.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMembersType.php
@@ -1,18 +1,20 @@
+ * For the full copyright and license information, please view
+ * the LICENSE file that was distributed with this source code.
*/
+
+declare(strict_types=1);
+
+namespace Chill\AMLI\FamilyMembersBundle\Form;
+
+use Chill\MainBundle\Form\Type\ChillCollectionType;
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
class FamilyMembersType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
@@ -21,15 +23,15 @@ class FamilyMembersType extends AbstractType
'entry_type' => FamilyMemberType::class,
'entry_options' => [
'show_start_date' => true,
- 'show_end_date' => true
+ 'show_end_date' => true,
],
'allow_add' => true,
'allow_delete' => true,
'button_add_label' => 'Ajouter un membre',
- 'button_remove_label' => 'Enlever ce membre'
+ 'button_remove_label' => 'Enlever ce membre',
]);
}
-
+
public function getParent()
{
return ChillCollectionType::class;
diff --git a/src/Bundle/ChillFamilyMembersBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillFamilyMembersBundle/Menu/UserMenuBuilder.php
index fb226cf5f..17976b6ef 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Menu/UserMenuBuilder.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Menu/UserMenuBuilder.php
@@ -1,61 +1,61 @@
- */
class UserMenuBuilder implements LocalMenuBuilderInterface
{
/**
- *
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
-
+
/**
- *
* @var TranslatorInterface
*/
protected $translator;
-
+
public function __construct(
- AuthorizationCheckerInterface $authorizationChecker,
+ AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator
) {
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
}
-
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
- /* @var $person \Chill\PersonBundle\Entity\Person */
+ /** @var \Chill\PersonBundle\Entity\Person $person */
$person = $parameters['person'];
-
+
if ($this->authorizationChecker->isGranted(FamilyMemberVoter::SHOW, $person)) {
$menu->addChild(
- $this->translator->trans('Family memberships'), [
+ $this->translator->trans('Family memberships'),
+ [
'route' => 'chill_family_members_family_members_index',
- 'routeParameters' => [ 'id' => $person->getId() ],
- ])
- ->setExtra('order', 450)
- ;
+ 'routeParameters' => ['id' => $person->getId()],
+ ]
+ )
+ ->setExtra('order', 450);
}
}
public static function getMenuIds(): array
{
- return [ 'person' ];
+ return ['person'];
}
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
index 618128c96..571e94161 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
@@ -1,17 +1,39 @@
findBy([ 'person' => $person ]);
+ parent::__construct($registry, FamilyMember::class);
+ }
+
+ /**
+ * @return FamilyMember[]
+ */
+ public function findByPerson(Person $person): array
+ {
+ return $this->findBy(['person' => $person]);
}
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Resources/migrations/Version20180522142023.php b/src/Bundle/ChillFamilyMembersBundle/Resources/migrations/Version20180522142023.php
index 90ac49a32..47cf5df6a 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Resources/migrations/Version20180522142023.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Resources/migrations/Version20180522142023.php
@@ -1,4 +1,13 @@
-abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
+
+ $this->addSql('DROP SCHEMA chill_family CASCADE');
+ }
+
+ public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
@@ -25,12 +41,4 @@ final class Version20180522142023 extends AbstractMigration
$this->addSql('ALTER TABLE chill_family.family_member ADD CONSTRAINT FK_A61F4A49217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_family.family_member ADD CONSTRAINT FK_A61F4A49D7D03CE3 FOREIGN KEY (maritalStatus_id) REFERENCES chill_person_marital_status (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
-
- public function down(Schema $schema) : void
- {
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
-
- $this->addSql('DROP SCHEMA chill_family CASCADE');
-
- }
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php b/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
index 5e218657c..73c320720 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
@@ -1,79 +1,82 @@
+ * For the full copyright and license information, please view
+ * the LICENSE file that was distributed with this source code.
*/
+
+declare(strict_types=1);
+
+namespace Chill\AMLI\FamilyMembersBundle\Security\Voter;
+
+use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
+use Chill\MainBundle\Entity\User;
+use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
+use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
+use Chill\PersonBundle\Entity\Person;
+use Symfony\Component\Security\Core\Role\Role;
+use function in_array;
+
class FamilyMemberVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
- const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE';
- const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE';
- const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE';
- const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW';
-
- const ROLES = [
+ public const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE';
+
+ public const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE';
+
+ public const ROLES = [
self::CREATE,
self::DELETE,
self::SHOW,
- self::UPDATE
+ self::UPDATE,
];
-
+
+ public const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW';
+
+ public const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE';
+
/**
- *
* @var AuthorizationHelper
*/
protected $authorizationHelper;
-
+
public function __construct(AuthorizationHelper $authorizationHelper)
{
$this->authorizationHelper = $authorizationHelper;
}
-
- protected function supports($attribute, $subject)
- {
- return (\in_array($attribute, self::ROLES) && $subject instanceof FamilyMember)
- or
- ($subject instanceof Person && \in_array($attribute, [ self::SHOW, self::CREATE ]));
- }
-
- protected function voteOnAttribute($attribute, $subject, \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token)
- {
- $user = $token->getUser();
-
- if (FALSE === $user instanceof User) {
- return false;
- }
-
- return $this->authorizationHelper
- ->userHasAccess($user, $subject, new Role($attribute));
- }
-
- public function getRoles()
- {
- return self::ROLES;
- }
-
- public function getRolesWithHierarchy(): array
- {
- return [ 'Family Members' => self::ROLES ];
- }
-
- public function getRolesWithoutScope()
+ public function getRoles(): array
{
return self::ROLES;
}
+ public function getRolesWithHierarchy(): array
+ {
+ return ['Family Members' => self::ROLES];
+ }
+
+ public function getRolesWithoutScope(): array
+ {
+ return self::ROLES;
+ }
+
+ protected function supports($attribute, $subject)
+ {
+ return (in_array($attribute, self::ROLES, true) && $subject instanceof FamilyMember)
+ || ($subject instanceof Person && in_array($attribute, [self::SHOW, self::CREATE], true));
+ }
+
+ protected function voteOnAttribute($attribute, $subject, \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token)
+ {
+ $user = $token->getUser();
+
+ if (false === $user instanceof User) {
+ return false;
+ }
+
+ return $this->authorizationHelper
+ ->userHasAccess($user, $subject, new Role($attribute));
+ }
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php b/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php
index e02d7e024..c2c060b79 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php
@@ -1,102 +1,99 @@
- */
class Twig extends AbstractExtension
{
/**
- *
* @var ConfigRepository
*/
protected $configRepository;
-
+
/**
- *
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
-
+
public function __construct(
- ConfigRepository $configRepository,
+ ConfigRepository $configRepository,
TranslatableStringHelper $translatableStringHelper
) {
$this->configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
-
+ public function displayFamilialSituation($situation)
+ {
+ if (null === $situation) {
+ return null;
+ }
+
+ return $this->translatableStringHelper->localize(
+ $this->configRepository->getFamilialSituationsLabels()[$situation]
+ );
+ }
+
+ public function displayLink($link)
+ {
+ if (null === $link) {
+ return null;
+ }
+
+ return $this->translatableStringHelper->localize(
+ $this->configRepository->getLinksLabels()[$link]
+ );
+ }
+
+ public function displayProfessionalSituation($situation)
+ {
+ if (null === $situation) {
+ return null;
+ }
+
+ return $this->translatableStringHelper->localize(
+ $this->configRepository->getProfessionalSituationsLabels()[$situation]
+ );
+ }
+
public function getFilters()
{
return [
- new TwigFilter('chill_family_member_link_display', [ $this, 'displayLink' ], [ 'is_safe' => [ 'html' ]]),
- new TwigFilter('chill_family_member_professional_situation_display', [ $this, 'displayProfessionalSituation' ], [ 'is_safe' => [ 'html' ]]),
- new TwigFilter('chill_family_member_familial_situation_display', [ $this, 'displayFamilialSituation' ], [ 'is_safe' => [ 'html' ]]),
-
+ new TwigFilter('chill_family_member_link_display', [$this, 'displayLink'], ['is_safe' => ['html']]),
+ new TwigFilter('chill_family_member_professional_situation_display', [$this, 'displayProfessionalSituation'], ['is_safe' => ['html']]),
+ new TwigFilter('chill_family_member_familial_situation_display', [$this, 'displayFamilialSituation'], ['is_safe' => ['html']]),
];
}
-
+
public function getFunctions()
{
return [
- new TwigFunction('chill_family_members_has_professionnal_situation', [ $this, 'hasProfessionnalSituation' ]),
- new TwigFunction('chill_family_members_has_familial_situation', [ $this, 'hasFamilialSituation' ]),
-
+ new TwigFunction('chill_family_members_has_professionnal_situation', [$this, 'hasProfessionnalSituation']),
+ new TwigFunction('chill_family_members_has_familial_situation', [$this, 'hasFamilialSituation']),
];
}
-
- public function displayLink($link)
- {
- if (NULL === $link) {
- return null;
- }
-
- return $this->translatableStringHelper->localize(
- $this->configRepository->getLinksLabels()[$link]
- );
- }
-
- public function displayProfessionalSituation($situation)
- {
- if (NULL === $situation) {
- return null;
- }
-
- return $this->translatableStringHelper->localize(
- $this->configRepository->getProfessionalSituationsLabels()[$situation]
- );
- }
-
- public function hasProfessionnalSituation()
- {
- return $this->configRepository->hasProfessionalSituation();
- }
-
- public function displayFamilialSituation($situation)
- {
- if (NULL === $situation) {
- return null;
- }
-
- return $this->translatableStringHelper->localize(
- $this->configRepository->getFamilialSituationsLabels()[$situation]
- );
- }
-
+
public function hasFamilialSituation()
{
return $this->configRepository->hasFamilialSituation();
}
+
+ public function hasProfessionnalSituation()
+ {
+ return $this->configRepository->hasProfessionalSituation();
+ }
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Tests/Controller/FamilyMemberControllerTest.php b/src/Bundle/ChillFamilyMembersBundle/Tests/Controller/FamilyMemberControllerTest.php
index 01e8d52df..7a10a6158 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Tests/Controller/FamilyMemberControllerTest.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Tests/Controller/FamilyMemberControllerTest.php
@@ -1,30 +1,42 @@
request('GET', '/edit');
+ }
+
public function testIndex()
{
- $client = static::createClient();
+ $client = self::createClient();
$crawler = $client->request('GET', '/index');
}
public function testNew()
{
- $client = static::createClient();
+ $client = self::createClient();
$crawler = $client->request('GET', '/new');
}
-
- public function testEdit()
- {
- $client = static::createClient();
-
- $crawler = $client->request('GET', '/edit');
- }
-
}
diff --git a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php
index 11b3c34fd..86ed8a4fa 100644
--- a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php
+++ b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php
@@ -1,33 +1,21 @@
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see
{{ streetLine }}
{% endif %} {% if options['extended_infos'] %} {{ _self.extended(address, options) }} @@ -56,14 +54,21 @@ {% endif %} {% endmacro %} -{% macro inline(address, options) %} +{% macro inline(address, options, streetLine) %} {% if options['has_no_address'] == true and address.isNoAddress == true %} + {% if address.postCode is not empty %} ++ {{ address.postCode.code }} + {{ address.postCode.name }} +
+{{ address.postCode.country.name|localize_translatable_string }}
+ {% endif %} {{ 'address.consider homeless'|trans }} {% else %} {% endif %} {{ _self.validity(address, options) }} @@ -83,12 +88,16 @@ {% endmacro %} +{# + this enclose the rendering inside a "li", which ease the placement operation when the address + must be shown in such list +#} {%- if render == 'list' -%}* my_role_declaration: * # ... * tags: * - { name: chill.role } *- * - * @author Julien Fastré
Text.
-HTML; - - private const UNAUTHORIZED_MARKDOWN = <<Text.
+ HTML; + + private const SIMPLE_MARKDOWN = <<<'MD' + # test + + Text. + MD; + + private const UNAUTHORIZED_HTML = <<<'HTML' +<script>alert("ok");</script>
+ HTML; + + private const UNAUTHORIZED_MARKDOWN = <<<'MD' + + MD; + /** - * Test that the markdown input is transformed into html + * Test that the markdown input is transformed into html. */ public function testRendering() { $extension = new ChillMarkdownRenderExtension(); - - $this->assertEquals(self::SIMPLE_HTML, - $extension->renderMarkdownToHtml(self::SIMPLE_MARKDOWN)); + + $this->assertEquals( + self::SIMPLE_HTML, + $extension->renderMarkdownToHtml(self::SIMPLE_MARKDOWN) + ); } - + /** - * Test that the output of the markdown content is sanitized + * Test that the output of the markdown content is sanitized. */ public function testSecurity() { $extension = new ChillMarkdownRenderExtension(); - - $this->assertEquals(self::UNAUTHORIZED_HTML, - $extension->renderMarkdownToHtml(self::UNAUTHORIZED_MARKDOWN)); + + $this->assertEquals( + self::UNAUTHORIZED_HTML, + $extension->renderMarkdownToHtml(self::UNAUTHORIZED_MARKDOWN) + ); } } diff --git a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php index 79551d23c..c866224e3 100644 --- a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php @@ -1,22 +1,53 @@ setName(['fr' => 'Pays']) + ->setCountryCode('BE'); + $postCode = new PostalCode(); + $postCode->setName('Locality') + ->setCode('012345') + ->setCountry($country); + + $addr->setStreet('Rue ABC') + ->setStreetNumber('5') + ->setPostcode($postCode); + + yield [$addr, 'Rue ABC, 5 - 012345 Locality']; + } + /** * @dataProvider addressDataProvider */ @@ -26,30 +57,8 @@ class AddressRenderTest extends KernelTestCase $renderer = new AddressRender($engine); $this->assertEquals($expectedString, $renderer->renderString($addr, [])); + return; $this->assertIsString($renderer->renderBox($addr, [])); - } - - - public function addressDataProvider(): \Iterator - { - $addr = new Address(); - $country = (new Country()) - ->setName([ "fr" => "Pays" ]) - ->setCountryCode("BE") - ; - $postCode = new PostalCode(); - $postCode->setName("Locality") - ->setCode("012345") - ->setCountry($country) - ; - - $addr->setStreet("Rue ABC") - ->setStreetNumber("5") - ->setPostcode($postCode) - ; - - yield[ $addr, "Rue ABC, 5 - 012345 Locality"]; } - } diff --git a/src/Bundle/ChillMainBundle/Tests/TestHelper.php b/src/Bundle/ChillMainBundle/Tests/TestHelper.php index a969eeeb3..205474685 100644 --- a/src/Bundle/ChillMainBundle/Tests/TestHelper.php +++ b/src/Bundle/ChillMainBundle/Tests/TestHelper.php @@ -1,47 +1,38 @@ * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see{{ $t('available_goals_text') }}
-{{ $t('available_evaluations_text') }}
-{{ $t('fix_these_errors') }}
Aucun résultat associé
-