From 1b0c19a68f544a0c74bb58f667cdaa320774e872 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 18 Oct 2021 15:47:57 +0200
Subject: [PATCH 001/227] prepare vue_visgraph component, with store, dataset
and display basic graph
---
.../Controller/HouseholdController.php | 17 +++-
.../Resources/public/page/vis/index.js | 32 --------
.../Resources/public/page/vis/scss/vis.scss | 5 --
.../Resources/public/vuejs/VisGraph/App.vue | 51 ++++++++++++
.../Resources/public/vuejs/VisGraph/api.js | 79 +++++++++++++++++++
.../Resources/public/vuejs/VisGraph/i18n.js | 15 ++++
.../Resources/public/vuejs/VisGraph/index.js | 27 +++++++
.../Resources/public/vuejs/VisGraph/store.js | 47 +++++++++++
.../views/Household/relationship.html.twig | 30 ++++---
.../ChillPersonBundle/chill.webpack.config.js | 2 +-
.../translations/messages+intl-icu.fr.yaml | 4 +-
11 files changed, 250 insertions(+), 59 deletions(-)
delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
index 1b9824184..bd3bf7889 100644
--- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
@@ -9,6 +9,8 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
+use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Chill\PersonBundle\Entity\Household\Household;
@@ -24,11 +26,16 @@ class HouseholdController extends AbstractController
private PositionRepository $positionRepository;
- public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
+ private SerializerInterface $serializer;
- {
+ public function __construct(
+ TranslatorInterface $translator,
+ PositionRepository $positionRepository,
+ SerializerInterface $serializer
+ ) {
$this->translator = $translator;
$this->positionRepository = $positionRepository;
+ $this->serializer = $serializer;
}
/**
@@ -177,9 +184,13 @@ class HouseholdController extends AbstractController
*/
public function showRelationship(Request $request, Household $household)
{
+ $jsonString = $this->serializer->serialize($household->getCurrentPersons(),
+ 'json', [ AbstractNormalizer::GROUPS => ['read']]);
+
return $this->render('@ChillPerson/Household/relationship.html.twig',
[
- 'household' => $household
+ 'household' => $household,
+ 'persons' => $jsonString
]
);
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js b/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
deleted file mode 100644
index f11e930c0..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import vis from 'vis-network/dist/vis-network.min';
-
-require('./scss/vis.scss');
-
-// create an array with nodes
-let nodes = new vis.DataSet([
- { id: 1, label: "Node 1" },
- { id: 2, label: "Node 2" },
- { id: 3, label: "Node 3" },
- { id: 4, label: "Node 4" },
- { id: 5, label: "Node 5", cid: 1 },
-]);
-
-// create an array with edges
-let edges = new vis.DataSet([
- { from: 1, to: 3 },
- { from: 1, to: 2 },
- { from: 2, to: 4 },
- { from: 2, to: 5 },
- { from: 3, to: 3 },
-]);
-
-// create a network
-let container = document.getElementById("graph-relationship");
-let data = {
- nodes: nodes,
- edges: edges,
-};
-let options = {};
-
-//
-let network = new vis.Network(container, data, options);
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss b/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
deleted file mode 100644
index 3d29c47ce..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-div#graph-relationship {
- margin: 2em auto;
- height: 500px;
- border: 1px solid lightgray;
-}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
new file mode 100644
index 000000000..bbaebf670
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
new file mode 100644
index 000000000..009d1309d
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -0,0 +1,79 @@
+/**
+ * @var makeFetch
+ */
+const makeFetch = (method, url, body) => {
+
+ return fetch(url, {
+ method: method,
+ headers: {
+ 'Content-Type': 'application/json;charset=utf-8'
+ },
+ body: JSON.stringify(body)
+ })
+ .then(response => {
+
+ if (response.ok) {
+ return response.json();
+ }
+
+ if (response.status === 422) {
+ return response.json();
+ }
+
+ throw {
+ msg: 'Error while updating AccompanyingPeriod Course.',
+ sta: response.status,
+ txt: response.statusText,
+ err: new Error(),
+ body: response.body
+ };
+ });
+}
+
+/**
+ * @var getHousehold
+*/
+const getHousehold = (person) => {
+ console.log('getHousehold', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/person/household/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+/**
+ * @var getCourse
+*/
+const getCourse = (person) => {
+ console.log('getCourse', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/person/accompanying-course/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+/**
+ * @var getRelationship
+*/
+const getRelationship = (person) => {
+ console.log('getRelationship', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/relations/relationship/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+export {
+ getHousehold,
+ getCourse,
+ getRelationship
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
new file mode 100644
index 000000000..950f5533c
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -0,0 +1,15 @@
+//import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
+
+const visMessages = {
+ fr: {
+ visgraph: {
+
+ }
+ }
+}
+
+//Object.assign(visMessages.fr, personMessages.fr);
+
+export {
+ visMessages
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
new file mode 100644
index 000000000..e70e3bb18
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -0,0 +1,27 @@
+import { createApp } from "vue"
+import { store } from "./store.js"
+import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
+import { visMessages } from './i18n'
+import App from './App.vue'
+
+const i18n = _createI18n(visMessages)
+
+const container = document.getElementById('relationship-graph')
+
+const persons = JSON.parse(container.dataset.persons)
+
+persons.forEach(person => {
+ store.dispatch('addPerson', person)
+ store.dispatch('fetchInfoForPerson', person)
+})
+
+const app = createApp({
+ template: ` `
+})
+.use(store)
+.use(i18n)
+.component('app', App)
+.mount('#relationship-graph')
+
+
+//console.log('container dataset', container.dataset.persons)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
new file mode 100644
index 000000000..ecb79c16e
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -0,0 +1,47 @@
+import { createStore } from 'vuex'
+import { getHousehold, getCourse, getRelationship } from './api'
+
+const debug = process.env.NODE_ENV !== 'production'
+
+const store = createStore({
+ strict: debug,
+ state: {
+ persons: [],
+ households: [],
+ courses: [],
+ relationships: [],
+ },
+ getters: {
+ getNodes() {
+ let nodes = [];
+ state.households.forEach(h => {
+ nodes.push(h)
+ });
+ return nodes
+ },
+ getEdges() {
+ }
+ },
+ mutations: {
+ addPerson(state, person) {
+ person.label = person.text // vis need label
+ state.persons.push(person)
+ }
+ },
+ actions: {
+ addPerson({ commit }, person) {
+ //console.log('addPerson', person)
+ commit('addPerson', person)
+ },
+ fetchInfoForPerson({ commit }, person) {
+ console.log('fetchInfoForPerson', person)
+
+ getHousehold(person)
+ getCourse(person)
+ getRelationship(person)
+
+ },
+ }
+});
+
+export { store }
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
index 5d5fc77af..db143e39f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
@@ -4,24 +4,22 @@
{% block content %}
{{ block('title') }}
-
- {% for m in household.members %}
- {% if m.endDate is null %}
- {{ dump(m) }}
- {% endif %}
- {% endfor %}
+
+
+ {#
+ {{ dump() }}
+ #}
{% endblock %}
-{% block js %}
- {{ parent() }}
- {{ encore_entry_script_tags('page_vis') }}
-{% endblock %}
-
-{% block css %}
- {{ parent() }}
- {{ encore_entry_link_tags('page_vis') }}
-{% endblock %}
-
{% block block_post_menu %}{% endblock %}
+
+{% block js %}
+ {{ encore_entry_script_tags('vue_visgraph') }}
+{% endblock %}
+
+{% block css %}
+ {{ encore_entry_link_tags('vue_visgraph') }}
+{% endblock %}
diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js
index 925a5ccf8..e033fc89d 100644
--- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js
+++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js
@@ -12,9 +12,9 @@ module.exports = function(encore, entries)
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
encore.addEntry('vue_accourse_work_create', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js');
encore.addEntry('vue_accourse_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js');
+ encore.addEntry('vue_visgraph', __dirname + '/Resources/public/vuejs/VisGraph/index.js');
encore.addEntry('page_household_edit_metadata', __dirname + '/Resources/public/page/household_edit_metadata/index.js');
encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js');
encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');
- encore.addEntry('page_vis', __dirname + '/Resources/public/page/vis/index.js');
};
diff --git a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
index c92dc6a31..ba7133b2a 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
+++ b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
@@ -51,8 +51,8 @@ household:
Household summary: Résumé du ménage
Accompanying period: Parcours d'accompagnement
Addresses: Historique adresse
- Relationship: Composition familiale
- Household relationships: Composition du ménage
+ Relationship: Filiation
+ Household relationships: Filiations dans le ménage
Current address: Adresse actuelle
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
Edit household members: Modifier l'appartenance au ménage
From 902c45f0cd012a63768dfa375c95fc8febad1e89 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 20 Oct 2021 13:11:58 +0200
Subject: [PATCH 002/227] endpoint created for acc periods by-person
---
.../AccompanyingCourseApiController.php | 25 ++++++++++++++++++-
.../ChillPersonExtension.php | 8 ++++++
.../ChillPersonBundle/chill.api.specs.yaml | 23 +++++++++++++++++
.../config/services/controller.yaml | 10 +++++---
4 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 8201752af..e7243fba1 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -18,7 +18,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Entity\Scope;
+use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
+use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Workflow\Registry;
+use Symfony\Component\Routing\Annotation\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingCourseApiController extends ApiController
{
@@ -28,14 +32,18 @@ class AccompanyingCourseApiController extends ApiController
private Registry $registry;
+ private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
+
public function __construct(
EventDispatcherInterface $eventDispatcher,
ValidatorInterface $validator,
- Registry $registry
+ Registry $registry,
+ AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository
) {
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
$this->registry = $registry;
+ $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
}
public function confirmApi($id, Request $request, $_format): Response
@@ -187,4 +195,19 @@ $workflow = $this->registry->get($accompanyingPeriod);
return null;
}
+
+ /**
+ * @Route("/api/1.0/person/accompanying-course/by-person/{person_id}.{_format}",
+ * name="chill_person_accompanyingperiod_by_person",
+ * requirements={
+ * "_format"="json"
+ * })
+ *
+ * @ParamConverter("person", options={"id" = "person_id"})
+ */
+ public function getAccompanyingPeriodsByPerson(Person $person){
+ $accompanyingPeriods = $person->getAccompanyingPeriods();
+ return $this->json(\array_values($accompanyingPeriods), Response::HTTP_OK, [], ['groups' => [ 'read']]);
+ }
+
}
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
index bc3b798fa..1dd1a7979 100644
--- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
+++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
@@ -585,6 +585,14 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
]
],
+ 'findAccompanyingPeriodsByPerson' => [
+ 'path' => '/by-person/{person_id}.{_format}',
+ 'controller_action' => 'findAccompanyingPeriodsByPerson',
+ 'methods' => [
+ Request::METHOD_GET => true,
+ Request::METHOD_HEAD => true,
+ ]
+ ]
]
],
[
diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
index 4041c52b7..5d3f07259 100644
--- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
+++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
@@ -1058,6 +1058,29 @@ paths:
description: "OK"
400:
description: "transition cannot be applyed"
+
+ /1.0/person/accompanying-course/by-person/{person_id}.json:
+ get:
+ tags:
+ - accompanying period
+ summary: get a list of accompanying periods for a person
+ description: Returns a list of the current accompanying periods for a person
+ parameters:
+ - name: person_id
+ in: path
+ required: true
+ description: The person id
+ schema:
+ type: integer
+ format: integer
+ minimum: 1
+ responses:
+ 401:
+ description: "Unauthorized"
+ 404:
+ description: "Not found"
+ 200:
+ description: "OK"
/1.0/person/accompanying-period/origin.json:
get:
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index 489168425..c61362583 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -41,10 +41,12 @@ services:
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
- arguments:
- $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $registry: '@Symfony\Component\Workflow\Registry'
+ autowire: true
+ autoconfigure: true
+ # arguments:
+ # $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
+ # $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
+ # $registry: '@Symfony\Component\Workflow\Registry'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonApiController:
From 8d947ea81b8489b2a7d6b38aa2df8f651f73bb1d Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 20 Oct 2021 13:37:27 +0200
Subject: [PATCH 003/227] viewing permission checked for returned accompanying
periods by-person
---
.../Controller/AccompanyingCourseApiController.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index e7243fba1..891a0f461 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -207,7 +207,11 @@ $workflow = $this->registry->get($accompanyingPeriod);
*/
public function getAccompanyingPeriodsByPerson(Person $person){
$accompanyingPeriods = $person->getAccompanyingPeriods();
- return $this->json(\array_values($accompanyingPeriods), Response::HTTP_OK, [], ['groups' => [ 'read']]);
+ $accompanyingPeriodsChecked = array_filter($accompanyingPeriods,
+ function(AccompanyingPeriod $period){
+ return $this->isGranted(AccompanyingPeriodVoter::SEE, $period);
+ });
+ return $this->json(\array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
}
From d7cf45885e7fcff61f9f88852f85af2108cee7bf Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 20 Oct 2021 10:15:33 +0200
Subject: [PATCH 004/227] vue_visgraph: vuex get household and update nodes
array
---
.../Resources/public/vuejs/VisGraph/App.vue | 58 +++++----
.../Resources/public/vuejs/VisGraph/api.js | 120 ++++++++++++------
.../Resources/public/vuejs/VisGraph/index.js | 5 +-
.../Resources/public/vuejs/VisGraph/store.js | 65 ++++++++--
4 files changed, 171 insertions(+), 77 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index bbaebf670..f78b9fb62 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -4,40 +4,52 @@
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 009d1309d..50aafc04b 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -1,14 +1,17 @@
/**
- * @var makeFetch
+ * @function makeFetch
+ * @param method
+ * @param url
+ * @param body
+ * @returns {Promise}
*/
const makeFetch = (method, url, body) => {
-
return fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
- body: JSON.stringify(body)
+ body: (body !== null) ? JSON.stringify(body) : null
})
.then(response => {
@@ -31,49 +34,92 @@ const makeFetch = (method, url, body) => {
}
/**
- * @var getHousehold
-*/
-const getHousehold = (person) => {
- console.log('getHousehold', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/person/household/by-person/${person.id}.json`,
- {
- type: 'person',
- id: person.id
- })
+ * @function getFetch
+ * @param url
+ * @returns {Promise}
+ */
+const getFetch = (url) => {
+ return makeFetch('GET', url, null);
}
/**
- * @var getCourse
-*/
-const getCourse = (person) => {
- console.log('getCourse', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/person/accompanying-course/by-person/${person.id}.json`,
- {
- type: 'person',
- id: person.id
- })
+ * @function postFetch
+ * @param url
+ * @param body
+ * @returns {Promise}
+ */
+const postFetch = (url, body) => {
+ return makeFetch('POST', url, body);
}
/**
- * @var getRelationship
-*/
+ * @function patchFetch
+ * @param url
+ * @param body
+ * @returns {Promise}
+ */
+const patchFetch = (url, body) => {
+ return makeFetch('PATCH', url, body);
+}
+
+
+/**
+ * @function getHouseholdByPerson
+ * @param person
+ * @returns {Promise}
+ */
+const getHouseholdByPerson = (person) => {
+ //console.log('getHouseholdByPerson', person.id)
+ if (person.current_household_id === null) {
+ throw 'Currently the person has not household!'
+ }
+ return getFetch(
+ `/api/1.0/person/household/${person.current_household_id}.json`)
+}
+
+/**
+ * @function getCourseByPerson
+ * @param person
+ * @returns {Promise}
+ */
+const getCourseByPerson = (person) => {
+ //console.log('getCourseByPerson', person.id)
+ return getFetch(
+ `/api/1.0/person/accompanying-course/by-person/${person.id}.json`)
+}
+
+/**
+ * @function getRelationship
+ * @param person
+ * @returns {Promise}
+ */
const getRelationship = (person) => {
- console.log('getRelationship', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/relations/relationship/by-person/${person.id}.json`,
+ //console.log('getRelationship', person.id)
+ return getFetch(
+ `/api/1.0/relations/relationship/by-person/${person.id}.json`)
+}
+
+/**
+ * @function postRelationship
+ * @param person
+ * @returns {Promise}
+ */
+const postRelationship = (person) => {
+ //console.log('postRelationship', person.id)
+ return postFetch(
+ `/api/1.0/relations/relationship.json`,
{
- type: 'person',
- id: person.id
- })
+ from: { type: 'person', id: 0 },
+ to: { type: 'person', id: 0 },
+ relation: { type: 'relation', id: 0 },
+ reverse: bool
+ }
+ )
}
export {
- getHousehold,
- getCourse,
- getRelationship
+ getHouseholdByPerson,
+ getCourseByPerson,
+ getRelationship,
+ postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
index e70e3bb18..0aeb032d5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -12,7 +12,7 @@ const persons = JSON.parse(container.dataset.persons)
persons.forEach(person => {
store.dispatch('addPerson', person)
- store.dispatch('fetchInfoForPerson', person)
+ //store.dispatch('fetchInfoForPerson', person)
})
const app = createApp({
@@ -22,6 +22,3 @@ const app = createApp({
.use(i18n)
.component('app', App)
.mount('#relationship-graph')
-
-
-//console.log('container dataset', container.dataset.persons)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index ecb79c16e..d286bf75f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,5 +1,5 @@
import { createStore } from 'vuex'
-import { getHousehold, getCourse, getRelationship } from './api'
+import { getHouseholdByPerson, getCourseByPerson, getRelationship } from './api'
const debug = process.env.NODE_ENV !== 'production'
@@ -10,36 +10,75 @@ const store = createStore({
households: [],
courses: [],
relationships: [],
+ householdLoadingIds: [],
},
getters: {
- getNodes() {
+ nodes(state) {
let nodes = [];
+ state.persons.forEach(p => {
+ nodes.push(p)
+ })
state.households.forEach(h => {
nodes.push(h)
- });
+ })
+ // push all others kinds of nodes..
return nodes
},
- getEdges() {
- }
+ edges(state) {
+ return []
+ },
+ isHouseholdLoading: (state) => (household_id) => {
+ return state.householdLoadingIds.includes(household_id);
+ },
},
mutations: {
addPerson(state, person) {
person.label = person.text // vis need label
state.persons.push(person)
+ },
+ addHousehold(state, household) {
+ household.label = `Ménage n° ${household.id}` // vis need label
+ state.households.push(household)
+ },
+ markHouseholdLoading(state, id) {
+ console.log('mutation: markHouseholdLoading', id)
+ state.householdLoadingIds.push(id)
+ },
+ unmarkHouseholdLoading(state, id) {
+ state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
}
},
actions: {
- addPerson({ commit }, person) {
- //console.log('addPerson', person)
+ addPerson({ commit, dispatch }, person) {
+ console.log('addPerson', person.id)
commit('addPerson', person)
+ dispatch('fetchInfoForPerson', person)
+ },
+ fetchInfoForPerson({ dispatch }, person) {
+ //console.log('fetchInfoForPerson', person.id)
+ dispatch('fetchHouseholdForPerson', person)
+ //getCourseByPerson(person)
+ //getRelationship(person)
},
- fetchInfoForPerson({ commit }, person) {
- console.log('fetchInfoForPerson', person)
-
- getHousehold(person)
- getCourse(person)
- getRelationship(person)
+ /**
+ * Fetch person current household if it is not already loading
+ * check first isHouseholdLoading to fetch household once
+ */
+ fetchHouseholdForPerson({ commit, getters }, person) {
+ console.log('isHouseholdLoading', getters.isHouseholdLoading(person.current_household_id))
+ if (! getters.isHouseholdLoading(person.current_household_id)) {
+ commit('markHouseholdLoading', person.current_household_id)
+ getHouseholdByPerson(person)
+ .then(household => new Promise(resolve => {
+ console.log('getHouseholdByPerson', household)
+ commit('addHousehold', household)
+ resolve()
+ })
+ ).catch( () => {
+ commit('unmarkHouseholdLoading', person.current_household_id)
+ });
+ }
},
}
});
From 6ff80be88d958cb49f84046284ec01327a554adc Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 22 Oct 2021 10:11:33 +0200
Subject: [PATCH 005/227] vue_visgraph: add vis manipulation actions and vis
styles
---
.../Resources/public/vuejs/VisGraph/App.vue | 82 +++++++++++++------
.../Resources/public/vuejs/VisGraph/store.js | 2 +
2 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index f78b9fb62..0518a93d2 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -1,59 +1,87 @@
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 77a01af4a..f7af08240 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -6,7 +6,8 @@ const visMessages = {
'Course': 'Parcours',
'Household': 'Ménage',
}
- }
+ },
+ en: {}
}
//Object.assign(visMessages.fr, personMessages.fr);
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 288bc1f94..a06e6e55c 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -74,10 +74,19 @@ const store = createStore({
},
},
actions: {
+ /**
+ * 1) Add a person in state
+ * @param Person person
+ */
addPerson({ commit, dispatch }, person) {
commit('addPerson', person)
dispatch('fetchInfoForPerson', person)
},
+
+ /**
+ * 2) Fetch infos for this person (hub)
+ * @param Person person
+ */
fetchInfoForPerson({ dispatch }, person) {
dispatch('fetchHouseholdForPerson', person)
dispatch('fetchCoursesByPerson', person)
@@ -85,8 +94,9 @@ const store = createStore({
},
/**
- * Fetch person current household if it is not already loading
+ * 3) Fetch person current household (if it is not already loading)
* check first isHouseholdLoading to fetch household once
+ * @param Person person
*/
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
@@ -104,6 +114,11 @@ const store = createStore({
})
}
},
+
+ /**
+ * 4) Add an edge for each household member (household -> person)
+ * @param Household household
+ */
addLinkFromPersonsToHousehold({ commit }, household) {
const members = household.members.filter(v => household.current_members_id.includes(v.id))
members.forEach(m => {
@@ -111,14 +126,20 @@ const store = createStore({
commit('addRelationship', {
from: `${m.person.type}_${m.person.id}`,
to: `household_${m.person.current_household_id}`,
- id: `p${m.person.id}-h${m.person.current_household_id}`
+ id: `p${m.person.id}-h${m.person.current_household_id}`,
+ arrows: 'from',
+ color: 'pink',
+ font: { color: 'pink' },
+ label: 'enfant',
+ ////group: 'link_person_household',
})
})
},
/**
- * Fetch person current AccompanyingCourses
+ * 5) Fetch AccompanyingCourses for the person
+ * @param Person person
*/
fetchCoursesByPerson({ dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
@@ -130,6 +151,11 @@ const store = createStore({
}))
},
+
+ /**
+ * 6) Add each distinct course
+ * @param array courses
+ */
addCourse({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
let currentCourses = courses.filter(c => c.closingDate === null)
@@ -143,6 +169,11 @@ const store = createStore({
}
})
},
+
+ /**
+ * 7) Add an edge for each course participation (course <- person)
+ * @param AccompanyingCourse course
+ */
addLinkFromPersonsToCourse({ commit }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
@@ -150,7 +181,12 @@ const store = createStore({
commit('addRelationship', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
- id: `p${p.person.id}-c`+ course.id.split('_')[2]
+ id: `p${p.person.id}-c`+ course.id.split('_')[2],
+ arrows: 'to',
+ color: 'orange',
+ font: { color: 'orange' },
+ label: 'usager',
+ //group: 'link_person_course',
})
})
},
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f90b8a917..cc0ef717a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -8,6 +8,8 @@ import { visMessages } from './i18n'
*/
window.options = {
+ locale: 'fr',
+ locales: visMessages,
manipulation: {
enabled: true,
initiallyActive: true,
@@ -20,6 +22,10 @@ window.options = {
console.log('editNode', nodeData)
callback(nodeData);
},
+ deleteNode: function(nodeData, callback) {
+ console.log('deleteNode', nodeData)
+ callback(nodeData);
+ },
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData);
@@ -28,12 +34,78 @@ window.options = {
console.log('editNode', edgeData)
callback(edgeData);
},
+ deleteEdge: function(edgeData, callback) {
+ console.log('deleteNode', edgeData)
+ callback(edgeData);
+ },
+ controlNodeStyle: { /*
+ shape:'dot',
+ size: 6,
+ color: {
+ background: '#ff0000',
+ border: '#3c3c3c',
+ highlight: {
+ background: '#07f968',
+ border: '#3c3c3c'
+ }
+ },
+ borderWidth: 2,
+ borderWidthSelected: 2
+ */
+ }
},
nodes: {
- physics: true
+ physics: true,
+ borderWidth: 1,
+ borderWidthSelected: 3,
},
edges: {
- physics: true
+ physics: true,
+ font: {
+ color: '#b0b0b0',
+ size: 9,
+ face: 'arial',
+ background: 'none',
+ strokeWidth: 2, // px
+ strokeColor: '#ffffff',
+ align: 'horizontal',
+ multi: false,
+ vadjust: 0,
+ },
+ scaling:{
+ label: true,
+ },
+ smooth: true,
+ },
+ groups: {
+ person: {
+ shape: 'box',
+ shapeProperties: {
+ borderDashes: false,
+ borderRadius: 3,
+ },
+ color: {
+ border: '#b0b0b0',
+ background: 'rgb(193,229,222)',
+ highlight: {
+ border: '#368d7e',
+ background: 'rgb(193,229,222)'
+ }
+ }
+ },
+ household: {
+ /*
+ shape: 'dot',
+ */
+ color: 'pink'
+ },
+ accompanying_period: {
+ /*
+ shape: 'triangle',
+ */
+ color: 'orange',
+
+ },
}
};
@@ -45,6 +117,7 @@ window.network = {};
* and add properties needed by vis
*/
const adapt2vis = (entity) => {
+ entity.group = entity.type
switch (entity.type) {
case 'person':
entity._id = entity.id
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
index db143e39f..c6d7330fa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
@@ -8,13 +8,11 @@
- {#
- {{ dump() }}
- #}
-
{% endblock %}
-{% block block_post_menu %}{% endblock %}
+{% block block_post_menu %}
+
+{% endblock %}
{% block js %}
{{ encore_entry_script_tags('vue_visgraph') }}
From b7466c7e85291b449e164abd9d48628f916f8f92 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Tue, 26 Oct 2021 14:49:12 +0200
Subject: [PATCH 014/227] GET for relationship fixed: associated relation
displayed
---
.../Controller/RelationshipApiController.php | 7 +---
.../Relationships/RelationshipRepository.php | 4 +-
.../Normalizer/RelationshipNormalizer.php | 37 +++++++++++++++++++
3 files changed, 41 insertions(+), 7 deletions(-)
create mode 100644 src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 0327d335e..921f2d151 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -23,12 +23,6 @@ class RelationshipApiController extends ApiController
$this->repository = $repository;
}
- public function createEntity(string $action, Request $request): object
- {
- $relationship = parent::createEntity($action, $request);
- return $relationship;
- }
-
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
* name="chill_relation_relationship_by_person")
@@ -39,6 +33,7 @@ class RelationshipApiController extends ApiController
{
//TODO: add permissions? (voter?)
$relationships = $this->repository->findByPerson($person);
+ dump($relationships[0]->getRelation());
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
index ad251b4ff..00546e424 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
@@ -27,7 +27,9 @@ class RelationshipRepository extends ServiceEntityRepository
{
// return all relationships of which person is part? or only where person is the fromPerson?
return $this->createQueryBuilder('r')
- ->andWhere('r.fromPerson = :val')
+ ->select('r, t') // entity Relationship
+ ->join('r.relation', 't')
+ ->where('r.fromPerson = :val')
->orWhere('r.toPerson = :val')
->setParameter('val', $personId)
->getQuery()
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
new file mode 100644
index 000000000..6036a18e9
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
@@ -0,0 +1,37 @@
+ 'relationship',
+ 'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
+ 'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
+ 'relation' => $this->normalizer->normalize($relationship->getRelation()),
+ 'reverse' => $relationship->getReverse()
+ ];
+ }
+
+ public function supportsNormalization($data, ?string $format = null)
+ {
+ return $data instanceof Relationship;
+ }
+
+}
\ No newline at end of file
From 9609fcb5d3974c72c8d94b1ad71cb6a18f536af2 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 14:53:42 +0200
Subject: [PATCH 015/227] visgraph: edit interface fr translations
---
.../Resources/public/vuejs/VisGraph/i18n.js | 32 +++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index f7af08240..9fa8eca26 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -5,9 +5,37 @@ const visMessages = {
visgraph: {
'Course': 'Parcours',
'Household': 'Ménage',
- }
+ },
+ edit: 'Éditer',
+ del: 'Supprimer',
+ back: 'Revenir en arrière',
+ addNode: 'Ajouter un noeuds',
+ addEdge: 'Ajouter un lien',
+ editNode: 'Éditer un noeuds',
+ editEdge: 'Éditer un lien',
+ addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
+ edgeDescription: 'Cliquez sur un nœud et faites glisser le lien vers un autre nœud pour les connecter.',
+ editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
+ createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
+ deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
+ editClusterError: 'Les clusters ne peuvent pas être modifiés.'
},
- en: {}
+ en: {
+ edit: 'Edit',
+ del: 'Delete selected',
+ back: 'Back',
+ addNode: 'Add Node',
+ addEdge: 'Add Link',
+ editNode: 'Edit Switch',
+ editEdge: 'Edit Link',
+ addDescription: 'Click in an empty space to place a new node.',
+ edgeDescription: 'Click on a node and drag the link to another node to connect them.',
+ editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
+ createEdgeError: 'Cannot link edges to a cluster.',
+ deleteClusterError: 'Clusters cannot be deleted.',
+ editClusterError: 'Clusters cannot be edited.'
+
+ }
}
//Object.assign(visMessages.fr, personMessages.fr);
From a20eeb6a34a10b304e50b47881fdfecd40f984fa Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 15:15:44 +0200
Subject: [PATCH 016/227] vue_visgraph: add a mechanism to force update
component
cfr. https://medium.com/emblatech/ways-to-force-vue-to-re-render-a-component-df866fbacf47
---
.../Resources/public/vuejs/VisGraph/App.vue | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 5979a2c71..d0e78bfaa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -66,6 +66,11 @@ export default {
// Instanciate vis objects in window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
+ },
+ forceUpdateComponent() {
+ console.log('forceUpdateComponent - method 3')
+ this.$forceUpdate()
+ this.refreshNetwork
}
}
/*
From 2a86fd12d7a0e0f2e97eebdede5541d5538991ac Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 21:29:17 +0200
Subject: [PATCH 017/227] vue_visgraph: add checkbox legend to enable/disable
layers
---
.../Resources/public/vuejs/VisGraph/App.vue | 104 +++++++++++++-----
.../Resources/public/vuejs/VisGraph/store.js | 17 ++-
.../public/vuejs/VisGraph/vis-network.js | 10 +-
3 files changed, 97 insertions(+), 34 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index d0e78bfaa..cb9e07716 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -1,30 +1,28 @@
-
+
+Checked layers: {{ checkedLayers }}
+Unchecked layers: {{ excludedNodesIds }}
+
Rafraîchir
@@ -37,12 +35,19 @@ export default {
name: "App",
data() {
return {
- container: ''
+ container: '',
+ checkedLayers: [],
}
},
computed: {
- //not used ...mapState(['persons', 'households', 'courses', 'relationships', 'householdLoadingIds', 'courseLoadedIds']),
...mapGetters(['nodes', 'edges']),
+ ...mapState(['households', 'courses',
+ 'excludedNodesIds'
+ //'persons',
+ //'relationships',
+ //'householdLoadingIds',
+ //'courseLoadedIds',
+ ]),
visgraph_data() {
console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
@@ -51,10 +56,36 @@ export default {
edges: this.edges
}
},
+
refreshNetwork() { // B
console.log('--- refresh network')
window.network.setData(this.visgraph_data)
+ },
+
+ legendLayers() {
+ console.log('--- refresh legendLayers')
+ return [
+ ...this.households,
+ ...this.courses
+ ]
+ },
+
+ rebuildCheckedLayers() {
+ console.log('-*- rebuild checked Layers Arrays from graph nodes')
+ this.checkedLayers = []
+ let layersDisplayed = [
+ ...this.nodes.filter(n => n.id.startsWith('household')),
+ ...this.nodes.filter(n => n.id.startsWith('accompanying'))
+ ]
+ layersDisplayed.forEach(layer => {
+ this.checkedLayers.push(layer.id)
+ })
+ },
+
+ checkedLayers() { // required to refresh data checkedLayers
+ return this.checkedLayers
}
+
},
mounted() {
console.log('=== mounted: init graph')
@@ -63,7 +94,6 @@ export default {
methods: {
initGraph() {
this.container = document.getElementById('visgraph')
-
// Instanciate vis objects in window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
},
@@ -71,7 +101,29 @@ export default {
console.log('forceUpdateComponent - method 3')
this.$forceUpdate()
this.refreshNetwork
- }
+ },
+
+ toggleLayer(value) {
+ let id = value.target.value
+ console.log('--> toggleLayer', this.checkedLayers)
+ if (this.checkedLayers.includes(id)) {
+ this.removeLayer(id)
+ } else {
+ this.addLayer(id)
+ }
+ console.log('<-- toggleLayer after', this.checkedLayers)
+ },
+ addLayer(id) {
+ console.log('+ add Layer', id)
+ this.checkedLayers.push(id)
+ this.$store.commit('removeExcludedNode', id)
+ },
+ removeLayer(id) {
+ console.log('- remove Layer', id)
+ this.checkedLayers = this.checkedLayers.filter(i => i !== id)
+ this.$store.commit('addExcludedNode', id)
+ },
+
}
/*
TODO / TO CHECK / TO UNDERSTAND
@@ -98,14 +150,6 @@ div#visgraph {
}
div#visgraph-legend {
div.post-menu.legend {
- ul.legend-list {
- padding-left: 0;
- list-style-type: square;
- li::marker {
- color: red;
- background-color: cyan;
- }
- }
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index a06e6e55c..b4938ff4a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -12,7 +12,8 @@ const store = createStore({
courses: [],
relationships: [],
householdLoadingIds: [],
- courseLoadedIds: []
+ courseLoadedIds: [],
+ excludedNodesIds: []
},
getters: {
nodes(state) {
@@ -26,6 +27,10 @@ const store = createStore({
state.courses.forEach(c => {
nodes.push(c)
})
+ // except excluded nodes (unchecked layers)
+ state.excludedNodesIds.forEach(excluded => {
+ nodes = nodes.filter(n => n.id !== excluded)
+ })
return nodes
},
edges(state) {
@@ -56,7 +61,7 @@ const store = createStore({
state.courses.push(adapt2vis(course))
},
addRelationship(state, relationship) {
- console.log('+ addRelationship', relationship)
+ console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
state.relationships.push(relationship)
},
markHouseholdLoading(state, id) {
@@ -72,6 +77,12 @@ const store = createStore({
unmarkCourseLoaded(state, id) {
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
},
+ addExcludedNode(state, id) {
+ state.excludedNodesIds.push(id)
+ },
+ removeExcludedNode(state, id) {
+ state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
+ }
},
actions: {
/**
@@ -185,7 +196,7 @@ const store = createStore({
arrows: 'to',
color: 'orange',
font: { color: 'orange' },
- label: 'usager',
+ label: 'concerné',
//group: 'link_person_course',
})
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index cc0ef717a..bfdc74991 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -10,6 +10,14 @@ import { visMessages } from './i18n'
window.options = {
locale: 'fr',
locales: visMessages,
+ /*
+ configure: {
+ enabled: true,
+ filter: 'nodes,edges',
+ container: undefined,
+ showButton: true
+ },
+ */
manipulation: {
enabled: true,
initiallyActive: true,
@@ -63,7 +71,7 @@ window.options = {
physics: true,
font: {
color: '#b0b0b0',
- size: 9,
+ size: 9,
face: 'arial',
background: 'none',
strokeWidth: 2, // px
From 326fe5f50b27cc389cf6b1b16057a4d86cb0e81c Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 11:53:34 +0200
Subject: [PATCH 018/227] vue_visgraph: cleaning + i18n
---
.../Resources/public/vuejs/_js/i18n.js | 3 +-
.../Resources/public/vuejs/VisGraph/App.vue | 35 +++++++------------
.../Resources/public/vuejs/VisGraph/i18n.js | 5 +--
3 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
index c16b4c65d..4b998f98a 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
@@ -45,7 +45,8 @@ const messages = {
redirect: {
person: "Quitter la page et ouvrir la fiche de l'usager",
thirdparty: "Quitter la page et voir le tiers",
- }
+ },
+ refresh: 'Rafraîchir'
},
nav: {
next: "Suivant",
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index cb9e07716..7be18e6eb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -3,7 +3,7 @@
-
-Checked layers: {{ checkedLayers }}
-Unchecked layers: {{ excludedNodesIds }}
-
- Rafraîchir
+ {{ $t('action.refresh') }}
@@ -41,8 +36,7 @@ export default {
},
computed: {
...mapGetters(['nodes', 'edges']),
- ...mapState(['households', 'courses',
- 'excludedNodesIds'
+ ...mapState(['households', 'courses', 'excludedNodesIds'
//'persons',
//'relationships',
//'householdLoadingIds',
@@ -57,13 +51,13 @@ export default {
}
},
- refreshNetwork() { // B
+ refreshNetwork() {
console.log('--- refresh network')
window.network.setData(this.visgraph_data)
},
legendLayers() {
- console.log('--- refresh legendLayers')
+ console.log('--- refresh legend')
return [
...this.households,
...this.courses
@@ -71,7 +65,7 @@ export default {
},
rebuildCheckedLayers() {
- console.log('-*- rebuild checked Layers Arrays from graph nodes')
+ console.log('--- rebuild checked Layers')
this.checkedLayers = []
let layersDisplayed = [
...this.nodes.filter(n => n.id.startsWith('household')),
@@ -94,36 +88,33 @@ export default {
methods: {
initGraph() {
this.container = document.getElementById('visgraph')
- // Instanciate vis objects in window variables, see vis-network.js
- window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
+ // Instanciate vis objects in separate window variables, see vis-network.js
+ window.network = new vis.Network(this.container, this.visgraph_data, window.options )
},
forceUpdateComponent() {
- console.log('forceUpdateComponent - method 3')
+ console.log('forceUpdateComponent')
this.$forceUpdate()
this.refreshNetwork
},
-
toggleLayer(value) {
+ //console.log('toggleLayer')
let id = value.target.value
- console.log('--> toggleLayer', this.checkedLayers)
if (this.checkedLayers.includes(id)) {
this.removeLayer(id)
} else {
this.addLayer(id)
}
- console.log('<-- toggleLayer after', this.checkedLayers)
},
addLayer(id) {
- console.log('+ add Layer', id)
+ console.log('+ addLayer', id)
this.checkedLayers.push(id)
this.$store.commit('removeExcludedNode', id)
},
removeLayer(id) {
- console.log('- remove Layer', id)
+ console.log('- removeLayer', id)
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
this.$store.commit('addExcludedNode', id)
},
-
}
/*
TODO / TO CHECK / TO UNDERSTAND
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 9fa8eca26..db3f8998f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -3,8 +3,9 @@
const visMessages = {
fr: {
visgraph: {
- 'Course': 'Parcours',
- 'Household': 'Ménage',
+ Course: 'Parcours',
+ Household: 'Ménage',
+ Legend: 'Légende',
},
edit: 'Éditer',
del: 'Supprimer',
From c200e9909ebecfad9f7391ec59d7108109d07c33 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 15:16:13 +0200
Subject: [PATCH 019/227] i18n minor changes
---
.../Resources/public/vuejs/VisGraph/i18n.js | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index db3f8998f..077c3c7f6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -1,11 +1,9 @@
-//import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
-
const visMessages = {
fr: {
visgraph: {
Course: 'Parcours',
Household: 'Ménage',
- Legend: 'Légende',
+ Legend: 'Calques',
},
edit: 'Éditer',
del: 'Supprimer',
@@ -39,8 +37,6 @@ const visMessages = {
}
}
-//Object.assign(visMessages.fr, personMessages.fr);
-
export {
visMessages
}
From a3b203c30629c18ebb0de9e2d79f4b5dc0643ae5 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:28:13 +0200
Subject: [PATCH 020/227] fix backend error with AccompanyingCourse endpoints
---
.../Controller/RelationshipApiController.php | 6 +++---
.../ChillPersonBundle/config/services/controller.yaml | 5 +----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 921f2d151..765d13d25 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -26,15 +26,15 @@ class RelationshipApiController extends ApiController
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
* name="chill_relation_relationship_by_person")
- *
+ *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getRelationshipsByPerson(Person $person)
{
//TODO: add permissions? (voter?)
$relationships = $this->repository->findByPerson($person);
- dump($relationships[0]->getRelation());
+ //dump($relationships[0]->getRelation());
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index cb7ebd76c..45a656e89 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -41,10 +41,7 @@ services:
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
- arguments:
- $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $registry: '@Symfony\Component\Workflow\Registry'
+ autowire: true
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonApiController:
From 7ad0e2f2c803819db97d69928affc1c720e2d54d Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:29:16 +0200
Subject: [PATCH 021/227] rename fetch api method
---
.../Resources/public/vuejs/VisGraph/api.js | 10 +++++-----
.../Resources/public/vuejs/VisGraph/store.js | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 957e01fbc..ee288dcc0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -89,14 +89,14 @@ const getCoursesByPerson = (person) => {
}
/**
- * @function getRelationship
+ * @function getRelationshipByPerson
* @param person
* @returns {Promise}
*/
-const getRelationship = (person) => {
- //console.log('getRelationship', person.id)
+const getRelationshipByPerson = (person) => {
+ //console.log('getRelationshipByPerson', person.id)
return getFetch(
- `/api/1.0/relations/relationship/by-person/${person.id}.json`)
+ `/api/1.0/relations/relationship/by-person/${person._id}.json`)
}
/**
@@ -120,6 +120,6 @@ const postRelationship = (person) => {
export {
getHouseholdByPerson,
getCoursesByPerson,
- getRelationship,
+ getRelationshipByPerson,
postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index b4938ff4a..25d044afb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,5 +1,5 @@
import { createStore } from 'vuex'
-import { getHouseholdByPerson, getCoursesByPerson, getRelationship } from './api'
+import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
import { adapt2vis } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -208,9 +208,9 @@ const store = createStore({
*/
fetchRelationship({ commit, getters }, person) {
console.log('fetchRelationship', person)
- getRelationship(person)
+ getRelationshipByPerson(person)
.then(relationship => new Promise(resolve => {
- console.log('getRelationship', relationship)
+ console.log('getRelationshipByPerson', relationship)
commit('addRelationship', relationship)
resolve()
}))
From 8ff581d5facce919fa108beecd4221404d1bfe15 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:29:54 +0200
Subject: [PATCH 022/227] vue_visgraph: add links array state in store
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 7be18e6eb..916fb05ef 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -38,6 +38,7 @@ export default {
...mapGetters(['nodes', 'edges']),
...mapState(['households', 'courses', 'excludedNodesIds'
//'persons',
+ //'links,
//'relationships',
//'householdLoadingIds',
//'courseLoadedIds',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 25d044afb..310315946 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -11,6 +11,7 @@ const store = createStore({
households: [],
courses: [],
relationships: [],
+ links: [],
householdLoadingIds: [],
courseLoadedIds: [],
excludedNodesIds: []
@@ -35,6 +36,9 @@ const store = createStore({
},
edges(state) {
let edges = []
+ state.links.forEach(l => {
+ edges.push(l)
+ })
state.relationships.forEach(r => {
edges.push(r)
})
@@ -60,6 +64,10 @@ const store = createStore({
console.log('+ addCourse', course.id)
state.courses.push(adapt2vis(course))
},
+ addLink(state, link) {
+ console.log('+ addLink from', link.from, 'to', link.to)
+ state.links.push(link)
+ },
addRelationship(state, relationship) {
console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
state.relationships.push(relationship)
@@ -134,7 +142,7 @@ const store = createStore({
const members = household.members.filter(v => household.current_members_id.includes(v.id))
members.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
- commit('addRelationship', {
+ commit('addLink', {
from: `${m.person.type}_${m.person.id}`,
to: `household_${m.person.current_household_id}`,
id: `p${m.person.id}-h${m.person.current_household_id}`,
@@ -189,7 +197,7 @@ const store = createStore({
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
currentParticipations.forEach(p => {
- commit('addRelationship', {
+ commit('addLink', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
id: `p${p.person.id}-c`+ course.id.split('_')[2],
@@ -202,7 +210,6 @@ const store = createStore({
})
},
-
/**
* Fetch Relationship
*/
From 1d1a54f653f7b58a72534ca8cf3723229c0e9e5c Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 17:24:23 +0200
Subject: [PATCH 023/227] vue_visgraph: improve household links (edges)
---
.../Resources/public/vuejs/VisGraph/i18n.js | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 15 +++--
.../public/vuejs/VisGraph/vis-network.js | 59 +++++++++++++++----
3 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 077c3c7f6..c4ad74907 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -3,6 +3,7 @@ const visMessages = {
visgraph: {
Course: 'Parcours',
Household: 'Ménage',
+ Holder: 'Titulaire',
Legend: 'Calques',
},
edit: 'Éditer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 310315946..0d0ff4442 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
-import { adapt2vis } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -139,8 +139,8 @@ const store = createStore({
* @param Household household
*/
addLinkFromPersonsToHousehold({ commit }, household) {
- const members = household.members.filter(v => household.current_members_id.includes(v.id))
- members.forEach(m => {
+ const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
+ currentMembers.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
commit('addLink', {
from: `${m.person.type}_${m.person.id}`,
@@ -148,9 +148,9 @@ const store = createStore({
id: `p${m.person.id}-h${m.person.current_household_id}`,
arrows: 'from',
color: 'pink',
- font: { color: 'pink' },
- label: 'enfant',
- ////group: 'link_person_household',
+ font: { color: '#D04A60' },
+ label: getHouseholdLabel(m),
+ width: getHouseholdWidth(m),
})
})
@@ -203,9 +203,8 @@ const store = createStore({
id: `p${p.person.id}-c`+ course.id.split('_')[2],
arrows: 'to',
color: 'orange',
- font: { color: 'orange' },
+ font: { color: 'darkorange' },
label: 'concerné',
- //group: 'link_person_course',
})
})
},
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index bfdc74991..8774501a0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,12 +1,14 @@
import { visMessages } from './i18n'
-/*
+/**
* Vis-network initial data/configuration script
* Notes:
* Use window.network and window.options to avoid conflict between vue and vis
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
+window.network = {};
+
window.options = {
locale: 'fr',
locales: visMessages,
@@ -14,7 +16,7 @@ window.options = {
configure: {
enabled: true,
filter: 'nodes,edges',
- container: undefined,
+ //container: undefined,
showButton: true
},
*/
@@ -46,7 +48,8 @@ window.options = {
console.log('deleteNode', edgeData)
callback(edgeData);
},
- controlNodeStyle: { /*
+ controlNodeStyle: {
+ /*
shape:'dot',
size: 6,
color: {
@@ -112,18 +115,16 @@ window.options = {
shape: 'triangle',
*/
color: 'orange',
-
},
}
};
-window.network = {};
-
-/*
-* Adapt entity to graph (id, label)
-* we rename id in _id
-* and add properties needed by vis
-*/
+/**
+ * Adapt entity to graph (id, label)
+ * rename id in _id and add properties needed by vis
+ * @param entity
+ * @returns entity
+ */
const adapt2vis = (entity) => {
entity.group = entity.type
switch (entity.type) {
@@ -146,6 +147,38 @@ const adapt2vis = (entity) => {
return entity
}
-export {
- adapt2vis
+/**
+ * Return member position in household
+ * @param member
+ * @returns string
+ */
+const getHouseholdLabel = (member) => {
+ let position = member.position.label.fr
+ let holder = member.holder ? ` (${visMessages.fr.visgraph.Holder})` : ''
+ return position + holder
+}
+
+/**
+ * Return edge width for member (depends of position in household)
+ * @param member
+ * @returns string
+ */
+const getHouseholdWidth = (member) => {
+ switch (member.position.ordering) {
+ case 1: //adult
+ if (member.holder) {
+ return 6
+ }
+ return 3
+ case 2: //children
+ case 3: //children out of household
+ return 1
+ }
+}
+
+
+export {
+ adapt2vis,
+ getHouseholdLabel,
+ getHouseholdWidth
}
From 6752a2f6d3279865bf0465591c54c2685d63f29f Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 27 Oct 2021 17:40:15 +0200
Subject: [PATCH 024/227] fixture created for Relation entity
---
.../DataFixtures/ORM/LoadRelations.php | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
new file mode 100644
index 000000000..bcd7df547
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
@@ -0,0 +1,45 @@
+ ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
+ ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
+ ['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Frère']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ];
+
+ foreach($relations as $value){
+ print "Creating a new relation type: relation" . $value['title']['fr'] . "reverse relation: " . $value['reverseTitle']['fr'] . "\n";
+ $relation = new Relation();
+ $relation->setTitle($value['title'])
+ ->setReverseTitle($value['reverseTitle']);
+ $manager->persist($relation);
+ }
+
+ $manager->flush();
+
+ }
+
+}
\ No newline at end of file
From 83e8b117db388e39f75716de1770ae1d9bd147dc Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 27 Oct 2021 18:10:35 +0200
Subject: [PATCH 025/227] start of Relationship fixture
---
.../ChillPersonBundle/DataFixtures/ORM/LoadRelations.php | 3 +++
.../ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php | 0
2 files changed, 3 insertions(+)
create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
index bcd7df547..2b72052c6 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
@@ -10,6 +10,8 @@ use Doctrine\Persistence\ObjectManager;
class LoadRelations extends Fixture implements FixtureGroupInterface
{
+ public const RELATIONS = 'relations';
+
public static function getGroups(): array
{
return ['person_relations'];
@@ -36,6 +38,7 @@ class LoadRelations extends Fixture implements FixtureGroupInterface
$relation->setTitle($value['title'])
->setReverseTitle($value['reverseTitle']);
$manager->persist($relation);
+ $this->addReference(self::RELATIONS, $relation);
}
$manager->flush();
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
new file mode 100644
index 000000000..e69de29bb
From 2cb1ad6afc3bcb2820d6815517aa09ecad197b8a Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 18:11:14 +0200
Subject: [PATCH 026/227] improve household position fixture
---
.../DataFixtures/ORM/LoadHouseholdPosition.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
index cf0bf3de1..23bd499f8 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
@@ -10,8 +10,8 @@ class LoadHouseholdPosition extends Fixture
{
const POSITIONS_DATA = [
["Adulte", true, true, 1.0, self::ADULT ],
- ["Enfants", true, false, 2.0, self::CHILD ],
- ["Enfants hors ménage", false, false, 3.0, self::CHILD_OUT ]
+ ["Enfant", true, false, 2.0, self::CHILD ],
+ ["Enfant hors ménage", false, false, 3.0, self::CHILD_OUT ]
];
const ADULT = "position_adulte";
From f834bb3bd613342aeff825852abcd947f51e0d2e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 19:54:28 +0200
Subject: [PATCH 027/227] backend normalizer: add id to relationship endpoint
---
.../Serializer/Normalizer/RelationshipNormalizer.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
index 6036a18e9..e410dd90b 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
@@ -22,6 +22,7 @@ class RelationshipNormalizer implements NormalizerInterface, NormalizerAwareInte
{
return [
'type' => 'relationship',
+ 'id' => $this->normalizer->normalize($relationship->getId()),
'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
'relation' => $this->normalizer->normalize($relationship->getRelation()),
From 92c1bf15cc6194fad153faa1470bba5711f85973 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 19:55:24 +0200
Subject: [PATCH 028/227] vue_visgraph: add relationship links with relations
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/api.js | 8 +-
.../Resources/public/vuejs/VisGraph/i18n.js | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 100 ++++++++++++++----
.../public/vuejs/VisGraph/vis-network.js | 17 ++-
5 files changed, 104 insertions(+), 23 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 916fb05ef..1804460f7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -42,6 +42,7 @@ export default {
//'relationships',
//'householdLoadingIds',
//'courseLoadedIds',
+ //'relationshipLoadedIds',
]),
visgraph_data() {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index ee288dcc0..f595daa34 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -89,12 +89,12 @@ const getCoursesByPerson = (person) => {
}
/**
- * @function getRelationshipByPerson
+ * @function getRelationshipsByPerson
* @param person
* @returns {Promise}
*/
-const getRelationshipByPerson = (person) => {
- //console.log('getRelationshipByPerson', person.id)
+const getRelationshipsByPerson = (person) => {
+ //console.log('getRelationshipsByPerson', person.id)
return getFetch(
`/api/1.0/relations/relationship/by-person/${person._id}.json`)
}
@@ -120,6 +120,6 @@ const postRelationship = (person) => {
export {
getHouseholdByPerson,
getCoursesByPerson,
- getRelationshipByPerson,
+ getRelationshipsByPerson,
postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index c4ad74907..9ca273f72 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -5,6 +5,7 @@ const visMessages = {
Household: 'Ménage',
Holder: 'Titulaire',
Legend: 'Calques',
+ concerned: 'concerné',
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 0d0ff4442..da13d9bd3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,7 @@
import { createStore } from 'vuex'
-import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth } from './vis-network'
+import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel } from './vis-network'
+import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -14,6 +15,7 @@ const store = createStore({
links: [],
householdLoadingIds: [],
courseLoadedIds: [],
+ relationshipLoadedIds: [],
excludedNodesIds: []
},
getters: {
@@ -39,9 +41,9 @@ const store = createStore({
state.links.forEach(l => {
edges.push(l)
})
- state.relationships.forEach(r => {
- edges.push(r)
- })
+ //state.relationships.forEach(r => {
+ // edges.push(r)
+ //})
return edges
},
isHouseholdLoading: (state) => (household_id) => {
@@ -50,6 +52,9 @@ const store = createStore({
isCourseLoaded: (state) => (course_id) => {
return state.courseLoadedIds.includes(course_id)
},
+ isRelationshipLoaded: (state) => (relationship_id) => {
+ return state.relationshipLoadedIds.includes(relationship_id)
+ }
},
mutations: {
addPerson(state, person) {
@@ -64,14 +69,14 @@ const store = createStore({
console.log('+ addCourse', course.id)
state.courses.push(adapt2vis(course))
},
+ addRelationship(state, relationship) {
+ console.log('+ addRelationship', relationship.id)
+ state.relationships.push(adapt2vis(relationship))
+ },
addLink(state, link) {
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
- addRelationship(state, relationship) {
- console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
- state.relationships.push(relationship)
- },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
@@ -85,6 +90,12 @@ const store = createStore({
unmarkCourseLoaded(state, id) {
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
},
+ markRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds.push(id)
+ },
+ unmarkRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
+ },
addExcludedNode(state, id) {
state.excludedNodesIds.push(id)
},
@@ -109,7 +120,7 @@ const store = createStore({
fetchInfoForPerson({ dispatch }, person) {
dispatch('fetchHouseholdForPerson', person)
dispatch('fetchCoursesByPerson', person)
- //dispatch('fetchRelationship', person)
+ dispatch('fetchRelationshipByPerson', person)
},
/**
@@ -204,23 +215,76 @@ const store = createStore({
arrows: 'to',
color: 'orange',
font: { color: 'darkorange' },
- label: 'concerné',
+ label: visMessages.fr.visgraph.concerned,
})
})
},
/**
- * Fetch Relationship
+ * 8) Fetch Relationship
+ * @param Person person
*/
- fetchRelationship({ commit, getters }, person) {
- console.log('fetchRelationship', person)
- getRelationshipByPerson(person)
- .then(relationship => new Promise(resolve => {
- console.log('getRelationshipByPerson', relationship)
- commit('addRelationship', relationship)
+ fetchRelationshipByPerson({ dispatch }, person) {
+ //console.log('fetchRelationshipByPerson', person)
+ getRelationshipsByPerson(person)
+ .then(relationships => new Promise(resolve => {
+ console.log('fetch relationships', relationships.length)
+ dispatch('addRelationship', relationships)
resolve()
}))
+ },
+
+ /**
+ * 9) Add each distinct relationship
+ * @param array relationships
+ */
+ addRelationship({ commit, getters, dispatch }, relationships) {
+ relationships.forEach(relationship => {
+ console.log(' isRelationshipLoaded ?', getters.isRelationshipLoaded(relationship.id))
+ if (! getters.isRelationshipLoaded(relationship.id)) {
+ //console.log('relationship', relationship.id)
+ commit('markRelationshipLoaded', relationship.id)
+ commit('addRelationship', relationship)
+ dispatch('addLinkFromRelationship', relationship)
+ }
+ })
+ },
+
+ /**
+ * 10) Add an edge for each relationship (person -> person)
+ * @param Relationship relationship
+ */
+ addLinkFromRelationship({ commit }, r) {
+
+ console.log(
+ '-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id,
+ //'reverse', r.reverse,
+ //'relation', r.relation.title.fr, r.relation.reverseTitle.fr
+ )
+
+ commit('addLink', {
+ from: `person_${r.fromPerson.id}`,
+ to: `person_${r.toPerson.id}`,
+ id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
+ arrows: 'from',
+ color: 'lightblue', dashes: true,
+ font: { color: 'lightblue' },
+ label: getRelationshipLabel(r, false),
+ })
+
+ /*
+ // add reverse relation
+ commit('addLink', {
+ from: `person_${r.toPerson.id}`,
+ to: `person_${r.fromPerson.id}`,
+ id: 'rr' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
+ arrows: 'from',
+ color: 'lightblue', dashes: true,
+ font: { color: 'lightblue' },
+ label: getRelationshipLabel(r, true),
+ })
+ */
},
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 8774501a0..3ed6a7e7a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -143,6 +143,12 @@ const adapt2vis = (entity) => {
entity.label = `${visMessages.fr.visgraph.Course} n° ${entity.id}`
entity.id = `accompanying_period_${entity.id}`
break
+ case 'relationship':
+ entity._id = entity.id
+ entity.id = `relationship_${entity.id}`
+
+ // sera utilisé pour les links :
+ //entity.id = 'r' + entity._id + '_p' + entity.fromPerson.id + '_p' + entity.toPerson.id
}
return entity
}
@@ -176,9 +182,18 @@ const getHouseholdWidth = (member) => {
}
}
+/**
+ * Return label edge
+ * @param relationship
+ * @returns string
+ */
+const getRelationshipLabel = (relationship, reverse) => {
+ return (!reverse) ? relationship.relation.title.fr : relationship.relation.reverseTitle.fr
+}
export {
adapt2vis,
getHouseholdLabel,
- getHouseholdWidth
+ getHouseholdWidth,
+ getRelationshipLabel
}
From 317ba0a095ab9c4ce86b21b99de0de4519311ab7 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 28 Oct 2021 12:11:51 +0200
Subject: [PATCH 029/227] vue_visgraph: store missing persons from courses,
household and relationship
---
.../Resources/public/vuejs/VisGraph/App.vue | 10 +--
.../Resources/public/vuejs/VisGraph/store.js | 83 +++++++++++--------
.../public/vuejs/VisGraph/vis-network.js | 8 +-
3 files changed, 57 insertions(+), 44 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 1804460f7..74409c7f1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -36,13 +36,9 @@ export default {
},
computed: {
...mapGetters(['nodes', 'edges']),
- ...mapState(['households', 'courses', 'excludedNodesIds'
- //'persons',
- //'links,
- //'relationships',
- //'householdLoadingIds',
- //'courseLoadedIds',
- //'relationshipLoadedIds',
+ ...mapState(['households', 'courses', 'excludedNodesIds',
+ // not used
+ 'persons', 'links', 'relationships', 'personLoadedIds', 'householdLoadingIds', 'courseLoadedIds', 'relationshipLoadedIds',
]),
visgraph_data() {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index da13d9bd3..c18323684 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -13,6 +13,7 @@ const store = createStore({
courses: [],
relationships: [],
links: [],
+ personLoadedIds: [],
householdLoadingIds: [],
courseLoadedIds: [],
relationshipLoadedIds: [],
@@ -41,9 +42,6 @@ const store = createStore({
state.links.forEach(l => {
edges.push(l)
})
- //state.relationships.forEach(r => {
- // edges.push(r)
- //})
return edges
},
isHouseholdLoading: (state) => (household_id) => {
@@ -54,6 +52,9 @@ const store = createStore({
},
isRelationshipLoaded: (state) => (relationship_id) => {
return state.relationshipLoadedIds.includes(relationship_id)
+ },
+ isPersonLoaded: (state) => (person_id) => {
+ return state.personLoadedIds.includes(person_id)
}
},
mutations: {
@@ -77,6 +78,12 @@ const store = createStore({
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
+ markPersonLoaded(state, id) {
+ state.personLoadedIds.push(id)
+ },
+ unmarkPersonLoaded(state, id) {
+ state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
+ },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
@@ -108,7 +115,9 @@ const store = createStore({
* 1) Add a person in state
* @param Person person
*/
+
addPerson({ commit, dispatch }, person) {
+ commit('markPersonLoaded', person.id)
commit('addPerson', person)
dispatch('fetchInfoForPerson', person)
},
@@ -149,7 +158,7 @@ const store = createStore({
* 4) Add an edge for each household member (household -> person)
* @param Household household
*/
- addLinkFromPersonsToHousehold({ commit }, household) {
+ addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
currentMembers.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
@@ -163,30 +172,32 @@ const store = createStore({
label: getHouseholdLabel(m),
width: getHouseholdWidth(m),
})
+ if (!getters.isPersonLoaded(m.person.id)) {
+ console.log(' person is not loaded', m.person.id)
+ dispatch('addMissingPerson', m.person)
+ }
})
-
},
/**
* 5) Fetch AccompanyingCourses for the person
* @param Person person
*/
- fetchCoursesByPerson({ dispatch }, person) {
+ fetchCoursesByPerson({ commit, dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
getCoursesByPerson(person)
.then(courses => new Promise(resolve => {
console.log('fetch courses', courses.length)
- dispatch('addCourse', courses)
+ dispatch('addCourses', courses)
resolve()
}))
-
},
/**
* 6) Add each distinct course
* @param array courses
*/
- addCourse({ commit, getters, dispatch }, courses) {
+ addCourses({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
let currentCourses = courses.filter(c => c.closingDate === null)
currentCourses.forEach(course => {
@@ -204,7 +215,7 @@ const store = createStore({
* 7) Add an edge for each course participation (course <- person)
* @param AccompanyingCourse course
*/
- addLinkFromPersonsToCourse({ commit }, course) {
+ addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
currentParticipations.forEach(p => {
@@ -217,6 +228,10 @@ const store = createStore({
font: { color: 'darkorange' },
label: visMessages.fr.visgraph.concerned,
})
+ if (!getters.isPersonLoaded(p.person.id)) {
+ console.log(' person is not loaded', p.person.id)
+ dispatch('addMissingPerson', p.person)
+ }
})
},
@@ -229,7 +244,7 @@ const store = createStore({
getRelationshipsByPerson(person)
.then(relationships => new Promise(resolve => {
console.log('fetch relationships', relationships.length)
- dispatch('addRelationship', relationships)
+ dispatch('addRelationships', relationships)
resolve()
}))
},
@@ -239,7 +254,7 @@ const store = createStore({
* 9) Add each distinct relationship
* @param array relationships
*/
- addRelationship({ commit, getters, dispatch }, relationships) {
+ addRelationships({ commit, getters, dispatch }, relationships) {
relationships.forEach(relationship => {
console.log(' isRelationshipLoaded ?', getters.isRelationshipLoaded(relationship.id))
if (! getters.isRelationshipLoaded(relationship.id)) {
@@ -253,40 +268,36 @@ const store = createStore({
/**
* 10) Add an edge for each relationship (person -> person)
- * @param Relationship relationship
+ * @param Relationship r
*/
- addLinkFromRelationship({ commit }, r) {
-
- console.log(
- '-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id,
- //'reverse', r.reverse,
- //'relation', r.relation.title.fr, r.relation.reverseTitle.fr
- )
-
+ addLinkFromRelationship({ commit, getters, dispatch }, r) {
+ //console.log('-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id)
commit('addLink', {
from: `person_${r.fromPerson.id}`,
to: `person_${r.toPerson.id}`,
id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
- arrows: 'from',
+ arrows: 'to',
color: 'lightblue', dashes: true,
- font: { color: 'lightblue' },
+ font: { color: '#33839d' },
label: getRelationshipLabel(r, false),
})
-
- /*
- // add reverse relation
- commit('addLink', {
- from: `person_${r.toPerson.id}`,
- to: `person_${r.fromPerson.id}`,
- id: 'rr' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
- arrows: 'from',
- color: 'lightblue', dashes: true,
- font: { color: 'lightblue' },
- label: getRelationshipLabel(r, true),
- })
- */
+ for (let person of [r.fromPerson, r.toPerson]) {
+ if (!getters.isPersonLoaded(person.id)) {
+ console.log(' person is not loaded', person.id)
+ dispatch('addMissingPerson', person)
+ }
+ }
},
+ /**
+ * Fetch missing person
+ * @param Person person
+ */
+ addMissingPerson({ commit, getters, dispatch }, person) {
+ //console.log('addMissingPerson', person)
+ commit('markPersonLoaded', person.id)
+ commit('addPerson', person)
+ },
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 3ed6a7e7a..f1e9ab05e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -167,7 +167,11 @@ const getHouseholdLabel = (member) => {
/**
* Return edge width for member (depends of position in household)
* @param member
- * @returns string
+ * @returns integer (width)
+ *
+ * TODO
+ * to use: holder, shareHousehold
+ * not use: ordering, position (-> null)
*/
const getHouseholdWidth = (member) => {
switch (member.position.ordering) {
@@ -179,6 +183,8 @@ const getHouseholdWidth = (member) => {
case 2: //children
case 3: //children out of household
return 1
+ default:
+ throw 'Ordering not supported'
}
}
From 998295dc5fb5004ca80e13581cefc10b87d49735 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 28 Oct 2021 15:47:40 +0200
Subject: [PATCH 030/227] vue_visgraph improve (physics, corrections)
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 2 +-
.../public/vuejs/VisGraph/vis-network.js | 79 +++++++++++++++++--
3 files changed, 75 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 74409c7f1..fd45dd750 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -96,6 +96,7 @@ export default {
},
toggleLayer(value) {
//console.log('toggleLayer')
+ this.forceUpdateComponent()
let id = value.target.value
if (this.checkedLayers.includes(id)) {
this.removeLayer(id)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index c18323684..394fd55e6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -223,7 +223,7 @@ const store = createStore({
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
id: `p${p.person.id}-c`+ course.id.split('_')[2],
- arrows: 'to',
+ arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
label: visMessages.fr.visgraph.concerned,
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f1e9ab05e..eeddb7da4 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -20,6 +20,55 @@ window.options = {
showButton: true
},
*/
+ physics:{
+ enabled: true,
+ barnesHut: {
+ theta: 0.5,
+ gravitationalConstant: -2000,
+ centralGravity: 0.1, //// 0.3
+ springLength: 200, //// 95
+ springConstant: 0.04,
+ damping: 0.09,
+ avoidOverlap: 0
+ },
+ forceAtlas2Based: {
+ theta: 0.5,
+ gravitationalConstant: -50,
+ centralGravity: 0.01,
+ springConstant: 0.08,
+ springLength: 100,
+ damping: 0.4,
+ avoidOverlap: 0
+ },
+ repulsion: {
+ centralGravity: 0.2,
+ springLength: 200,
+ springConstant: 0.05,
+ nodeDistance: 100,
+ damping: 0.09
+ },
+ hierarchicalRepulsion: {
+ centralGravity: 0.0,
+ springLength: 100,
+ springConstant: 0.01,
+ nodeDistance: 120,
+ damping: 0.09,
+ avoidOverlap: 0
+ },
+ maxVelocity: 50,
+ minVelocity: 0.1,
+ solver: 'barnesHut',
+ stabilization: {
+ enabled: true,
+ iterations: 1000,
+ updateInterval: 100,
+ onlyDynamicEdges: false,
+ fit: true
+ },
+ timestep: 0.5,
+ adaptiveTimestep: true,
+ wind: { x: 0, y: 0 }
+ },
manipulation: {
enabled: true,
initiallyActive: true,
@@ -66,12 +115,12 @@ window.options = {
}
},
nodes: {
- physics: true,
+ //physics: true,
borderWidth: 1,
borderWidthSelected: 3,
},
edges: {
- physics: true,
+ //physics: true,
font: {
color: '#b0b0b0',
size: 9,
@@ -130,7 +179,7 @@ const adapt2vis = (entity) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = entity.text
+ entity.label = `${entity.text}\n` + getGender(entity.gender_numeric) +' - '+ getAge(entity.birthdate)
entity.id = `person_${entity.id}`
break
case 'household':
@@ -146,13 +195,31 @@ const adapt2vis = (entity) => {
case 'relationship':
entity._id = entity.id
entity.id = `relationship_${entity.id}`
-
- // sera utilisé pour les links :
- //entity.id = 'r' + entity._id + '_p' + entity.fromPerson.id + '_p' + entity.toPerson.id
}
return entity
}
+const getGender = (gender) => {
+ switch (gender) {
+ case 0:
+ return 'N'
+ case 1:
+ return 'M'
+ case 2:
+ return 'F'
+ default:
+ throw 'gender undefined'
+ }
+}
+const getAge = (birthdate) => {
+ if (null === birthdate) {
+ return null
+ }
+ const birthday = new Date(birthdate.datetime)
+ const now = new Date()
+ return (now.getFullYear() - birthday.getFullYear()) + ' ans'
+}
+
/**
* Return member position in household
* @param member
From 3a7af94058e0bd6d9c7c42d0651a9656abd1b5a0 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 09:29:27 +0200
Subject: [PATCH 031/227] GET and POST both working.
---
.../AccompanyingCourseApiController.php | 2 -
.../DataFixtures/ORM/LoadRelationships.php | 22 +++++++
.../ChillPersonExtension.php | 4 --
.../Entity/Relationships/Relation.php | 16 +++--
.../Entity/Relationships/Relationship.php | 58 +++++++++++--------
5 files changed, 68 insertions(+), 34 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 891a0f461..132dc1172 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -32,8 +32,6 @@ class AccompanyingCourseApiController extends ApiController
private Registry $registry;
- private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
-
public function __construct(
EventDispatcherInterface $eventDispatcher,
ValidatorInterface $validator,
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
index e69de29bb..cfabde912 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
@@ -0,0 +1,22 @@
+ [
'_entity' => [
'methods' => [
- Request::METHOD_GET => true,
- Request::METHOD_HEAD => true,
Request::METHOD_POST => true,
Request::METHOD_PATCH => true
],
'roles' => [
- Request::METHOD_GET => 'ROLE_USER',
- Request::METHOD_HEAD => 'ROLE_USER',
Request::METHOD_POST => 'ROLE_USER',
Request::METHOD_PATCH => 'ROLE_USER'
]
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
index 7cd000dd5..a0fefc877 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
@@ -3,10 +3,16 @@
namespace Chill\PersonBundle\Entity\Relationships;
use Doctrine\ORM\Mapping as ORM;
+use Doctrine\ORM\Mapping\DiscriminatorColumn;
+use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
+use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity()
* @ORM\Table(name="chill_person_relations")
+ * @DiscriminatorMap(typeProperty="type", mapping={
+ * "relation"=Relation::class
+ * })
*/
class Relation
{
@@ -15,17 +21,19 @@ class Relation
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
- private $id;
+ private ?int $id = null;
/**
* @ORM\Column(type="json", nullable=true)
+ * @Serializer\Groups({"read"})
*/
- private $title = [];
+ private array $title = [];
/**
* @ORM\Column(type="json", nullable=true)
+ * @Serializer\Groups({"read"})
*/
- private $reverseTitle = [];
+ private array $reverseTitle = [];
public function getId(): ?int
{
@@ -55,4 +63,4 @@ class Relation
return $this;
}
-}
+}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
index e748f9797..54be21140 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
@@ -2,50 +2,60 @@
namespace Chill\PersonBundle\Entity\Relationships;
+use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
+use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Relationships\Relation;
+use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
-use Symfony\Component\Serializer\Annotation\Groups;
+use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
+use Doctrine\ORM\Mapping\DiscriminatorColumn;
+use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity()
* @ORM\Table(name="chill_person_relationships")
+ * @DiscriminatorColumn(name="relation_id", type="integer")
+ * @DiscriminatorMap(typeProperty="type", mapping={
+ * "relationship"=Relationship::class
+ * })
+ *
*/
-class Relationship
+class Relationship implements TrackCreationInterface, TrackUpdateInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
- * @Groups({"read"})
+ * @Serializer\Groups({"read"})
*/
- private $id;
+ private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $fromPerson;
+ private ?Person $fromPerson = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $toPerson;
+ private ?Person $toPerson = null;
/**
* @ORM\ManyToOne(targetEntity=Relation::class)
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $relation;
+ private ?Relation $relation = null;
/**
* @ORM\Column(type="boolean")
@@ -53,30 +63,30 @@ class Relationship
* type="bool",
* message="This must be of type boolean"
* )
- * @Groups({"read"})
+ * @Serializer\Groups({"read", "write"})
*/
- private $reverse;
+ private bool $reverse;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
- private $createdBy;
+ private ?User $createdBy = null;
/**
* @ORM\Column(type="datetime_immutable")
*/
- private $createdAt;
+ private ?DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
- private $updatedBy;
+ private ?User $updatedBy = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
- private $updatedAt;
+ private ?DateTimeImmutable $updatedAt = null;
public function getId(): ?int
@@ -125,9 +135,9 @@ class Relationship
return $this->createdBy;
}
- public function setCreatedBy(?User $createdBy): self
+ public function setCreatedBy(?User $user): self
{
- $this->createdBy = $createdBy;
+ $this->createdBy = $user;
return $this;
}
@@ -137,7 +147,7 @@ class Relationship
return $this->createdAt;
}
- public function setCreatedAt(\DateTimeImmutable $createdAt): self
+ public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -161,7 +171,7 @@ class Relationship
return $this->updatedAt;
}
- public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
+ public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
@@ -179,4 +189,4 @@ class Relationship
return $this;
}
-}
+}
\ No newline at end of file
From 76d6a9b4dfe2943cf5ff3bf6301edeba7b18e187 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 10:01:14 +0200
Subject: [PATCH 032/227] vue_visgraph: makeFetch (api), add validation
exception
---
.../Resources/public/vuejs/VisGraph/api.js | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index f595daa34..5533bd6ff 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -20,7 +20,9 @@ const makeFetch = (method, url, body) => {
}
if (response.status === 422) {
- return response.json();
+ return response.json().then(violations => {
+ throw ValidationException(violations)
+ });
}
throw {
@@ -33,13 +35,22 @@ const makeFetch = (method, url, body) => {
});
}
+/**
+ * @param violations
+ * @constructor
+ */
+const ValidationException = (violations) => {
+ this.violations = violations
+ this.name = 'ValidationException'
+}
+
/**
* @function getFetch
* @param url
* @returns {Promise}
*/
const getFetch = (url) => {
- return makeFetch('GET', url, null);
+ return makeFetch('GET', url, null)
}
/**
@@ -49,7 +60,7 @@ const getFetch = (url) => {
* @returns {Promise}
*/
const postFetch = (url, body) => {
- return makeFetch('POST', url, body);
+ return makeFetch('POST', url, body)
}
/**
@@ -59,7 +70,7 @@ const postFetch = (url, body) => {
* @returns {Promise}
*/
const patchFetch = (url, body) => {
- return makeFetch('PATCH', url, body);
+ return makeFetch('PATCH', url, body)
}
From 1155555bb3ec1c375ef683f13ea355772d305214 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 10:37:51 +0200
Subject: [PATCH 033/227] backend: adapt deprecated getGenderNumeric
---
src/Bundle/ChillPersonBundle/Entity/Person.php | 14 ++++++++++----
.../Serializer/Normalizer/PersonNormalizer.php | 1 -
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 9aaad8c04..01a524beb 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -901,13 +901,19 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* return gender as a Numeric form.
* This is used for translations
* @return int
+ * @deprecated Keep for legacy. Used in Chill 1.5 for feminize before icu translations
*/
public function getGenderNumeric()
{
- if ($this->getGender() == self::FEMALE_GENDER) {
- return 1;
- } else {
- return 0;
+ switch ($this->getGender()) {
+ case self::FEMALE_GENDER:
+ return 1;
+ case self::MALE_GENDER:
+ return 0;
+ case self::BOTH_GENDER:
+ return 2;
+ default:
+ return -1;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
index 2b82780c2..380112a12 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
@@ -79,7 +79,6 @@ class PersonNormalizer implements
'mobilenumber' => $person->getMobilenumber(),
'altNames' => $this->normalizeAltNames($person->getAltNames()),
'gender' => $person->getGender(),
- 'gender_numeric' => $person->getGenderNumeric(),
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
];
From 50fbc7fd158b9c038953433b338cdc5c3d70b8b6 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 11:30:01 +0200
Subject: [PATCH 034/227] processing of review. still ACL left to do
---
.../Controller/RelationshipApiController.php | 2 +-
.../Entity/Relationships/Relation.php | 18 ++++++
.../Relationships/RelationRepository.php | 62 ++++++++-----------
.../Relationships/RelationshipRepository.php | 50 ++++++++++-----
.../Normalizer/RelationshipNormalizer.php | 38 ------------
.../migrations/Version20211029075117.php | 29 +++++++++
6 files changed, 110 insertions(+), 89 deletions(-)
delete mode 100644 src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 765d13d25..69809d6ee 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -25,7 +25,7 @@ class RelationshipApiController extends ApiController
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
- * name="chill_relation_relationship_by_person")
+ * name="chill_relationship_by_person")
*
* @ParamConverter("person", options={"id" = "person_id"})
*/
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
index a0fefc877..7628863fe 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
@@ -35,6 +35,12 @@ class Relation
*/
private array $reverseTitle = [];
+ /**
+ * @ORM\Column(type="boolean", nullable=true)
+ * @Serializer\Groups({"read"})
+ */
+ private bool $isActive = true;
+
public function getId(): ?int
{
return $this->id;
@@ -63,4 +69,16 @@ class Relation
return $this;
}
+
+ public function getIsActive(): bool
+ {
+ return $this->isActive;
+ }
+
+ public function setIsActive(?bool $isActive): self
+ {
+ $this->isActive = $isActive;
+
+ return $this;
+ }
}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
index 8b5fbb743..b735138f4 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
@@ -2,49 +2,41 @@
namespace Chill\PersonBundle\Repository\Relationships;
-use App\Entity\Relation;
-use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Persistence\ManagerRegistry;
+use Chill\PersonBundle\Entity\Relationships\Relation;
+use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\EntityRepository;
+use Doctrine\Persistence\ObjectRepository;
-/**
- * @method Relation|null find($id, $lockMode = null, $lockVersion = null)
- * @method Relation|null findOneBy(array $criteria, array $orderBy = null)
- * @method Relation[] findAll()
- * @method Relation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
-class RelationRepository extends ServiceEntityRepository
+class RelationRepository implements ObjectRepository
{
- public function __construct(ManagerRegistry $registry)
+ private EntityRepository $repository;
+
+ public function __construct(EntityManagerInterface $entityManager)
{
- parent::__construct($registry, Relation::class);
+ $this->repository = $entityManager->getRepository(Relation::class);
+ }
+ public function find($id): ?Relation
+ {
+ return $this->repository->find($id);
}
- // /**
- // * @return Relation[] Returns an array of Relation objects
- // */
- /*
- public function findByExampleField($value)
+ public function findAll(): array
{
- return $this->createQueryBuilder('r')
- ->andWhere('r.exampleField = :val')
- ->setParameter('val', $value)
- ->orderBy('r.id', 'ASC')
- ->setMaxResults(10)
- ->getQuery()
- ->getResult()
- ;
+ return $this->repository->findAll();
}
- */
- /*
- public function findOneBySomeField($value): ?Relation
+ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
- return $this->createQueryBuilder('r')
- ->andWhere('r.exampleField = :val')
- ->setParameter('val', $value)
- ->getQuery()
- ->getOneOrNullResult()
- ;
+ return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
+ }
+
+ public function findOneBy(array $criteria): ?Relation
+ {
+ return $this->findOneBy($criteria);
+ }
+
+ public function getClassName(): string
+ {
+ return MaritalStatus::class;
}
- */
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
index 00546e424..3f105537a 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
@@ -3,30 +3,50 @@
namespace Chill\PersonBundle\Repository\Relationships;
use Chill\PersonBundle\Entity\Relationships\Relationship;
-use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ObjectRepository;
-/**
- * @method Relationship|null find($id, $lockMode = null, $lockVersion = null)
- * @method Relationship|null findOneBy(array $criteria, array $orderBy = null)
- * @method Relationship[] findAll()
- * @method Relationship[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
-class RelationshipRepository extends ServiceEntityRepository
+class RelationshipRepository implements ObjectRepository
{
- public function __construct(ManagerRegistry $registry)
+
+ private EntityRepository $repository;
+
+ public function __construct(EntityManagerInterface $em)
{
- parent::__construct($registry, Relationship::class);
+ $this->repository = $em->getRepository(Relationship::class);
}
- // /**
- // * @return Relationship[] Returns an array of Relationship objects linked to certain person.
- // */
+ public function find($id): ?Relationship
+ {
+ return $this->repository->find($id);
+ }
+
+ public function findAll(): array
+ {
+ return $this->repository->findAll();
+ }
+
+ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
+ {
+ return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
+ }
+
+ public function findOneBy(array $criteria): ?Relationship
+ {
+ return $this->findOneBy($criteria);
+ }
+
+ public function getClassName(): string
+ {
+ return MaritalStatus::class;
+ }
- public function findByPerson($personId)
+ public function findByPerson($personId): array
{
// return all relationships of which person is part? or only where person is the fromPerson?
- return $this->createQueryBuilder('r')
+ return $this->repository->createQueryBuilder('r')
->select('r, t') // entity Relationship
->join('r.relation', 't')
->where('r.fromPerson = :val')
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
deleted file mode 100644
index e410dd90b..000000000
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
+++ /dev/null
@@ -1,38 +0,0 @@
- 'relationship',
- 'id' => $this->normalizer->normalize($relationship->getId()),
- 'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
- 'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
- 'relation' => $this->normalizer->normalize($relationship->getRelation()),
- 'reverse' => $relationship->getReverse()
- ];
- }
-
- public function supportsNormalization($data, ?string $format = null)
- {
- return $data instanceof Relationship;
- }
-
-}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
new file mode 100644
index 000000000..9c3d5131e
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
@@ -0,0 +1,29 @@
+addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN NOT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE chill_person_relations DROP isActive');
+ }
+}
From 039c74a1e435426a4f8840ee943aa4d65b78ff96 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 13:20:56 +0200
Subject: [PATCH 035/227] route annotation removed
---
.../Controller/AccompanyingCourseApiController.php | 7 -------
.../Controller/RelationshipApiController.php | 5 -----
2 files changed, 12 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 132dc1172..72ca7aa5b 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -21,7 +21,6 @@ use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Workflow\Registry;
-use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingCourseApiController extends ApiController
@@ -195,12 +194,6 @@ $workflow = $this->registry->get($accompanyingPeriod);
}
/**
- * @Route("/api/1.0/person/accompanying-course/by-person/{person_id}.{_format}",
- * name="chill_person_accompanyingperiod_by_person",
- * requirements={
- * "_format"="json"
- * })
- *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getAccompanyingPeriodsByPerson(Person $person){
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 69809d6ee..bf4452942 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -8,9 +8,7 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;
-use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Symfony\Component\HttpFoundation\Request;
class RelationshipApiController extends ApiController
{
@@ -24,9 +22,6 @@ class RelationshipApiController extends ApiController
}
/**
- * @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
- * name="chill_relationship_by_person")
- *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getRelationshipsByPerson(Person $person)
From 1c60a5b51e33a3a8159886c81108d0835d94352a Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 12:06:59 +0200
Subject: [PATCH 036/227] vue_visgraph: improve graph
---
.../Resources/public/vuejs/VisGraph/i18n.js | 5 ++
.../Resources/public/vuejs/VisGraph/store.js | 13 ++--
.../public/vuejs/VisGraph/vis-network.js | 74 +++++++++++--------
3 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 9ca273f72..0e1cf4686 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -6,6 +6,11 @@ const visMessages = {
Holder: 'Titulaire',
Legend: 'Calques',
concerned: 'concerné',
+ both: 'neutre, non binaire',
+ woman: 'féminin',
+ man: 'masculin',
+ years: 'ans'
+
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 394fd55e6..b336da45a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -115,7 +115,6 @@ const store = createStore({
* 1) Add a person in state
* @param Person person
*/
-
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
commit('addPerson', person)
@@ -127,7 +126,9 @@ const store = createStore({
* @param Person person
*/
fetchInfoForPerson({ dispatch }, person) {
- dispatch('fetchHouseholdForPerson', person)
+ if (null !== person.current_household_id) {
+ dispatch('fetchHouseholdForPerson', person)
+ }
dispatch('fetchCoursesByPerson', person)
dispatch('fetchRelationshipByPerson', person)
},
@@ -226,7 +227,7 @@ const store = createStore({
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
- label: visMessages.fr.visgraph.concerned,
+ //label: visMessages.fr.visgraph.concerned,
})
if (!getters.isPersonLoaded(p.person.id)) {
console.log(' person is not loaded', p.person.id)
@@ -277,9 +278,11 @@ const store = createStore({
to: `person_${r.toPerson.id}`,
id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
arrows: 'to',
- color: 'lightblue', dashes: true,
+ color: 'lightblue',
font: { color: '#33839d' },
+ dashes: true,
label: getRelationshipLabel(r, false),
+ title: getRelationshipTitle(r),
})
for (let person of [r.fromPerson, r.toPerson]) {
if (!getters.isPersonLoaded(person.id)) {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index eeddb7da4..f8001f441 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -128,7 +128,7 @@ window.options = {
background: 'none',
strokeWidth: 2, // px
strokeColor: '#ffffff',
- align: 'horizontal',
+ align: 'middle',
multi: false,
vadjust: 0,
},
@@ -154,15 +154,9 @@ window.options = {
}
},
household: {
- /*
- shape: 'dot',
- */
color: 'pink'
},
accompanying_period: {
- /*
- shape: 'triangle',
- */
color: 'orange',
},
}
@@ -179,7 +173,8 @@ const adapt2vis = (entity) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = `${entity.text}\n` + getGender(entity.gender_numeric) +' - '+ getAge(entity.birthdate)
+ entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
+ //entity.title = `${entity.text}`
entity.id = `person_${entity.id}`
break
case 'household':
@@ -195,29 +190,42 @@ const adapt2vis = (entity) => {
case 'relationship':
entity._id = entity.id
entity.id = `relationship_${entity.id}`
+ break
+ default:
+ throw 'entity undefined'
}
return entity
}
+/**
+ * @param gender
+ * @returns {string}
+ */
const getGender = (gender) => {
switch (gender) {
- case 0:
- return 'N'
- case 1:
- return 'M'
- case 2:
- return 'F'
+ case 'both':
+ return visMessages.fr.visgraph.both
+ case 'woman':
+ return visMessages.fr.visgraph.woman
+ case 'man':
+ return visMessages.fr.visgraph.man
default:
throw 'gender undefined'
}
}
+
+/**
+ * TODO Repeat getAge() in PersonRenderBox.vue
+ * @param birthdate
+ * @returns {string|null}
+ */
const getAge = (birthdate) => {
if (null === birthdate) {
return null
}
const birthday = new Date(birthdate.datetime)
const now = new Date()
- return (now.getFullYear() - birthday.getFullYear()) + ' ans'
+ return (now.getFullYear() - birthday.getFullYear()) + ' '+ visMessages.fr.visgraph.years
}
/**
@@ -235,24 +243,15 @@ const getHouseholdLabel = (member) => {
* Return edge width for member (depends of position in household)
* @param member
* @returns integer (width)
- *
- * TODO
- * to use: holder, shareHousehold
- * not use: ordering, position (-> null)
*/
const getHouseholdWidth = (member) => {
- switch (member.position.ordering) {
- case 1: //adult
- if (member.holder) {
- return 6
- }
- return 3
- case 2: //children
- case 3: //children out of household
- return 1
- default:
- throw 'Ordering not supported'
+ if (member.holder) {
+ return 5
}
+ if (member.shareHousehold) {
+ return 2
+ }
+ return 1
}
/**
@@ -264,9 +263,22 @@ const getRelationshipLabel = (relationship, reverse) => {
return (!reverse) ? relationship.relation.title.fr : relationship.relation.reverseTitle.fr
}
+/**
+ * Return title edge
+ * @param relationship
+ * @returns string
+ */
+const getRelationshipTitle = (relationship) => {
+ return relationship.relation.title.fr + ': '
+ + relationship.fromPerson.text + '\n'
+ + relationship.relation.reverseTitle.fr + ': '
+ + relationship.toPerson.text
+}
+
export {
adapt2vis,
getHouseholdLabel,
getHouseholdWidth,
- getRelationshipLabel
+ getRelationshipLabel,
+ getRelationshipTitle
}
From a9d3d2027b84bfa9c95e19e93925e2910cb4ab3e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 15:32:12 +0200
Subject: [PATCH 037/227] minor
---
.../Resources/public/vuejs/VisGraph/store.js | 35 ++++++++++++-------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index b336da45a..86b21d3de 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,7 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
-import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -113,7 +112,8 @@ const store = createStore({
actions: {
/**
* 1) Add a person in state
- * @param Person person
+ * @param object
+ * @param person
*/
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
@@ -123,7 +123,8 @@ const store = createStore({
/**
* 2) Fetch infos for this person (hub)
- * @param Person person
+ * @param object
+ * @param person
*/
fetchInfoForPerson({ dispatch }, person) {
if (null !== person.current_household_id) {
@@ -136,7 +137,8 @@ const store = createStore({
/**
* 3) Fetch person current household (if it is not already loading)
* check first isHouseholdLoading to fetch household once
- * @param Person person
+ * @param object
+ * @param person
*/
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
@@ -157,7 +159,8 @@ const store = createStore({
/**
* 4) Add an edge for each household member (household -> person)
- * @param Household household
+ * @param object
+ * @param household
*/
addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
@@ -182,7 +185,8 @@ const store = createStore({
/**
* 5) Fetch AccompanyingCourses for the person
- * @param Person person
+ * @param object
+ * @param person
*/
fetchCoursesByPerson({ commit, dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
@@ -196,7 +200,8 @@ const store = createStore({
/**
* 6) Add each distinct course
- * @param array courses
+ * @param object
+ * @param courses
*/
addCourses({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
@@ -214,7 +219,8 @@ const store = createStore({
/**
* 7) Add an edge for each course participation (course <- person)
- * @param AccompanyingCourse course
+ * @param object
+ * @param course
*/
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
@@ -227,7 +233,6 @@ const store = createStore({
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
- //label: visMessages.fr.visgraph.concerned,
})
if (!getters.isPersonLoaded(p.person.id)) {
console.log(' person is not loaded', p.person.id)
@@ -238,7 +243,8 @@ const store = createStore({
/**
* 8) Fetch Relationship
- * @param Person person
+ * @param object
+ * @param person
*/
fetchRelationshipByPerson({ dispatch }, person) {
//console.log('fetchRelationshipByPerson', person)
@@ -253,7 +259,8 @@ const store = createStore({
/**
* 9) Add each distinct relationship
- * @param array relationships
+ * @param object
+ * @param relationships
*/
addRelationships({ commit, getters, dispatch }, relationships) {
relationships.forEach(relationship => {
@@ -269,7 +276,8 @@ const store = createStore({
/**
* 10) Add an edge for each relationship (person -> person)
- * @param Relationship r
+ * @param object
+ * @param r (relationship)
*/
addLinkFromRelationship({ commit, getters, dispatch }, r) {
//console.log('-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id)
@@ -294,7 +302,8 @@ const store = createStore({
/**
* Fetch missing person
- * @param Person person
+ * @param object
+ * @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
//console.log('addMissingPerson', person)
From e6183f664629f315ef8666ade8796b79c697a53c Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 15:56:57 +0200
Subject: [PATCH 038/227] migration fixed to insert default true value for
isActive
---
.../ChillPersonBundle/migrations/Version20211029075117.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
index 9c3d5131e..ef739dcb8 100644
--- a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
@@ -19,7 +19,7 @@ final class Version20211029075117 extends AbstractMigration
public function up(Schema $schema): void
{
- $this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN NOT NULL');
+ $this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN DEFAULT true NOT NULL');
}
public function down(Schema $schema): void
From 8eedee5e9106792f58624891c3244fdefcab698e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 16:54:22 +0200
Subject: [PATCH 039/227] visgraph: default uncheck layers when loading
---
.../ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 86b21d3de..a0109c9c8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -148,6 +148,7 @@ const store = createStore({
.then(household => new Promise(resolve => {
//console.log('getHouseholdByPerson', household)
commit('addHousehold', household)
+ commit('addExcludedNode', household.id)
dispatch('addLinkFromPersonsToHousehold', household)
resolve()
})
@@ -212,6 +213,7 @@ const store = createStore({
//console.log('course', course.id)
commit('markCourseLoaded', course.id)
commit('addCourse', course)
+ commit('addExcludedNode', course.id)
dispatch('addLinkFromPersonsToCourse', course)
}
})
From 83129553913d030a3298de333a9691192f416fa9 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 17:34:37 +0200
Subject: [PATCH 040/227] visgraph: hide somes persons nodes labels (folded)
---
.../Resources/public/vuejs/VisGraph/i18n.js | 4 +-
.../Resources/public/vuejs/VisGraph/store.js | 50 +++++++++++--------
.../public/vuejs/VisGraph/vis-network.js | 9 +++-
3 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 0e1cf4686..5b408e209 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -9,8 +9,8 @@ const visMessages = {
both: 'neutre, non binaire',
woman: 'féminin',
man: 'masculin',
- years: 'ans'
-
+ years: 'ans',
+ click_to_expand: 'cliquez pour étendre',
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index a0109c9c8..0944667bc 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -59,49 +59,53 @@ const store = createStore({
mutations: {
addPerson(state, person) {
console.log('+ addPerson', person.id)
- state.persons.push(adapt2vis(person))
+ state.persons.push(person)
},
addHousehold(state, household) {
console.log('+ addHousehold', household.id)
- state.households.push(adapt2vis(household))
+ state.households.push(household)
},
addCourse(state, course) {
console.log('+ addCourse', course.id)
- state.courses.push(adapt2vis(course))
+ state.courses.push(course)
},
addRelationship(state, relationship) {
console.log('+ addRelationship', relationship.id)
- state.relationships.push(adapt2vis(relationship))
+ state.relationships.push(relationship)
},
addLink(state, link) {
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
+
+ //// id markers
markPersonLoaded(state, id) {
state.personLoadedIds.push(id)
},
- unmarkPersonLoaded(state, id) {
- state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
- },
+ unmarkPersonLoaded(state, id) {
+ state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
+ },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
},
- unmarkHouseholdLoading(state, id) {
- state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
- },
+ unmarkHouseholdLoading(state, id) {
+ state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
+ },
markCourseLoaded(state, id) {
state.courseLoadedIds.push(id)
},
- unmarkCourseLoaded(state, id) {
- state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
- },
+ unmarkCourseLoaded(state, id) {
+ state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
+ },
markRelationshipLoaded(state, id) {
state.relationshipLoadedIds.push(id)
},
- unmarkRelationshipLoaded(state, id) {
- state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
- },
+ unmarkRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
+ },
+
+ //// excluded
addExcludedNode(state, id) {
state.excludedNodesIds.push(id)
},
@@ -117,7 +121,7 @@ const store = createStore({
*/
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
- commit('addPerson', person)
+ commit('addPerson', adapt2vis(person, { folded: false }))
dispatch('fetchInfoForPerson', person)
},
@@ -147,7 +151,7 @@ const store = createStore({
getHouseholdByPerson(person)
.then(household => new Promise(resolve => {
//console.log('getHouseholdByPerson', household)
- commit('addHousehold', household)
+ commit('addHousehold', adapt2vis(household))
commit('addExcludedNode', household.id)
dispatch('addLinkFromPersonsToHousehold', household)
resolve()
@@ -212,7 +216,7 @@ const store = createStore({
if (! getters.isCourseLoaded(course.id)) {
//console.log('course', course.id)
commit('markCourseLoaded', course.id)
- commit('addCourse', course)
+ commit('addCourse', adapt2vis(course))
commit('addExcludedNode', course.id)
dispatch('addLinkFromPersonsToCourse', course)
}
@@ -270,7 +274,7 @@ const store = createStore({
if (! getters.isRelationshipLoaded(relationship.id)) {
//console.log('relationship', relationship.id)
commit('markRelationshipLoaded', relationship.id)
- commit('addRelationship', relationship)
+ commit('addRelationship', adapt2vis(relationship))
dispatch('addLinkFromRelationship', relationship)
}
})
@@ -308,9 +312,11 @@ const store = createStore({
* @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
- //console.log('addMissingPerson', person)
commit('markPersonLoaded', person.id)
- commit('addPerson', person)
+ commit('addPerson', adapt2vis(person, { folded: true }))
+
+ console.log('********* fetch infos for missing', person.id, '******')
+ //dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f8001f441..8cafdda9f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -166,15 +166,20 @@ window.options = {
* Adapt entity to graph (id, label)
* rename id in _id and add properties needed by vis
* @param entity
+ * @param options
* @returns entity
*/
-const adapt2vis = (entity) => {
+const adapt2vis = (entity, options = {}) => {
entity.group = entity.type
switch (entity.type) {
case 'person':
entity._id = entity.id
entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
- //entity.title = `${entity.text}`
+ if (options.folded) {
+ entity.title = visMessages.fr.visgraph.click_to_expand
+ entity._label = entity.label // keep label
+ entity.label = null
+ }
entity.id = `person_${entity.id}`
break
case 'household':
From 09903c2f52ea8dbd370f6ee1aab8765c1009ee12 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 19:08:52 +0200
Subject: [PATCH 041/227] click node event (wip)
---
.../ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index fd45dd750..9ff406e47 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -114,6 +114,10 @@ export default {
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
this.$store.commit('addExcludedNode', id)
},
+ clickOnNode(callback) {
+ console.log('** click on node **')
+ window.network.on('click', callback)
+ },
}
/*
TODO / TO CHECK / TO UNDERSTAND
From 851a24625798bd9489a0bd8a9876887d3685218b Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Sat, 30 Oct 2021 00:27:10 +0200
Subject: [PATCH 042/227] visgraph: improve label with basic markdown
---
.../Resources/public/vuejs/VisGraph/vis-network.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 8cafdda9f..ecec18c9b 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -118,6 +118,9 @@ window.options = {
//physics: true,
borderWidth: 1,
borderWidthSelected: 3,
+ font: {
+ multi: 'md'
+ }
},
edges: {
//physics: true,
@@ -148,7 +151,7 @@ window.options = {
border: '#b0b0b0',
background: 'rgb(193,229,222)',
highlight: {
- border: '#368d7e',
+ border: '#8d3686',
background: 'rgb(193,229,222)'
}
}
@@ -174,7 +177,7 @@ const adapt2vis = (entity, options = {}) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
+ entity.label = `*${entity.text}*\n_${getGender(entity.gender)} - ${getAge(entity.birthdate)}_`
if (options.folded) {
entity.title = visMessages.fr.visgraph.click_to_expand
entity._label = entity.label // keep label
From a57a23dc4934225c9e6a5310c1767e4ec5b7ae63 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Sat, 30 Oct 2021 01:51:02 +0200
Subject: [PATCH 043/227] visgraph options settings
---
.../Resources/public/vuejs/VisGraph/store.js | 2 +-
.../public/vuejs/VisGraph/vis-network.js | 22 ++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 0944667bc..80e4d0768 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -316,7 +316,7 @@ const store = createStore({
commit('addPerson', adapt2vis(person, { folded: true }))
console.log('********* fetch infos for missing', person.id, '******')
- //dispatch('fetchInfoForPerson', person)
+ dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index ecec18c9b..fca3c0876 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -25,8 +25,8 @@ window.options = {
barnesHut: {
theta: 0.5,
gravitationalConstant: -2000,
- centralGravity: 0.1, //// 0.3
- springLength: 200, //// 95
+ centralGravity: 0.08, //// 0.3
+ springLength: 220, //// 95
springConstant: 0.04,
damping: 0.09,
avoidOverlap: 0
@@ -151,10 +151,22 @@ window.options = {
border: '#b0b0b0',
background: 'rgb(193,229,222)',
highlight: {
- border: '#8d3686',
- background: 'rgb(193,229,222)'
+ border: '#89c9a9',
+ background: 'rgb(156,213,203)'
+ },
+ hover: {
+ border: '#89c9a9',
+ background: 'rgb(156,213,203)'
}
- }
+ },
+ opacity: 0.85,
+ shadow:{
+ enabled: true,
+ color: 'rgba(0,0,0,0.5)',
+ size:10,
+ x:5,
+ y:5
+ },
},
household: {
color: 'pink'
From 869e442c2c515bb01ab614beee93a890db4aa105 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 09:49:55 +0100
Subject: [PATCH 044/227] visgraph: add hover interaction
---
.../Resources/public/vuejs/VisGraph/store.js | 4 ++--
.../Resources/public/vuejs/VisGraph/vis-network.js | 12 ++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 80e4d0768..066b7c1dc 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -294,7 +294,7 @@ const store = createStore({
arrows: 'to',
color: 'lightblue',
font: { color: '#33839d' },
- dashes: true,
+ dashes: true, //physics: false,
label: getRelationshipLabel(r, false),
title: getRelationshipTitle(r),
})
@@ -316,7 +316,7 @@ const store = createStore({
commit('addPerson', adapt2vis(person, { folded: true }))
console.log('********* fetch infos for missing', person.id, '******')
- dispatch('fetchInfoForPerson', person)
+ //dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index fca3c0876..15d9fafdd 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -69,6 +69,16 @@ window.options = {
adaptiveTimestep: true,
wind: { x: 0, y: 0 }
},
+ interaction: {
+ hover: true,
+ keyboard: {
+ enabled: true,
+ speed: {x: 3, y: 3, zoom: 0.02},
+ bindToWindow: false
+ },
+ multiselect: true,
+ navigationButtons: false
+ },
manipulation: {
enabled: true,
initiallyActive: true,
@@ -115,7 +125,6 @@ window.options = {
}
},
nodes: {
- //physics: true,
borderWidth: 1,
borderWidthSelected: 3,
font: {
@@ -123,7 +132,6 @@ window.options = {
}
},
edges: {
- //physics: true,
font: {
color: '#b0b0b0',
size: 9,
From c4ba78d076a3106575cc13f71068e33af4708d7e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 10:50:13 +0100
Subject: [PATCH 045/227] minor
---
.../public/vuejs/VisGraph/vis-network.js | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 15d9fafdd..7932217b1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -7,7 +7,7 @@ import { visMessages } from './i18n'
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
-window.network = {};
+window.network = {}
window.options = {
locale: 'fr',
@@ -84,28 +84,28 @@ window.options = {
initiallyActive: true,
addNode: function(nodeData, callback) {
console.log('addNode', nodeData)
- nodeData.label = 'hello world';
- callback(nodeData);
+ nodeData.label = 'hello world'
+ callback(nodeData)
},
editNode: function(nodeData, callback) {
console.log('editNode', nodeData)
- callback(nodeData);
+ callback(nodeData)
},
deleteNode: function(nodeData, callback) {
console.log('deleteNode', nodeData)
- callback(nodeData);
+ callback(nodeData)
},
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
deleteEdge: function(edgeData, callback) {
console.log('deleteNode', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
controlNodeStyle: {
/*
@@ -183,7 +183,7 @@ window.options = {
color: 'orange',
},
}
-};
+}
/**
* Adapt entity to graph (id, label)
@@ -285,6 +285,7 @@ const getHouseholdWidth = (member) => {
/**
* Return label edge
* @param relationship
+ * @param reverse
* @returns string
*/
const getRelationshipLabel = (relationship, reverse) => {
From a0940a0c8517667dc27374a8d7403bd5b9d48c61 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 10:45:37 +0100
Subject: [PATCH 046/227] visgraph: init window.eventHub as external emitter
called in Vue. This implementation works with vue2, but is deprecated in vue3
!!
see https://vue3-fr.netlify.app/guide/migration/events-api.html#_2-x-syntax
---
.../Resources/public/vuejs/VisGraph/App.vue | 9 +++++++++
.../Resources/public/vuejs/VisGraph/index.js | 1 +
.../Resources/public/vuejs/VisGraph/vis-network.js | 7 +++++++
3 files changed, 17 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 9ff406e47..c72c3689f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -79,6 +79,12 @@ export default {
}
},
+ created() {
+ eventHub.$on('add-switch', this.addSwitch)
+ },
+ unmounted() {
+ eventHub.$off('add-switch', this.addSwitch)
+ },
mounted() {
console.log('=== mounted: init graph')
this.initGraph()
@@ -118,6 +124,9 @@ export default {
console.log('** click on node **')
window.network.on('click', callback)
},
+ addSwitch(edgeData) {
+ console.log('==> addSwitch <=======================', edgeData)
+ },
}
/*
TODO / TO CHECK / TO UNDERSTAND
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
index 332b6cf6c..9e3da390f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -3,6 +3,7 @@ import { store } from "./store.js"
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { visMessages } from './i18n'
import App from './App.vue'
+
import './vis-network'
const i18n = _createI18n(visMessages)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 7932217b1..a5d2a8daa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,4 +1,5 @@
import { visMessages } from './i18n'
+import {createApp} from "vue"
/**
* Vis-network initial data/configuration script
@@ -7,6 +8,11 @@ import { visMessages } from './i18n'
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
+console.log('@@@@@@@ eventHub App @@@@@@@@@@')
+window.eventHub = createApp()
+console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
+
+
window.network = {}
window.options = {
@@ -98,6 +104,7 @@ window.options = {
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData)
+ eventHub.$emit('add-switch', edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
From 41f815bbb91e0b06bb6d30914141665a771e9b1d Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 11:46:30 +0100
Subject: [PATCH 047/227] tiny-emitter package is used as "centralized event
hub" between vis-network and vue3
---
.../Resources/public/vuejs/VisGraph/App.vue | 8 ++++----
.../Resources/public/vuejs/VisGraph/vis-network.js | 12 +++++-------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index c72c3689f..5bd654bd5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -80,10 +80,10 @@ export default {
},
created() {
- eventHub.$on('add-switch', this.addSwitch)
+ eventHub.on('add-relationship-link', this.addRelationshipLink)
},
unmounted() {
- eventHub.$off('add-switch', this.addSwitch)
+ eventHub.off('add-relationship-link', this.addRelationshipLink)
},
mounted() {
console.log('=== mounted: init graph')
@@ -124,8 +124,8 @@ export default {
console.log('** click on node **')
window.network.on('click', callback)
},
- addSwitch(edgeData) {
- console.log('==> addSwitch <=======================', edgeData)
+ addRelationshipLink(edgeData) {
+ console.log('==> addRelationshipLink <=======================', edgeData)
},
}
/*
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index a5d2a8daa..086608e19 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,5 +1,5 @@
import { visMessages } from './i18n'
-import {createApp} from "vue"
+import { TinyEmitter } from "tiny-emitter";
/**
* Vis-network initial data/configuration script
@@ -8,10 +8,8 @@ import {createApp} from "vue"
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
-console.log('@@@@@@@ eventHub App @@@@@@@@@@')
-window.eventHub = createApp()
-console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
-
+console.log('@@@ init eventHub App @@@')
+window.eventHub = new TinyEmitter()
window.network = {}
@@ -26,7 +24,7 @@ window.options = {
showButton: true
},
*/
- physics:{
+ physics: {
enabled: true,
barnesHut: {
theta: 0.5,
@@ -104,7 +102,7 @@ window.options = {
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData)
- eventHub.$emit('add-switch', edgeData)
+ eventHub.emit('add-relationship-link', edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
From 5d995115babc03b5a476b046e8117db5f0f1e935 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 12:40:22 +0100
Subject: [PATCH 048/227] visgraph: only addEdge for person to person
---
.../Resources/public/vuejs/VisGraph/i18n.js | 2 +-
.../Resources/public/vuejs/VisGraph/store.js | 4 +--
.../public/vuejs/VisGraph/vis-network.js | 31 ++++++++++++++++---
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 5b408e209..609299cfe 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -20,7 +20,7 @@ const visMessages = {
editNode: 'Éditer un noeuds',
editEdge: 'Éditer un lien',
addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
- edgeDescription: 'Cliquez sur un nœud et faites glisser le lien vers un autre nœud pour les connecter.',
+ edgeDescription: 'Cliquez sur un usager et faites glisser le lien vers un autre usager pour les connecter.',
editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 066b7c1dc..772af6630 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, splitId } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -235,7 +235,7 @@ const store = createStore({
commit('addLink', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
- id: `p${p.person.id}-c`+ course.id.split('_')[2],
+ id: `p${p.person.id}-c`+ splitId(course.id,'id'),
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 086608e19..b13f9ac32 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -100,9 +100,14 @@ window.options = {
callback(nodeData)
},
addEdge: function(edgeData, callback) {
- console.log('addEdge', edgeData)
- callback(edgeData)
- eventHub.emit('add-relationship-link', edgeData)
+ if (
+ splitId(edgeData.from,'type') === 'person'
+ && splitId(edgeData.to,'type') === 'person'
+ ) {
+ console.log('addEdge', edgeData)
+ eventHub.emit('add-relationship-link', edgeData)
+ callback(edgeData)
+ }
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
@@ -309,10 +314,28 @@ const getRelationshipTitle = (relationship) => {
+ relationship.toPerson.text
}
+/**
+ * Split string id and return type|id substring
+ * @param id
+ * @param position
+ * @returns string
+ */
+const splitId = (id, position) => {
+ switch (position) {
+ case 'type':
+ return /(.+)_/.exec(id)[1] // return 'accompanying_period'
+ case 'id':
+ return id.split("_").pop() // return '124'
+ default:
+ throw 'position undefined'
+ }
+}
+
export {
adapt2vis,
getHouseholdLabel,
getHouseholdWidth,
getRelationshipLabel,
- getRelationshipTitle
+ getRelationshipTitle,
+ splitId
}
From d3a08149f0f12886cef414b2a25d12df5f927c73 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 13:31:58 +0100
Subject: [PATCH 049/227] visgraph: open vue modal when adding/editing edge
---
.../Resources/public/vuejs/VisGraph/App.vue | 45 ++++++++++++++++---
.../public/vuejs/VisGraph/vis-network.js | 20 ++++++---
2 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 5bd654bd5..ffe73a7ab 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -4,7 +4,6 @@
@@ -147,8 +147,8 @@ export default {
container: '',
checkedLayers: [],
relations: [],
- relation: null,
- reverse: false,
+ //relation: null,
+ //reverse: false,
displayHelpMessage: false,
listenPersonFlag: 'normal',
newEdgeData: {},
@@ -157,7 +157,13 @@ export default {
modalDialogClass: "modal-md",
title: null,
action: null,
- data: {},
+ data: {
+ type: 'relationship',
+ from: null,
+ to: null,
+ relation: null,
+ reverse: false
+ },
button: {
class: null,
text: null
@@ -216,26 +222,24 @@ export default {
},
- /*
relation: {
get() {
- return this.relation
+ return this.modal.data.relation
},
set(value) {
- //console.log('setter relation', value) // <=== InternalError: too much recursion
- this.relation = value
+ this.modal.data.relation = value
}
},
reverse: {
get() {
- return this.reverse
+ return this.modal.data.reverse
},
- set(newValue) {
- //console.log('setter reverse', newValue) // <=== InternalError: too much recursion
- this.reverse = newValue
+ set(value) {
+ this.modal.data.reverse = value
}
},
+ /*
*/
},
@@ -377,8 +381,9 @@ export default {
/// control Modal
addRelationshipModal(edgeData) {
- this.modal.data = edgeData
- console.log('==- addRelationshipModal', edgeData) // { from: "person_1617", to: "person_1614" }
+ console.log('==- addRelationshipModal', edgeData)
+ this.modal.data.from = edgeData.from
+ this.modal.data.to = edgeData.to
this.modal.action = 'create'
this.modal.title = 'visgraph.add_relationship_link'
this.modal.button.class = 'btn-create'
@@ -410,7 +415,13 @@ export default {
resetForm() {
console.log('==- reset Form')
- this.modal.data = {}
+ this.modal.data = {
+ type: 'relationship',
+ from: null,
+ to: null,
+ relation: null,
+ reverse: false
+ }
this.modal.action = null
this.modal.title = null
this.modal.button.class = null
@@ -428,6 +439,7 @@ export default {
//console.log('customLabel', value)
return (value.title && value.reverseTitle) ? `${value.title.fr} ↔ ${value.reverseTitle.fr}` : ''
},
+
getPerson(idtext) {
let person = this.persons.filter(p => p.id === idtext)
return person[0]
@@ -439,8 +451,9 @@ export default {
console.log(' @@> switch listener to create link mode:', this.listenPersonFlag)
},
dropRelationship() {
- console.log('delete')
- deleteRelationship(relationship) /// param ?
+ console.log('delete', this.modal.data)
+ deleteRelationship(this.modal.data)
+ this.$store.commit('removeLink', this.modal.data.id)
this.modal.showModal = false
this.resetForm()
},
@@ -449,9 +462,7 @@ export default {
switch (this.modal.action) {
case 'create':
- return postRelationship(
- this.getPerson(this.modal.data.from), this.getPerson(this.modal.data.to), this.relation, this.reverse
- )
+ return postRelationship(this.modal.data)
.then(relationship => new Promise(resolve => {
console.log('post response', relationship)
this.$store.dispatch('addLinkFromRelationship', relationship)
@@ -462,10 +473,10 @@ export default {
.catch()
case 'edit':
- return patchRelationship(relationship)
+ return patchRelationship(this.modal.data)
.then(relationship => new Promise(resolve => {
console.log('patch relationship', relationship)
- this.$store.dispatch('updateLinkFromRelationship', relationship)
+ this.$store.commit('updateLink', relationship)
this.modal.showModal = false
this.resetForm()
resolve()
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 024486a07..2035c8e1e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -1,3 +1,5 @@
+import { splitId } from './vis-network'
+
/**
* @function makeFetch
* @param method
@@ -130,21 +132,19 @@ const getRelationsList = () => {
/**
* @function postRelationship
- * @param fromPerson
- * @param toPerson
- * @param relation
- * @param reverse
+ * @param relationship
* @returns {Promise}
*/
-const postRelationship = (fromPerson, toPerson, relation, reverse) => {
+const postRelationship = (relationship) => {
+ console.log(relationship)
return postFetch(
`/api/1.0/relations/relationship.json`,
{
type: 'relationship',
- fromPerson: { type: 'person', id: fromPerson._id },
- toPerson: { type: 'person', id: toPerson._id },
- relation: { type: 'relation', id: relation.id },
- reverse: reverse
+ fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
+ toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
+ relation: { type: 'relation', id: relationship.relation.id },
+ reverse: relationship.reverse
}
)
}
@@ -156,12 +156,14 @@ const postRelationship = (fromPerson, toPerson, relation, reverse) => {
*/
const patchRelationship = (relationship) => {
console.log(relationship)
+ let linkType = splitId(relationship.id, 'link')
+ let id = splitId(linkType, 'id')
return patchFetch(
- `/api/1.0/relations/relationship/${relationship.id}.json`,
+ `/api/1.0/relations/relationship/${id}.json`,
{
type: 'relationship',
- fromPerson: { type: 'person', id: relationship.fromPerson.id },
- toPerson: { type: 'person', id: relationship.toPerson.id },
+ fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
+ toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
relation: { type: 'relation', id: relationship.relation.id },
reverse: relationship.reverse
}
@@ -174,8 +176,11 @@ const patchRelationship = (relationship) => {
* @returns {Promise}
*/
const deleteRelationship = (relationship) => {
+ console.log(relationship)
+ let linkType = splitId(relationship.id, 'link')
+ let id = splitId(linkType, 'id')
return deleteFetch(
- `/api/1.0/relations/relationship/${relationship.id}.json`
+ `/api/1.0/relations/relationship/${id}.json`
)
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 98f188fdf..1cdd472d8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -160,6 +160,30 @@ const store = createStore({
addLink(state, link) {
state.links.push(link)
},
+ updateLink(state, link) {
+ console.log('updateLink', link)
+ let link_ = {
+ from: `person_${link.fromPerson.id}`,
+ to: `person_${link.toPerson.id}`,
+ id: 'relationship_' + splitId(link.id,'id')
+ + '-person_' + link.fromPerson.id + '-person_' + link.toPerson.id,
+ arrows: getRelationshipDirection(link),
+ color: 'lightblue',
+ font: { color: '#33839d' },
+ dashes: true,
+ label: getRelationshipLabel(link),
+ title: getRelationshipTitle(link),
+ relation: link.relation,
+ reverse: link.reverse
+ }
+ // find row position and replace by updatedLink
+ state.links.splice(
+ state.links.findIndex(item => item.id === link_.id), 1, link_
+ )
+ },
+ removeLink(state, link_id) {
+ state.links = state.links.filter(l => l.id !== link_id)
+ },
//// id markers
markInWhitelist(state, person) {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 011f83977..98ea88fb5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -266,13 +266,12 @@ const getRelationshipTitle = (relationship) => {
* @param position
* @returns string|integer
*/
-const splitId = (id, position) => {
+const splitId = (id, position) => { console.log(id, position)
switch (position) {
case 'type': // return 'accompanying_period'
return /(.+)_/.exec(id)[1]
case 'id': // return 124
- return parseInt(id
- .toString()
+ return parseInt(id.toString()
.split("_")
.pop())
case 'link':
From bfca6d2afc549b73626666e925742e1efa44652f Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 9 Nov 2021 19:58:04 +0100
Subject: [PATCH 118/227] cleaning
---
.../Resources/public/vuejs/VisGraph/App.vue | 30 ++++---------------
.../Resources/public/vuejs/VisGraph/api.js | 6 ++--
.../Resources/public/vuejs/VisGraph/store.js | 7 ++---
.../public/vuejs/VisGraph/vis-network.js | 3 +-
4 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index d21f21446..312b5d722 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -82,10 +82,8 @@
-
+
@@ -108,10 +107,6 @@
>
{{ $t('visgraph.reverse_relation') }}
-
@@ -147,8 +142,6 @@ export default {
container: '',
checkedLayers: [],
relations: [],
- //relation: null,
- //reverse: false,
displayHelpMessage: false,
listenPersonFlag: 'normal',
newEdgeData: {},
@@ -218,9 +211,11 @@ export default {
return this.checkedLayers
},
+ /*
toggleIdPerson() {
-
+ console.log('toggleIdPerson')
},
+ */
relation: {
get() {
@@ -239,8 +234,6 @@ export default {
this.modal.data.reverse = value
}
},
- /*
- */
},
mounted() {
@@ -394,24 +387,13 @@ export default {
this.modal.data = edgeData
this.relation = this.modal.data.relation
this.reverse = this.modal.data.reverse
- console.log('==- editRelationshipModal', this.modal.data, this.relation, this.reverse)
+ console.log('==- editRelationshipModal', this.modal.data)
this.modal.action = 'edit'
this.modal.title = 'visgraph.edit_relationship_link'
this.modal.button.class = 'btn-edit'
this.modal.button.text = 'action.edit'
this.modal.showModal = true
},
- /*
- deleteRelationshipModal(edgeData) {
- this.modal.data = edgeData
- console.log('==- deleteRelationshipModal', edgeData)
- this.modal.action = 'delete'
- this.modal.title = 'visgraph.delete_relationship_link'
- this.modal.button.class = 'btn-delete'
- this.modal.button.text = 'action.delete'
- this.modal.showModal = true
- },
- */
resetForm() {
console.log('==- reset Form')
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 2035c8e1e..448ff6633 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -136,7 +136,7 @@ const getRelationsList = () => {
* @returns {Promise}
*/
const postRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
return postFetch(
`/api/1.0/relations/relationship.json`,
{
@@ -155,7 +155,7 @@ const postRelationship = (relationship) => {
* @returns {Promise}
*/
const patchRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
let linkType = splitId(relationship.id, 'link')
let id = splitId(linkType, 'id')
return patchFetch(
@@ -176,7 +176,7 @@ const patchRelationship = (relationship) => {
* @returns {Promise}
*/
const deleteRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
let linkType = splitId(relationship.id, 'link')
let id = splitId(linkType, 'id')
return deleteFetch(
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 1cdd472d8..edde88f1f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -71,7 +71,7 @@ const store = createStore({
//console.log(link.id, state.excludedNodesIds.indexOf(splitId(link.id, 'link')))
}
})
- console.log(array.length, array.map(i => i.id))
+ console.log('count links', array.length, array.map(i => i.id))
return array.length
},
@@ -120,9 +120,8 @@ const store = createStore({
mutations: {
addPerson(state, [person, options]) {
let debug = ''
- /// Debug mode ~ display person_id on visgraph
- // uncomment
- debug = `\nid ${person.id}`
+ /// Debug mode: uncomment to display person_id on visgraph
+ //debug = `\nid ${person.id}`
person.group = person.type
person._id = person.id
person.id = `person_${person.id}`
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 98ea88fb5..cf3dc1baa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -266,7 +266,8 @@ const getRelationshipTitle = (relationship) => {
* @param position
* @returns string|integer
*/
-const splitId = (id, position) => { console.log(id, position)
+const splitId = (id, position) => {
+ //console.log(id, position)
switch (position) {
case 'type': // return 'accompanying_period'
return /(.+)_/.exec(id)[1]
From a63e1321b0f7ac65e06676a77dc729e390e4a4e8 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 9 Nov 2021 22:48:29 +0100
Subject: [PATCH 119/227] cleaning
---
.../Resources/public/vuejs/VisGraph/App.vue | 60 ++++++++-----------
.../Resources/public/vuejs/VisGraph/store.js | 4 +-
.../public/vuejs/VisGraph/vis-network.js | 12 ++--
3 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 312b5d722..3cd3de56d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -5,7 +5,7 @@
@@ -95,7 +95,7 @@
{%- if options['addAge'] -%}
- ({{ 'years_old'|trans({ 'age': person.age }) }})
+ {{- 'years_old'|trans({ 'age': person.age }) -}}
{%- endif -%}
{%- endif -%}
From 5606b714cdbb2c6e10232bd65ce2189bbb442649 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Thu, 11 Nov 2021 13:38:32 +0100
Subject: [PATCH 124/227] changelog updated
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c85f102b..4c8fecc02 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@ and this project adheres to
* [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
+* [person]: double parentheses removed around age in banner + whitespace
### Test release 2021-10-27
From 96b44ede3c51485e735b492c9aed453f7ecb8892 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Thu, 11 Nov 2021 16:56:26 +0100
Subject: [PATCH 125/227] information about creation and update displayed on
person detail page. Vendee person and mineur still to do
---
.../translations/messages.fr.yml | 2 +-
.../ChillPersonBundle/Entity/Person.php | 22 ++++++++++++++++---
.../Resources/public/chill/chillperson.scss | 7 +++++-
.../Resources/views/Person/view.html.twig | 15 +++++++++++++
4 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
index 7737e1d04..e04b9f43a 100644
--- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
@@ -37,7 +37,7 @@ Choose an user: Choisir un utilisateur
No value: Aucune information
Last updated by: Dernière mise à jour par
Last updated on: Dernière mise à jour le
-on: le
+on: "le "
Edit: Modifier
Update: Mettre à jour
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 5e521b60a..86a1d9bc8 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -50,6 +50,7 @@ use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint;
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential;
+use DateTimeInterface;
/**
* Person Class
@@ -390,19 +391,19 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
*/
- private \DateTimeInterface $createdAt;
+ private $createdAt;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*/
- private User $updatedBy;
+ private $updatedBy;
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
*/
- private \DateTimeInterface $updatedAt;
+ private $updatedAt;
/**
* @var boolean
@@ -1823,6 +1824,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
+ public function getCreatedAt(): ?DateTimeInterface
+ {
+ return $this->createdAt;
+ }
+
public function setCreatedAt(\DateTimeInterface $datetime): self
{
$this->createdAt = $datetime;
@@ -1830,6 +1836,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
+ public function getUpdatedBy(): ?User
+ {
+ return $this->updatedBy;
+ }
+
+ public function getUpdatedAt(): ?DateTimeInterface
+ {
+ return $this->updatedAt;
+ }
+
public function setUpdatedBy(User $user): self
{
$this->updatedBy = $user;
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss
index 2e5821659..6c9687ff9 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss
+++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss
@@ -237,8 +237,13 @@ abbr.referrer { // still used ?
align-self: center; // in flex context
}
-.updatedBy {
+.updatedBy, .createdBy {
margin-top: 0.3rem;
font-size: 0.9rem;
font-style: italic;
}
+
+.created-updated {
+ border: 1px solid black;
+ padding: 10px;
+}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
index 0351d0ba1..807a0d894 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
@@ -259,6 +259,21 @@ This view should receive those arguments:
{% endif %}
+
+ {% if person.createdBy %}
+
+ {{ 'Created by'|trans}}: {{ person.createdBy|chill_entity_render_box }} ,
+ {{ 'on'|trans ~ person.createdAt|format_datetime('long', 'short') }}
+
+ {% endif %}
+ {% if person.updatedBy %}
+
+ {{ 'Last updated by'|trans}}: {{ person.updatedBy|chill_entity_render_box }} ,
+ {{ 'on'|trans ~ person.updatedAt|format_datetime('long', 'short') }}
+
+ {% endif %}
+
+
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
+
+ {% endif %}
+ {% endif %}
{%- if chill_person.fields.contact_info == 'visible' -%}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index af3ca6f05..64873d2ba 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -50,6 +50,8 @@ mobilenumber: numéro de téléphone portable
Accept short text message ?: La personne a donné l'autorisation d'utiliser ce no de téléphone pour l'envoi de rappel par SMS
Accept short text message: La personne a donné l'autorisation d'utiliser ce no de téléphone pour l'envoi de rappel par SMS
Other phonenumber: Autre numéro de téléphone
+Others phone numbers: Autres numéros de téléphone
+No additional phone numbers: Aucun numéro de téléphone supplémentaire
Description: description
Add new phone: Ajouter un numéro de téléphone
Remove phone: Supprimer
From a7dd15a411538d9e4fc59511a6c03bb316abad7b Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 11:09:02 +0100
Subject: [PATCH 128/227] upd CHANGELOG
---
CHANGELOG.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c8fecc02..5c9adc9cb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,8 +11,7 @@ and this project adheres to
## Unreleased
-
-
+* [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)
## Test releases
From eedf5f25bd9e3ca4f857548d5f0374a1da0edc23 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 12:00:39 +0100
Subject: [PATCH 129/227] accompanying course work: translation
---
.../Resources/views/AccompanyingCourseWork/delete.html.twig | 2 +-
src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/delete.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/delete.html.twig
index 2b47adc93..c66e5aa3d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/delete.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/delete.html.twig
@@ -26,7 +26,7 @@
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'accompanying_course_work.remove'|trans,
- 'confirm_question' : 'Are you sure you want to remove the work of the accompanying period %name% ?'|trans({ '%name%' : accompanyingCourse.id } ),
+ 'confirm_question' : 'Are you sure you want to remove this work of the accompanying period %name% ?'|trans({ '%name%' : accompanyingCourse.id } ),
'cancel_route' : 'chill_person_accompanying_period_work_list',
'cancel_parameters' : {'id' : accompanyingCourse.id},
'form' : delete_form
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index 0a720af3e..ef8e58bb1 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -405,7 +405,7 @@ Back to household: Revenir au ménage
# accompanying course work
Accompanying Course Actions: Actions d'accompagnements
Accompanying Course Action: Action d'accompagnement
-Are you sure you want to remove the work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer l'action de la période d'accompagnement %name% ?
+Are you sure you want to remove this work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer cette action de la période d'accompagnement %name% ?
The accompanying period work has been successfully removed.: L'action d'accompagnement a été supprimée.
accompanying_course_work:
create: Créer une action
From 32c2d96ab620c261a5e156eeec8ba142d55cc112 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 12:02:45 +0100
Subject: [PATCH 130/227] accompanying course work: add cascade remove on
delete Accompanying Period Work
---
.../Entity/AccompanyingPeriod/AccompanyingPeriodWork.php | 2 +-
.../AccompanyingPeriodWorkEvaluationDocument.php | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
index 39aaf309b..8ae4212cc 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
@@ -167,7 +167,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
* mappedBy="accompanyingPeriodWork",
- * cascade={"persist"},
+ * cascade={"remove"},
* orphanRemoval=true
* )
* @Serializer\Groups({"read"})
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
index eb07cd4d8..1dfaef99c 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php
@@ -70,7 +70,8 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
/**
* @ORM\ManyToOne(
- * targetEntity=StoredObject::class
+ * targetEntity=StoredObject::class,
+ * cascade={"remove"},
* )
* @Serializer\Groups({"read"})
*/
From fcbf1bd5587b49b80cf02687af28bd45d421a49c Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 12:10:27 +0100
Subject: [PATCH 131/227] accompanying course work: missing translation in
App.vue
---
.../Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue
index 3be3c57e2..7931a2a0d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue
@@ -72,7 +72,7 @@
{{ $t('action.save') }}
- {{ $t('Save') }}
+ {{ $t('action.save') }}
From 28afe5228a47c1e1d1852c2fae109ccb641e6712 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 12:14:55 +0100
Subject: [PATCH 132/227] upd CHANGELOG
---
CHANGELOG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fad2c948..c899353f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,9 @@ and this project adheres to
+* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36)
+
+
* [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
From 22bdf35eb0e7b2d902ed31e25ce2b13c814e4b34 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 12 Nov 2021 12:05:16 +0000
Subject: [PATCH 133/227] minor fixes
---
.../Controller/AccompanyingCourseWorkController.php | 2 +-
.../Entity/AccompanyingPeriod/AccompanyingPeriodWork.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
index cf8e5cab0..3625c7cca 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
@@ -29,7 +29,7 @@ class AccompanyingCourseWorkController extends AbstractController
SerializerInterface $serializer,
AccompanyingPeriodWorkRepository $workRepository,
PaginatorFactory $paginator,
- LoggerInterface $logger
+ LoggerInterface $chillLogger
) {
$this->trans = $trans;
$this->serializer = $serializer;
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
index 8ae4212cc..58b27d95d 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php
@@ -167,7 +167,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
* mappedBy="accompanyingPeriodWork",
- * cascade={"remove"},
+ * cascade={"remove", "persist"},
* orphanRemoval=true
* )
* @Serializer\Groups({"read"})
From c8135e074189269fc1ac4a706084af86511ef1ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 12 Nov 2021 12:07:31 +0000
Subject: [PATCH 134/227] add validation to accompanying periods
---
.../Tests/Util/DateRangeCoveringTest.php | 12 ++++
.../Util/DateRangeCovering.php | 61 ----------------
.../AccompanyingCourseApiController.php | 15 +++-
.../ORM/LoadAccompanyingPeriodOrigin.php | 2 +-
.../DataFixtures/ORM/LoadPeople.php | 4 +-
.../Entity/AccompanyingPeriod.php | 38 +++++++++-
.../Entity/AccompanyingPeriod/Resource.php | 8 ++-
.../AccompanyingPeriodParticipation.php | 7 ++
.../public/vuejs/AccompanyingCourse/App.vue | 17 ++---
.../public/vuejs/AccompanyingCourse/api.js | 3 +-
.../components/OriginDemand.vue | 16 ++---
.../public/vuejs/AccompanyingCourse/index.js | 3 +
.../vuejs/AccompanyingCourse/store/index.js | 2 +-
.../AccompanyingPeriod/LocationValidity.php | 2 +-
.../ParticipationOverlap.php | 15 ++++
.../ParticipationOverlapValidator.php | 72 +++++++++++++++++++
.../ResourceDuplicateCheck.php | 16 +++++
.../ResourceDuplicateCheckValidator.php | 56 +++++++++++++++
.../config/services/validator.yaml | 6 ++
.../migrations/Version20211020131133.php | 31 ++++++++
.../migrations/Version20211021125359.php | 36 ++++++++++
.../translations/validators.fr.yml | 3 +
22 files changed, 337 insertions(+), 88 deletions(-)
create mode 100644 src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php
create mode 100644 src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
create mode 100644 src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php
create mode 100644 src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php
create mode 100644 src/Bundle/ChillPersonBundle/config/services/validator.yaml
create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php
create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php
diff --git a/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php b/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php
index c06b4a4f4..18af61849 100644
--- a/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Util/DateRangeCoveringTest.php
@@ -37,6 +37,18 @@ class DateRangeCoveringTest extends TestCase
$this->assertNotContains(3, $cover->getIntersections()[0][2]);
}
+ public function testCoveringWithMinCover1_NoCoveringWithNullDates()
+ {
+ $cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
+ $cover
+ ->add(new \DateTime('2021-10-05'), new \DateTime('2021-10-18'), 521)
+ ->add(new \DateTime('2021-10-26'), null, 663)
+ ->compute()
+ ;
+
+ $this->assertFalse($cover->hasIntersections());
+ }
+
public function testCoveringWithMinCover1WithTwoIntersections()
{
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
diff --git a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php
index a10ebb883..3eb6d1433 100644
--- a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php
+++ b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php
@@ -140,67 +140,6 @@ class DateRangeCovering
return $this;
}
- private function process(array $intersections): array
- {
- $result = [];
- $starts = [];
- $ends = [];
- $metadatas = [];
-
- while (null !== ($current = \array_pop($intersections))) {
- list($cStart, $cEnd, $cMetadata) = $current;
- $n = count($cMetadata);
-
- foreach ($intersections as list($iStart, $iEnd, $iMetadata)) {
- $start = max($cStart, $iStart);
- $end = min($cEnd, $iEnd);
-
- if ($start <= $end) {
- if (FALSE !== ($key = \array_search($start, $starts))) {
- if ($ends[$key] === $end) {
- $metadatas[$key] = \array_unique(\array_merge($metadatas[$key], $iMetadata));
- continue;
- }
- }
- $starts[] = $start;
- $ends[] = $end;
- $metadatas[] = \array_unique(\array_merge($iMetadata, $cMetadata));
- }
- }
- }
-
- // recompose results
- foreach ($starts as $k => $start) {
- $result[] = [$start, $ends[$k], \array_unique($metadatas[$k])];
- }
-
- return $result;
- }
-
- private function addToIntersections(array $intersections, array $intersection)
- {
- $foundExisting = false;
- list($nStart, $nEnd, $nMetadata) = $intersection;
-
- \array_walk($intersections,
- function(&$i, $key) use ($nStart, $nEnd, $nMetadata, $foundExisting) {
- if ($foundExisting) {
- return;
- };
- if ($i[0] === $nStart && $i[1] === $nEnd) {
- $foundExisting = true;
- $i[2] = \array_merge($i[2], $nMetadata);
- }
- }
- );
-
- if (!$foundExisting) {
- $intersections[] = $intersection;
- }
-
- return $intersections;
- }
-
public function hasIntersections(): bool
{
if (!$this->computed) {
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index bce888876..ba033f562 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -54,10 +54,14 @@ class AccompanyingCourseApiController extends ApiController
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
$this->checkACL('confirm', $request, $_format, $accompanyingPeriod);
-$workflow = $this->registry->get($accompanyingPeriod);
+ $workflow = $this->registry->get($accompanyingPeriod);
if (FALSE === $workflow->can($accompanyingPeriod, 'confirm')) {
- throw new BadRequestException('It is not possible to confirm this period');
+ // throw new BadRequestException('It is not possible to confirm this period');
+ $errors = $this->validator->validate($accompanyingPeriod, null, [$accompanyingPeriod::STEP_CONFIRMED]);
+ if( count($errors) > 0 ){
+ return $this->json($errors, 422);
+ }
}
$workflow->apply($accompanyingPeriod, 'confirm');
@@ -109,6 +113,13 @@ $workflow = $this->registry->get($accompanyingPeriod);
public function resourceApi($id, Request $request, string $_format): Response
{
+ $accompanyingPeriod = $this->getEntity('resource', $id, $request);
+ $errors = $this->validator->validate($accompanyingPeriod);
+
+ if ($errors->count() > 0) {
+ return $this->json($errors, 422);
+ }
+
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
}
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php
index cbec9c439..eef8d7b47 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php
@@ -40,7 +40,7 @@ class LoadAccompanyingPeriodOrigin extends AbstractFixture implements OrderedFix
public function getOrder()
{
- return 10005;
+ return 9000;
}
private $phoneCall = ['en' => 'phone call', 'fr' => 'appel téléphonique'];
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
index adc37d5b5..b9b0b4946 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
@@ -247,7 +247,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
if (\random_int(0, 10) > 3) {
// always add social scope:
$accompanyingPeriod->addScope($this->getReference('scope_social'));
-
+ $origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN);
+ $accompanyingPeriod->setOrigin($origin);
+ $accompanyingPeriod->setIntensity('regular');
$accompanyingPeriod->setAddressLocation($this->createAddress());
$manager->persist($accompanyingPeriod->getAddressLocation());
$workflow = $this->workflowRegistry->get($accompanyingPeriod);
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index 9ad0c75dd..dab1dcb9d 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -45,6 +45,9 @@ use Chill\MainBundle\Entity\User;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Component\Validator\GroupSequenceProviderInterface;
+use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
+use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
/**
* AccompanyingPeriod Class
@@ -54,9 +57,10 @@ use Symfony\Component\Validator\Constraints as Assert;
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period"=AccompanyingPeriod::class
* })
+ * @Assert\GroupSequenceProvider
*/
class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface,
- HasScopesInterface, HasCentersInterface
+ HasScopesInterface, HasCentersInterface, GroupSequenceProviderInterface
{
/**
* Mark an accompanying period as "occasional"
@@ -132,6 +136,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
+ * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT})
*/
private $comments;
@@ -147,9 +152,10 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* @var Collection
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
- * mappedBy="accompanyingPeriod",
+ * mappedBy="accompanyingPeriod", orphanRemoval=true,
* cascade={"persist", "refresh", "remove", "merge", "detach"})
* @Groups({"read"})
+ * @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*/
private $participations;
@@ -188,6 +194,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* @ORM\ManyToOne(targetEntity=Origin::class)
* @ORM\JoinColumn(nullable=true)
* @Groups({"read", "write"})
+ * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private $origin;
@@ -195,8 +202,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* @var string
* @ORM\Column(type="string", nullable=true)
* @Groups({"read", "write"})
+ * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
- private $intensity;
+ private $intensity = self::INTENSITY_OCCASIONAL;
/**
* @var Collection
@@ -210,6 +218,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
* )
* @Groups({"read"})
+ * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private $scopes;
@@ -256,6 +265,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* orphanRemoval=true
* )
* @Groups({"read"})
+ * @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"})
*/
private $resources;
@@ -267,6 +277,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* name="chill_person_accompanying_period_social_issues"
* )
* @Groups({"read"})
+ * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private Collection $socialIssues;
@@ -606,6 +617,14 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
return $participation;
}
+ /**
+ * Remove Participation
+ */
+
+ public function removeParticipation(AccompanyingPeriodParticipation $participation)
+ {
+ $participation->setAccompanyingPeriod(null);
+ }
/**
* Remove Person
@@ -1115,4 +1134,17 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
return $centers ?? null;
}
+
+ public function getGroupSequence()
+ {
+ if($this->getStep() == self::STEP_DRAFT)
+ {
+ return [[self::STEP_DRAFT]];
+ }
+
+ if($this->getStep() == self::STEP_CONFIRMED)
+ {
+ return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
+ }
+ }
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php
index a50e28621..48e532e10 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php
@@ -33,7 +33,13 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
- * @ORM\Table(name="chill_person_accompanying_period_resource")
+ * @ORM\Table(
+ * name="chill_person_accompanying_period_resource",
+ * uniqueConstraints={
+ * @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
+ * @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
+ * }
+ * )
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_resource"=Resource::class
* })
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php
index c873e527a..f246c25bd 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php
@@ -134,4 +134,11 @@ class AccompanyingPeriodParticipation
{
return $this->endDate === null;
}
+
+ private function checkSameStartEnd()
+ {
+ if($this->endDate == $this->startDate) {
+ $this->accompanyingPeriod->removeParticipation($this);
+ }
+ }
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
index 9c65137bd..ff77f77ce 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
@@ -16,16 +16,16 @@
-
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
index 52f3f6c36..c372ac7a7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
@@ -86,7 +86,8 @@ const postParticipation = (id, payload, method) => {
})
.then(response => {
if (response.ok) { return response.json(); }
- throw { msg: 'Error while sending AccompanyingPeriod Course participation.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
+ // TODO: adjust message according to status code? Or how to access the message from the violation array?
+ throw { msg: 'Error while sending AccompanyingPeriod Course participation', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
});
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
index 30001028c..30ad6afe0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
@@ -10,13 +10,13 @@
@@ -47,18 +47,18 @@ export default {
},
methods: {
getOptions() {
- //console.log('loading origins list');
getListOrigins().then(response => new Promise((resolve, reject) => {
this.options = response.results;
resolve();
}));
},
updateOrigin(value) {
- //console.log('value', value);
+ console.log('value', value);
this.$store.dispatch('updateOrigin', value);
},
transText ({ text }) {
- return text.fr //TODO multilang
+ const parsedText = JSON.parse(text);
+ return parsedText.fr;
},
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
index e3fdec4a3..ace482d79 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
@@ -2,6 +2,8 @@ import { createApp } from 'vue'
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { appMessages } from './js/i18n'
import { initPromise } from './store'
+import VueToast from 'vue-toast-notification';
+import 'vue-toast-notification/dist/theme-sugar.css';
import App from './App.vue';
import Banner from './components/Banner.vue';
@@ -21,6 +23,7 @@ if (root === 'app') {
})
.use(store)
.use(i18n)
+ .use(VueToast)
.component('app', App)
.mount('#accompanying-course');
});
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
index 9b69845cf..41e341dd8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
@@ -77,7 +77,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
},
mutations: {
catchError(state, error) {
- console.log('### mutation: a new error have been catched and pushed in store !', error);
+ // console.log('### mutation: a new error have been catched and pushed in store !', error);
state.errorMsg.push(error);
},
removeParticipation(state, participation) {
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php
index 75c10ca75..b1b660596 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php
@@ -11,7 +11,7 @@ class LocationValidity extends Constraint
{
public $messagePersonLocatedMustBeAssociated = "The person where the course is located must be associated to the course. Change course's location before removing the person.";
- public $messagePeriodMustRemainsLocated = "The period must remains located";
+ public $messagePeriodMustRemainsLocated = "The period must remain located";
public function getTargets()
{
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php
new file mode 100644
index 000000000..38d5516b5
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php
@@ -0,0 +1,15 @@
+getStartDate()->getTimezone());
+
+ foreach ($participations as $participation) {
+
+ if (!$participation instanceof AccompanyingPeriodParticipation) {
+ throw new UnexpectedTypeException($participation, AccompanyingPeriodParticipation::class);
+ }
+
+ $personId = $participation->getPerson()->getId();
+
+ $particpationList[$personId][] = $participation;
+
+ }
+
+ foreach ($particpationList as $group) {
+ if (count($group) > 1) {
+ foreach ($group as $p) {
+ $overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId());
+ }
+ }
+ }
+
+ $overlaps->compute();
+
+ if ($overlaps->hasIntersections()) {
+ foreach ($overlaps->getIntersections() as list($start, $end, $ids)) {
+ $msg = $end === null ? $constraint->message :
+ $constraint->message;
+
+ $this->context->buildViolation($msg)
+ ->setParameters([
+ '{{ start }}' => $start->format('d-m-Y'),
+ '{{ end }}' => $end === null ? null : $end->format('d-m-Y'),
+ '{{ ids }}' => $ids,
+ ])
+ ->addViolation();
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php
new file mode 100644
index 000000000..bfc9d62af
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php
@@ -0,0 +1,16 @@
+personRender = $personRender;
+ $this->thirdpartyRender = $thirdPartyRender;
+ }
+
+ public function validate($resources, Constraint $constraint)
+ {
+ if (!$constraint instanceof ResourceDuplicateCheck) {
+ throw new UnexpectedTypeException($constraint, ParticipationOverlap::class);
+ }
+
+ if (!$resources instanceof Collection) {
+ throw new UnexpectedTypeException($resources, Collection::class);
+ }
+
+ $resourceList = [];
+
+ foreach ($resources as $resource) {
+ $id = ($resource->getResource() instanceof Person ? 'p' :
+ 't').$resource->getResource()->getId();
+
+ if (\in_array($id, $resourceList, true)) {
+ $this->context->buildViolation($constraint->message)
+ ->setParameter('{{ name }}', $resource->getResource() instanceof Person ? $this->personRender->renderString($resource->getResource(), []) :
+ $this->thirdpartyRender->renderString($resource->getResource(), []))
+ ->addViolation();
+ }
+
+ $resourceList[] = $id;
+
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/config/services/validator.yaml b/src/Bundle/ChillPersonBundle/config/services/validator.yaml
new file mode 100644
index 000000000..435f2f5b5
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/config/services/validator.yaml
@@ -0,0 +1,6 @@
+services:
+ Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod:
+ autowire: true
+ autoconfigure: true
+ tags: ['validator.service_arguments']
+
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php b/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php
new file mode 100644
index 000000000..031356cd3
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php
@@ -0,0 +1,31 @@
+addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE person_id IS NOT NULL');
+ $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE thirdparty_id IS NOT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('DROP INDEX person_unique');
+ $this->addSql('DROP INDEX thirdparty_unique');
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php b/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php
new file mode 100644
index 000000000..a4ed54254
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php
@@ -0,0 +1,36 @@
+addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT '.
+ "participations_no_overlap EXCLUDE USING GIST(
+ -- extension btree_gist required to include comparaison with integer
+ person_id WITH =, accompanyingperiod_id WITH =,
+ daterange(startdate, enddate) WITH &&
+ )
+ INITIALLY DEFERRED");
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('CREATE UNIQUE INDEX participation_unique ON chill_person_accompanying_period_participation (accompanyingperiod_id, person_id)');
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml
index 0e77dae0c..6d2ccb3cb 100644
--- a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml
@@ -41,3 +41,6 @@ household:
household_membership:
The end date must be after start date: La date de la fin de l'appartenance doit être postérieure à la date de début.
Person with membership covering: Une personne ne peut pas appartenir à deux ménages simultanément. Or, avec cette modification, %person_name% appartiendrait à %nbHousehold% ménages à partir du %from%.
+
+# Accompanying period
+'{{ name }} is already associated to this accompanying course.': '{{ name }} est déjà associé avec ce parcours.'
\ No newline at end of file
From 2b0093a351d8cd01c8b3c8f80d95018ae1af0fd7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 12 Nov 2021 12:08:48 +0000
Subject: [PATCH 135/227] fix typo
---
src/Bundle/ChillMainBundle/translations/messages.fr.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
index 7f7801805..082e4c83f 100644
--- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
@@ -74,7 +74,7 @@ Choose a postal code: Choisir un code postal
address:
address_homeless: L'adresse est-elle celle d'un domicile fixe ?
real address: Adresse d'un domicile
- consider homeless: Cette addresse est incomplète
+ consider homeless: Cette adresse est incomplète
address more:
floor: ét
corridor: coul
From a04c499af0ca24530fd1ace9027e945adbf4a505 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 16:01:03 +0100
Subject: [PATCH 136/227] fix when adding multiple pick address type form in a
collection
---
.../Resources/public/vuejs/Address/mod_input_address_index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js
index 0f39c5e75..cb7da6e07 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js
@@ -6,12 +6,12 @@ import App from './App.vue';
const i18n = _createI18n(addressMessages);
const addAddressInput = (inputs) => {
-
+ console.log(inputs)
inputs.forEach(el => {
let
addressId = el.value,
uniqid = el.dataset.inputAddress,
- container = document.querySelector('div[data-input-address-container="' + uniqid + '"]'),
+ container = el.parentNode.querySelector('div[data-input-address-container="' + uniqid + '"]'),
isEdit = addressId !== '',
addressIdInt = addressId !== '' ? parseInt(addressId) : null
;
From e413a09a0f9256eb3319dd236a86152fba1fe9ee Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 12 Nov 2021 16:05:47 +0100
Subject: [PATCH 137/227] upd CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66de80f48..4661dcaa9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ and this project adheres to
## Unreleased
+* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection)
+
* 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.
From fa7409bdf85e48c856a29f3b95ca1a15cb5042d4 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 12 Nov 2021 15:18:41 +0100
Subject: [PATCH 138/227] visgraph: export canvas as image
---
.../Resources/public/vuejs/VisGraph/App.vue | 49 ++++++++++++++++---
1 file changed, 42 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 3f26eb13b..60db92628 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -8,9 +8,9 @@
{{ $t('visgraph.add_link') }}
-
+
{{ $t('visgraph.screenshot') }}
-
+
{{ $t('visgraph.refresh') }}
@@ -231,17 +231,17 @@ export default {
this.getRelationsList()
},
methods: {
- forceUpdateComponent() {
- //console.log('!! forceUpdateComponent !!')
- this.refreshNetwork
- this.$forceUpdate()
- },
initGraph() {
this.container = document.getElementById('visgraph')
// Instanciate vis objects in separate window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options)
},
+ forceUpdateComponent() {
+ //console.log('!! forceUpdateComponent !!')
+ this.refreshNetwork
+ this.$forceUpdate()
+ },
// events
listenOnGraph() {
@@ -444,6 +444,41 @@ export default {
default:
throw "uncaught action"
}
+ },
+
+ // export image
+ exportCanvasAsImage() {
+ const canvas = document.getElementById('visgraph')
+ .querySelector('canvas')
+ console.log(canvas)
+
+ let link = document.getElementById('exportCanvasBtn')
+ link.download = "filiation.png"
+
+ canvas.toBlob(blob => {
+ console.log(blob)
+ link.href = URL.createObjectURL(blob)
+ }, 'image/png')
+
+ /*
+ TODO improve feature
+
+ // 1. fonctionne, mais pas de contrôle sur le nom
+ if (canvas && canvas.getContext('2d')) {
+ let img = canvas.toDataURL('image/png;base64;')
+ img = img.replace('image/png','image/octet-stream')
+ window.open(img, '', 'width=1000, height=1000')
+ }
+
+ // 2. fonctionne, mais 2 click et pas compatible avec tous les browsers
+ let link = document.getElementById('exportCanvasBtn')
+ link.download = "image.png"
+ canvas.toBlob(blob => {
+ link.href = URL.createObjectURL(blob)
+ }, 'image/png')
+ */
+
+
}
}
}
From 5651efe44d3847d8c1ec8c4e4dd4d68df58db21f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Fri, 12 Nov 2021 17:50:12 +0100
Subject: [PATCH 139/227] fix phpstan errors
---
phpstan-baseline.neon | 5 -----
.../Controller/AccompanyingCourseWorkController.php | 7 ++++---
.../ChillPersonBundle/Entity/AccompanyingPeriod.php | 9 +++++----
.../AccompanyingPeriod/ParticipationOverlapValidator.php | 9 +++++----
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index e578c1d45..d2128437a 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -905,11 +905,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Util/DateRangeCovering.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
index 3625c7cca..cf935b7c3 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
@@ -22,7 +22,7 @@ class AccompanyingCourseWorkController extends AbstractController
private SerializerInterface $serializer;
private AccompanyingPeriodWorkRepository $workRepository;
private PaginatorFactory $paginator;
- protected LoggerInterface $logger;
+ private LoggerInterface $chillLogger;
public function __construct(
TranslatorInterface $trans,
@@ -35,7 +35,7 @@ class AccompanyingCourseWorkController extends AbstractController
$this->serializer = $serializer;
$this->workRepository = $workRepository;
$this->paginator = $paginator;
- $this->logger = $logger;
+ $this->chillLogger = $chillLogger;
}
/**
@@ -133,7 +133,7 @@ class AccompanyingCourseWorkController extends AbstractController
if ($form->isValid()) {
- $this->logger->notice("An accompanying period work has been removed", [
+ $this->chillLogger->notice("An accompanying period work has been removed", [
'by_user' => $this->getUser()->getUsername(),
'work_id' => $work->getId(),
'accompanying_period_id' => $work->getAccompanyingPeriod()->getId()
@@ -162,6 +162,7 @@ class AccompanyingCourseWorkController extends AbstractController
private function createDeleteForm(int $id): Form
{
+ $params = [];
$params['id'] = $id;
return $this->createFormBuilder()
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index dab1dcb9d..6c9c84b56 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -1137,14 +1137,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
public function getGroupSequence()
{
- if($this->getStep() == self::STEP_DRAFT)
+ if ($this->getStep() == self::STEP_DRAFT)
{
return [[self::STEP_DRAFT]];
- }
-
- if($this->getStep() == self::STEP_CONFIRMED)
+ } elseif ($this->getStep() == self::STEP_CONFIRMED)
{
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
}
+
+ throw new \LogicException("no validation group permitted with this step");
+
}
}
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
index ef9868420..50c71998b 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php
@@ -30,6 +30,7 @@ class ParticipationOverlapValidator extends ConstraintValidator
}
$overlaps = new DateRangeCovering(self::MAX_PARTICIPATION, $participations[0]->getStartDate()->getTimezone());
+ $participationList = [];
foreach ($participations as $participation) {
@@ -38,12 +39,12 @@ class ParticipationOverlapValidator extends ConstraintValidator
}
$personId = $participation->getPerson()->getId();
-
- $particpationList[$personId][] = $participation;
+
+ $participationList[$personId][] = $participation;
}
- foreach ($particpationList as $group) {
+ foreach ($participationList as $group) {
if (count($group) > 1) {
foreach ($group as $p) {
$overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId());
@@ -69,4 +70,4 @@ class ParticipationOverlapValidator extends ConstraintValidator
}
}
-}
\ No newline at end of file
+}
From b07188eaaf04c2b79f24babbe151a02a52083058 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Mon, 15 Nov 2021 10:21:57 +0100
Subject: [PATCH 140/227] changelog updated
---
CHANGELOG.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c8fecc02..6c85f102b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,7 +44,6 @@ and this project adheres to
* [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
-* [person]: double parentheses removed around age in banner + whitespace
### Test release 2021-10-27
From 4ba93bb70996e0566658868e9822e43b588d08ad Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Mon, 15 Nov 2021 11:56:29 +0100
Subject: [PATCH 141/227] failed job personControllerUpdateTest fixed
---
.../Tests/Controller/PersonControllerUpdateTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
index 8a8c04538..6620a7c38 100644
--- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
+++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
@@ -259,7 +259,7 @@ class PersonControllerUpdateTest extends WebTestCase
return array(
['firstName', 'random Value', function(Person $person) { return $person->getFirstName(); } ],
['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ],
- ['placeOfBirth', 'none place', function(Person $person) { return $person->getPlaceOfBirth(); }],
+ ['placeOfBirth', 'NONE PLACE', function(Person $person) { return $person->getPlaceOfBirth(); }],
['birthdate', '1980-12-15', function(Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
['phonenumber', '+32123456789', function(Person $person) { return $person->getPhonenumber(); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }],
From 3417aa8207963cd7eae4b88bf09fc7fb9211fef3 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Mon, 15 Nov 2021 12:00:42 +0100
Subject: [PATCH 142/227] person: do not suggest the current household of the
person
---
.../Controller/HouseholdApiController.php | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php
index 11e41ba29..3f3e04cb3 100644
--- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php
@@ -47,13 +47,22 @@ class HouseholdApiController extends ApiController
$count = $this->householdRepository->countByAccompanyingPeriodParticipation($person);
$paginator = $this->getPaginatorFactory()->create($count);
- if ($count === 0) {
- $households = [];
- } else {
- $households = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
+ $households = [];
+ if ($count !== 0) {
+ $allHouseholds = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
- }
+ $currentHouseholdPerson = $person->getCurrentHousehold();
+ foreach ($allHouseholds as $h) {
+ if ($h !== $currentHouseholdPerson) {
+ array_push($households, $h);
+ }
+ }
+ if (null !== $currentHouseholdPerson) {
+ $count = $count - 1;
+ $paginator = $this->getPaginatorFactory()->create($count);
+ }
+ }
$collection = new Collection($households, $paginator);
return $this->json($collection, Response::HTTP_OK, [],
From bfc25c50b926905e5793081c659321335d7a81f1 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Mon, 15 Nov 2021 12:03:31 +0100
Subject: [PATCH 143/227] upd CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66de80f48..b2b969c66 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ and this project adheres to
## Unreleased
+* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51)
+
* 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.
From 8296d60cb6f86b75e542095f0bc7030151e40584 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 11:17:03 +0000
Subject: [PATCH 144/227] add base authorization to person search + improve
search ordering
---
CHANGELOG.md | 2 +
phpstan-baseline.neon | 20 ----
.../DataFixtures/ORM/LoadActivity.php | 29 +++---
.../config/services/fixtures.yaml | 2 +
.../DataFixtures/ORM/LoadCalendarRange.php | 13 ++-
.../DataFixtures/ORM/LoadDocumentACL.php | 14 +--
.../DataFixtures/ORM/LoadRolesACL.php | 20 ++--
.../ChillMainBundle/Search/SearchApi.php | 6 +-
.../ChillMainBundle/Search/SearchApiQuery.php | 57 +++++++----
.../Test/PrepareClientTrait.php | 1 -
.../Tests/Search/SearchApiQueryTest.php | 7 +-
.../AccompanyingCourseApiController.php | 10 +-
.../Helper/PersonRandomHelper.php | 40 ++++++++
.../DataFixtures/ORM/LoadPeople.php | 2 +-
.../DataFixtures/ORM/LoadRelations.php | 47 +++++----
.../DataFixtures/ORM/LoadRelationships.php | 44 +++++++--
.../Relationships/RelationRepository.php | 2 +-
.../Relationships/RelationshipRepository.php | 7 +-
.../Search/SearchPersonApiProvider.php | 46 ++++++++-
.../Controller/PersonControllerUpdateTest.php | 3 +-
.../RelationshipApiControllerTest.php | 95 +++++++++++++++----
.../config/services/fixtures.yaml | 1 +
22 files changed, 317 insertions(+), 151 deletions(-)
create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/Helper/PersonRandomHelper.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 875f8c34a..5139087a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,8 @@ and this project adheres to
* 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;
+
## Test releases
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index d2128437a..b88679016 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -10,16 +10,6 @@ parameters:
count: 4
path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
-
- -
- message: "#^Variable \\$activity might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -305,11 +295,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
@@ -325,11 +310,6 @@ parameters:
count: 3
path: src/Bundle/ChillEventBundle/Controller/ParticipationController.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
index a23b2d73f..18a6f83d3 100644
--- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
+++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
@@ -22,8 +22,10 @@
namespace Chill\ActivityBundle\DataFixtures\ORM;
+use Chill\PersonBundle\Entity\Person;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
use Faker\Factory as FakerFactory;
use Chill\ActivityBundle\Entity\Activity;
@@ -31,25 +33,19 @@ use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityReason;
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityType;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-/**
- * Load reports into DB
- *
- * @author Champs-Libres Coop
- */
-class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
+class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
{
- use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
-
/**
* @var \Faker\Generator
*/
private $faker;
+ private EntityManagerInterface $em;
- public function __construct()
+ public function __construct(EntityManagerInterface $em)
{
$this->faker = FakerFactory::create('fr_FR');
+ $this->em = $em;
}
public function getOrder()
@@ -88,7 +84,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
{
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
- if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
+ if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
// we have a reason which should be excluded. Find another...
return $this->getRandomActivityReason($excludingIds);
}
@@ -132,20 +128,17 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
public function load(ObjectManager $manager)
{
- $persons = $this->container->get('doctrine.orm.entity_manager')
- ->getRepository('ChillPersonBundle:Person')
+ $persons = $this->em
+ ->getRepository(Person::class)
->findAll();
- foreach($persons as $person) {
+ foreach ($persons as $person) {
$activityNbr = rand(0,3);
- $ref = 'activity_'.$person->getFullnameCanonical();
- for($i = 0; $i < $activityNbr; $i ++) {
+ for ($i = 0; $i < $activityNbr; $i ++) {
$activity = $this->newRandomActivity($person);
$manager->persist($activity);
}
-
- $this->setReference($ref, $activity);
}
$manager->flush();
}
diff --git a/src/Bundle/ChillActivityBundle/config/services/fixtures.yaml b/src/Bundle/ChillActivityBundle/config/services/fixtures.yaml
index 4851b7838..900453a67 100644
--- a/src/Bundle/ChillActivityBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillActivityBundle/config/services/fixtures.yaml
@@ -1,4 +1,6 @@
services:
Chill\ActivityBundle\DataFixtures\ORM\:
+ autowire: true
+ autoconfigure: true
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
index 0bf19418f..c23871c26 100644
--- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
+++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
@@ -5,21 +5,20 @@ namespace Chill\CalendarBundle\DataFixtures\ORM;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\User;
+use Chill\MainBundle\Repository\UserRepository;
use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
-use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
class LoadCalendarRange extends Fixture implements FixtureGroupInterface, OrderedFixtureInterface
{
-
public function __construct(
- EntityManagerInterface $em
+ UserRepository $userRepository
) {
- $this->userRepository = $em->getRepository(User::class);
+ $this->userRepository = $userRepository;
}
public function getOrder(): int
@@ -37,7 +36,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
public function load(ObjectManager $manager): void
{
$arr = range(-50, 50);
-
+
print "Creating calendar range ('plage de disponibilités')\n";
$users = $this->userRepository->findAll();
@@ -70,7 +69,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
->setUser($u)
->setStartDate($startEvent)
->setEndDate($endEvent);
-
+
$manager->persist($calendarRange);
}
@@ -79,4 +78,4 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
}
$manager->flush();
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php b/src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php
index 0f4577ffd..ec1773640 100644
--- a/src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php
+++ b/src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php
@@ -38,7 +38,7 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
return 35000;
}
-
+
public function load(ObjectManager $manager)
{
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
@@ -57,15 +57,15 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
break;
case 'administrative':
case 'direction':
- if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
+ if (in_array($scope->getName()['en'], array('administrative', 'social'), true)) {
printf("denying power on %s\n", $scope->getName()['en']);
break 2; // we do not want any power on social or administrative
- }
+ }
break;
}
-
+
printf("Adding Person report acl to %s "
- . "permission group, scope '%s' \n",
+ . "permission group, scope '%s' \n",
$permissionsGroup->getName(), $scope->getName()['en']);
$roleScopeUpdate = (new RoleScope())
->setRole(PersonDocumentVoter::CREATE)
@@ -83,9 +83,9 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($roleScopeCreate);
$manager->persist($roleScopeDelete);
}
-
+
}
-
+
$manager->flush();
}
diff --git a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php
index 7ef753e52..be95880e8 100644
--- a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php
+++ b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php
@@ -50,19 +50,19 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
break;
case 'administrative':
case 'direction':
- if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
+ if (in_array($scope->getName()['en'], array('administrative', 'social'), true)) {
break 2; // we do not want any power on social or administrative
- }
+ }
break;
}
-
+
printf("Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE "
. "& CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE "
. "& CHILL_EVENT_SEE & CHILL_EVENT_SEE_DETAILS "
. "to %s "
- . "permission group, scope '%s' \n",
+ . "permission group, scope '%s' \n",
$permissionsGroup->getName(), $scope->getName()['en']);
-
+
$roleScopeUpdate = (new RoleScope())
->setRole('CHILL_EVENT_UPDATE')
->setScope($scope);
@@ -71,7 +71,7 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeUpdate);
$permissionsGroup->addRoleScope($roleScopeUpdate2);
-
+
$roleScopeCreate = (new RoleScope())
->setRole('CHILL_EVENT_CREATE')
->setScope($scope);
@@ -80,7 +80,7 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeCreate);
$permissionsGroup->addRoleScope($roleScopeCreate2);
-
+
$roleScopeSee = (new RoleScope())
->setRole('CHILL_EVENT_SEE')
->setScope($scope);
@@ -89,7 +89,7 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeSee);
$permissionsGroup->addRoleScope($roleScopeSee2);
-
+
$manager->persist($roleScopeUpdate);
$manager->persist($roleScopeUpdate2);
$manager->persist($roleScopeCreate);
@@ -97,9 +97,9 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($roleScopeSee);
$manager->persist($roleScopeSee2);
}
-
+
}
-
+
$manager->flush();
}
diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php
index 0a7aa1737..877f1c330 100644
--- a/src/Bundle/ChillMainBundle/Search/SearchApi.php
+++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php
@@ -88,13 +88,13 @@ class SearchApi
private function buildCountQuery(array $queries, $types, $parameters)
{
- $query = "SELECT COUNT(sq.key) AS count FROM ({union_unordered}) AS sq";
+ $query = "SELECT COUNT(*) AS count FROM ({union_unordered}) AS sq";
$unions = [];
$parameters = [];
foreach ($queries as $q) {
- $unions[] = $q->buildQuery();
- $parameters = \array_merge($parameters, $q->buildParameters());
+ $unions[] = $q->buildQuery(true);
+ $parameters = \array_merge($parameters, $q->buildParameters(true));
}
$unionUnordered = \implode(" UNION ", $unions);
diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php b/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php
index 9188c0b5c..095d49b43 100644
--- a/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php
+++ b/src/Bundle/ChillMainBundle/Search/SearchApiQuery.php
@@ -76,33 +76,58 @@ class SearchApiQuery
return $this;
}
- public function buildQuery(): string
+ public function buildQuery(bool $countOnly = false): string
{
- $where = \implode(' AND ', $this->whereClauses);
+ $isMultiple = count($this->whereClauses);
+ $where =
+ ($isMultiple ? '(' : '').
+ \implode(
+ ($isMultiple ? ')' : '').' AND '.($isMultiple ? '(' : '')
+ , $this->whereClauses).
+ ($isMultiple ? ')' : '')
+ ;
- return \strtr("SELECT
+ if (!$countOnly) {
+ $select = \strtr("
'{key}' AS key,
{metadata} AS metadata,
{pertinence} AS pertinence
- FROM {from}
- WHERE {where}
+ ", [
+ '{key}' => $this->selectKey,
+ '{metadata}' => $this->jsonbMetadata,
+ '{pertinence}' => $this->pertinence,
+ ]);
+ } else {
+ $select = "1 AS c";
+ }
+
+ return \strtr("SELECT
+ {select}
+ FROM {from}
+ WHERE {where}
", [
- '{key}' => $this->selectKey,
- '{metadata}' => $this->jsonbMetadata,
- '{pertinence}' => $this->pertinence,
+ '{select}' => $select,
'{from}' => $this->fromClause,
'{where}' => $where,
]);
}
- public function buildParameters(): array
+
+ public function buildParameters(bool $countOnly = false): array
{
- return \array_merge(
- $this->selectKeyParams,
- $this->jsonbMetadataParams,
- $this->pertinenceParams,
- $this->fromClauseParams,
- \array_merge([], ...$this->whereClausesParams),
- );
+ if (!$countOnly) {
+ return \array_merge(
+ $this->selectKeyParams,
+ $this->jsonbMetadataParams,
+ $this->pertinenceParams,
+ $this->fromClauseParams,
+ \array_merge([], ...$this->whereClausesParams),
+ );
+ } else {
+ return \array_merge(
+ $this->fromClauseParams,
+ \array_merge([], ...$this->whereClausesParams),
+ );
+ }
}
}
diff --git a/src/Bundle/ChillMainBundle/Test/PrepareClientTrait.php b/src/Bundle/ChillMainBundle/Test/PrepareClientTrait.php
index 5df0b57dd..4440f2eef 100644
--- a/src/Bundle/ChillMainBundle/Test/PrepareClientTrait.php
+++ b/src/Bundle/ChillMainBundle/Test/PrepareClientTrait.php
@@ -30,7 +30,6 @@ trait PrepareClientTrait
*
* @param string $username the username (default 'center a_social')
* @param string $password the password (default 'password')
- * @return \Symfony\Component\BrowserKit\Client
* @throws \LogicException
*/
public function getClientAuthenticated(
diff --git a/src/Bundle/ChillMainBundle/Tests/Search/SearchApiQueryTest.php b/src/Bundle/ChillMainBundle/Tests/Search/SearchApiQueryTest.php
index 2e63f24e0..6aeb835e7 100644
--- a/src/Bundle/ChillMainBundle/Tests/Search/SearchApiQueryTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Search/SearchApiQueryTest.php
@@ -20,7 +20,12 @@ class SearchApiQueryTest extends TestCase
$query = $q->buildQuery();
- $this->assertStringContainsString('foo AND bar', $query);
+ $this->assertStringContainsString('(foo) AND (bar)', $query);
+ $this->assertEquals(['alpha', 'beta'], $q->buildParameters());
+
+ $query = $q->buildQuery(true);
+
+ $this->assertStringContainsString('(foo) AND (bar)', $query);
$this->assertEquals(['alpha', 'beta'], $q->buildParameters());
}
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index c2a8f6e2c..0941dd7d4 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -28,14 +28,12 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
use Symfony\Component\Workflow\Registry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-class AccompanyingCourseApiController extends ApiController
+final class AccompanyingCourseApiController extends ApiController
{
- protected EventDispatcherInterface $eventDispatcher;
-
- protected ValidatorInterface $validator;
-
+ private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
+ private EventDispatcherInterface $eventDispatcher;
+ private ValidatorInterface $validator;
private Registry $registry;
-
private ReferralsSuggestionInterface $referralAvailable;
public function __construct(
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/Helper/PersonRandomHelper.php b/src/Bundle/ChillPersonBundle/DataFixtures/Helper/PersonRandomHelper.php
new file mode 100644
index 000000000..0f7068751
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/Helper/PersonRandomHelper.php
@@ -0,0 +1,40 @@
+countPersons) {
+ $qb = $em->createQueryBuilder();
+ $this->countPersons = $qb->select('count(p)')
+ ->from(Person::class, 'p')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ }
+
+ if ([] === $this->randPersons) {
+ $qb = $em->createQueryBuilder();
+ $this->randPersons = $qb
+ ->select('p')
+ ->from(Person::class, 'p')
+ ->getQuery()
+ ->setFirstResult(\random_int(0, $this->countPersons - $fetchBy))
+ ->setMaxResults($fetchBy)
+ ->getResult()
+ ;
+ }
+
+ return \array_pop($this->randPersons);
+ }
+
+}
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
index 35d11475c..df471aedd 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
@@ -262,7 +262,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
$manager->persist($accompanyingPeriod);
echo "add person'".$person->__toString()."'\n";
- $this->addReference(self::PERSON, $person);
+ $this->addReference(self::PERSON.$person->getId(), $person);
}
private function getRandomUser(): User
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
index f433f2402..3b2b4518e 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
@@ -10,7 +10,26 @@ use Doctrine\Persistence\ObjectManager;
class LoadRelations extends Fixture implements FixtureGroupInterface
{
- public const RELATIONS = 'relations';
+ public const RELATION_KEY = 'relations';
+ public const RELATIONS = [
+ ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
+
+ ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Frère']],
+ ['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Soeur']],
+ ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
+
+ ['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-frère']],
+ ['title' => ['fr' => 'Demi-soeur'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
+ ['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
+
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ];
public static function getGroups(): array
{
@@ -19,37 +38,17 @@ class LoadRelations extends Fixture implements FixtureGroupInterface
public function load(ObjectManager $manager)
{
- $relations = [
- ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
- ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
- ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
- ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
-
- ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Frère']],
- ['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Soeur']],
- ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
-
- ['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-frère']],
- ['title' => ['fr' => 'Demi-soeur'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
- ['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
-
- ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
- ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
- ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
- ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
- ];
-
- foreach($relations as $value){
+ foreach (self::RELATIONS as $key => $value){
print "Creating a new relation type: relation" . $value['title']['fr'] . "reverse relation: " . $value['reverseTitle']['fr'] . "\n";
$relation = new Relation();
$relation->setTitle($value['title'])
->setReverseTitle($value['reverseTitle']);
$manager->persist($relation);
- $this->addReference(self::RELATIONS, $relation);
+
+ $this->addReference(self::RELATION_KEY.$key, $relation);
}
$manager->flush();
-
}
}
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
index 5efc68400..cce6d0365 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
@@ -3,17 +3,24 @@ declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM;
+use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
+use Chill\MainBundle\Entity\User;
+use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
-use Chill\PersonBundle\DataFixtures\ORM\LoadPeople;
-use Chill\PersonBundle\DataFixtures\ORM\LoadRelations;
use Chill\PersonBundle\Entity\Relationships\Relationship;
class LoadRelationships extends Fixture implements DependentFixtureInterface
{
+ use PersonRandomHelper;
+ private EntityManagerInterface $em;
-
+ public function __construct(EntityManagerInterface $em)
+ {
+ $this->em = $em;
+ }
public function getDependencies()
{
@@ -21,16 +28,33 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
LoadPeople::class,
LoadRelations::class
];
-
}
public function load(ObjectManager $manager)
{
- $relationship = new Relationship;
- $relationship->setFromPerson($this->getReference(LoadPeople::PERSON));
- $relationship->setToPerson($this->getReference(LoadPeople::PERSON));
- $relationship->setRelation($this->getReference(LoadRelations::RELATIONS));
- $relationship->setReverse((bool)random_int(0, 1));
+ for ($i = 0; $i < 15; $i++) {
+ $user = $this->getRandomUser();
+ $date = new \DateTimeImmutable();
+ $relationship = (new Relationship())
+ ->setFromPerson($this->getRandomPerson($this->em))
+ ->setToPerson($this->getRandomPerson($this->em))
+ ->setRelation($this->getReference(LoadRelations::RELATION_KEY.
+ \random_int(0, count(LoadRelations::RELATIONS) - 1)))
+ ->setReverse((bool) random_int(0, 1))
+ ->setCreatedBy($user)
+ ->setUpdatedBy($user)
+ ->setCreatedAt($date)
+ ->setUpdatedAt($date)
+ ;
+ $manager->persist($relationship);
+ }
+
+ $manager->flush();
}
-}
\ No newline at end of file
+ private function getRandomUser(): User
+ {
+ $userRef = array_rand(LoadUsers::$refs);
+ return $this->getReference($userRef);
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
index b735138f4..b68055581 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
@@ -37,6 +37,6 @@ class RelationRepository implements ObjectRepository
public function getClassName(): string
{
- return MaritalStatus::class;
+ return Relation::class;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
index 3f105537a..7e5f2af24 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
@@ -10,7 +10,6 @@ use Doctrine\Persistence\ObjectRepository;
class RelationshipRepository implements ObjectRepository
{
-
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
@@ -40,9 +39,9 @@ class RelationshipRepository implements ObjectRepository
public function getClassName(): string
{
- return MaritalStatus::class;
+ return Relationship::class;
}
-
+
public function findByPerson($personId): array
{
// return all relationships of which person is part? or only where person is the fromPerson?
@@ -56,5 +55,5 @@ class RelationshipRepository implements ObjectRepository
->getResult()
;
}
-
+
}
diff --git a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php
index dd0ae67c7..60122dbc2 100644
--- a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php
+++ b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php
@@ -2,29 +2,43 @@
namespace Chill\PersonBundle\Search;
+use Chill\MainBundle\Entity\Center;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Search\SearchApiInterface;
+use Chill\PersonBundle\Security\Authorization\PersonVoter;
+use Symfony\Component\Security\Core\Security;
class SearchPersonApiProvider implements SearchApiInterface
{
private PersonRepository $personRepository;
+ private Security $security;
+ private AuthorizationHelperInterface $authorizationHelper;
- public function __construct(PersonRepository $personRepository)
+ public function __construct(PersonRepository $personRepository, Security $security, AuthorizationHelperInterface $authorizationHelper)
{
$this->personRepository = $personRepository;
+ $this->security = $security;
+ $this->authorizationHelper = $authorizationHelper;
}
public function provideQuery(string $pattern, array $parameters): SearchApiQuery
+ {
+ return $this->addAuthorizations($this->buildBaseQuery($pattern, $parameters));
+ }
+
+ public function buildBaseQuery(string $pattern, array $parameters): SearchApiQuery
{
$query = new SearchApiQuery();
$query
->setSelectKey("person")
->setSelectJsonbMetadata("jsonb_build_object('id', person.id)")
- ->setSelectPertinence("GREATEST(".
- "STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), person.fullnamecanonical), ".
- "(person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%')::int".
- ")", [ $pattern, $pattern ])
+ ->setSelectPertinence("".
+ "STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), person.fullnamecanonical) + ".
+ "(person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%')::int + ".
+ "(EXISTS (SELECT 1 FROM unnest(string_to_array(fullnamecanonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int"
+ , [ $pattern, $pattern, $pattern ])
->setFromClause("chill_person_person AS person")
->setWhereClauses("LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ".
"person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%' ", [ $pattern, $pattern ])
@@ -33,6 +47,28 @@ class SearchPersonApiProvider implements SearchApiInterface
return $query;
}
+ private function addAuthorizations(SearchApiQuery $query): SearchApiQuery
+ {
+ $authorizedCenters = $this->authorizationHelper
+ ->getReachableCenters($this->security->getUser(), PersonVoter::SEE);
+
+ if ([] === $authorizedCenters) {
+ return $query->andWhereClause("FALSE = TRUE", []);
+ }
+
+ return $query
+ ->andWhereClause(
+ strtr(
+ "person.center_id IN ({{ center_ids }})",
+ [
+ '{{ center_ids }}' => \implode(', ',
+ \array_fill(0, count($authorizedCenters), '?')),
+ ]
+ ),
+ \array_map(function(Center $c) {return $c->getId();}, $authorizedCenters)
+ );
+ }
+
public function supportsTypes(string $pattern, array $types, array $parameters): bool
{
return \in_array('person', $types);
diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
index 6620a7c38..7e18c7c65 100644
--- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
+++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php
@@ -259,7 +259,8 @@ class PersonControllerUpdateTest extends WebTestCase
return array(
['firstName', 'random Value', function(Person $person) { return $person->getFirstName(); } ],
['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ],
- ['placeOfBirth', 'NONE PLACE', function(Person $person) { return $person->getPlaceOfBirth(); }],
+ // reminder: this value is capitalized
+ ['placeOfBirth', 'A PLACE', function(Person $person) { return $person->getPlaceOfBirth(); }],
['birthdate', '1980-12-15', function(Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
['phonenumber', '+32123456789', function(Person $person) { return $person->getPhonenumber(); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }],
diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
index 6d538a646..293dd1a10 100644
--- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
+++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
@@ -2,23 +2,32 @@
declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Controller;
+use Chill\MainBundle\Test\PrepareClientTrait;
+use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper;
+use Chill\PersonBundle\Entity\Person;
+use Chill\PersonBundle\Entity\Relationships\Relation;
+use Doctrine\ORM\EntityManagerInterface;
+use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Component\HttpFoundation\Request;
use Chill\PersonBundle\Repository\PersonRepository;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class RelationshipApiControllerTest extends WebTestCase
{
- public static function setUpBeforeClass()
- {
- static::bootKernel();
- }
+ use PrepareClientTrait;
+
+ private KernelBrowser $client;
+
+ /**
+ * A cache for all relations
+ * @var array|null|Relation[]
+ */
+ private ?array $relations = null;
public function setUp()
{
- $this->client = static::createClient(array(), array(
- 'PHP_AUTH_USER' => 'fred',
- 'PHP_AUTH_PW' => 'password',
- ));
+ static::bootKernel();
+ $this->client = $this->getClientAuthenticated();
}
/**
@@ -38,11 +47,11 @@ class RelationshipApiControllerTest extends WebTestCase
public function testPostRelationship($fromPersonId, $toPersonId, $relationId, $isReverse): void
{
- $this->client->request(Request::METHOD_POST,
- '/api/1.0/person/relations/relationship.json',
+ $this->client->request(Request::METHOD_POST,
+ '/api/1.0/relations/relationship.json',
+ [],
[],
[],
- [],
\json_encode([
'type' => 'relationship',
'fromPerson' => ['id' => $fromPersonId, 'type' => 'person'],
@@ -57,18 +66,72 @@ class RelationshipApiControllerTest extends WebTestCase
public function relationProvider(): array
{
- //TODO: which different cases to test?
+ static::bootKernel();
+ $em = self::$container->get(EntityManagerInterface::class);
+ $countPersons = $em->createQueryBuilder()
+ ->select('count(p)')
+ ->from(Person::class, 'p')
+ ->join('p.center', 'c')
+ ->where('c.name LIKE :name')
+ ->setParameter('name', 'Center A')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ $persons = $em->createQueryBuilder()
+ ->select('p')
+ ->from(Person::class, 'p')
+ ->join('p.center', 'c')
+ ->where('c.name LIKE :name')
+ ->setParameter('name', 'Center A')
+ ->getQuery()
+ ->setMaxResults(2)
+ ->setFirstResult(\random_int(0, $countPersons - 1))
+ ->getResult()
+ ;
+
return [
- [333, 334, 1, true],
+ [$persons[0]->getId(), $persons[1]->getId(), $this->getRandomRelation($em)->getId(), true],
];
}
+ private function getRandomRelation(EntityManagerInterface $em): Relation
+ {
+ if (null === $this->relations) {
+ $this->relations = $em->getRepository(Relation::class)
+ ->findAll();
+ }
+
+ return $this->relations[\array_rand($this->relations)];
+ }
+
public function personProvider(): array
{
- //TODO: which different cases to test?
+ static::bootKernel();
+ $em = self::$container->get(EntityManagerInterface::class);
+ $countPersons = $em->createQueryBuilder()
+ ->select('count(p)')
+ ->from(Person::class, 'p')
+ ->join('p.center', 'c')
+ ->where('c.name LIKE :name')
+ ->setParameter('name', 'Center A')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ $person = $em->createQueryBuilder()
+ ->select('p')
+ ->from(Person::class, 'p')
+ ->join('p.center', 'c')
+ ->where('c.name LIKE :name')
+ ->setParameter('name', 'Center A')
+ ->getQuery()
+ ->setMaxResults(1)
+ ->setFirstResult(\random_int(0, $countPersons - 1))
+ ->getSingleResult()
+ ;
+
return [
- [333],
+ [$person->getId()],
];
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillPersonBundle/config/services/fixtures.yaml b/src/Bundle/ChillPersonBundle/config/services/fixtures.yaml
index 72bf899f4..753521ad7 100644
--- a/src/Bundle/ChillPersonBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/fixtures.yaml
@@ -1,6 +1,7 @@
services:
Chill\PersonBundle\DataFixtures\ORM\:
autowire: true
+ autoconfigure: true
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
From 6c51d6de51bfcabaac4880c512e08ab488be3a62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 12:28:48 +0100
Subject: [PATCH 145/227] remove unnecessary space (minor, [ci-skip])
---
.../Tests/Controller/RelationshipApiControllerTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
index 293dd1a10..ac785f781 100644
--- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
+++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php
@@ -44,7 +44,6 @@ class RelationshipApiControllerTest extends WebTestCase
/**
* @dataProvider relationProvider
*/
-
public function testPostRelationship($fromPersonId, $toPersonId, $relationId, $isReverse): void
{
$this->client->request(Request::METHOD_POST,
From 5ee67f74d9e1d739bbcb789f149d68c82a90aa70 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Mon, 15 Nov 2021 13:05:27 +0100
Subject: [PATCH 146/227] remove toast imports for vue
---
.../Resources/public/vuejs/AccompanyingCourse/index.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
index ace482d79..fe01abd19 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
@@ -2,8 +2,6 @@ import { createApp } from 'vue'
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { appMessages } from './js/i18n'
import { initPromise } from './store'
-import VueToast from 'vue-toast-notification';
-import 'vue-toast-notification/dist/theme-sugar.css';
import App from './App.vue';
import Banner from './components/Banner.vue';
From e2d4d9c831d8d7651e1e7da7d799680b310dc269 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Mon, 15 Nov 2021 13:07:44 +0100
Subject: [PATCH 147/227] remove use statement
---
.../Resources/public/vuejs/AccompanyingCourse/index.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
index fe01abd19..e3fdec4a3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js
@@ -21,7 +21,6 @@ if (root === 'app') {
})
.use(store)
.use(i18n)
- .use(VueToast)
.component('app', App)
.mount('#accompanying-course');
});
From b217fb3c3984ecc996636a0a5082cee370b02d1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 13:06:31 +0100
Subject: [PATCH 148/227] create option config for asking (or not) center in
form
---
.../ChillMainBundle/DependencyInjection/Configuration.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php
index be1281ee6..7cf3aed50 100644
--- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php
+++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php
@@ -104,6 +104,9 @@ class Configuration implements ConfigurationInterface
->booleanNode('form_show_scopes')
->defaultTrue()
->end()
+ ->booleanNode('form_show_centers')
+ ->defaultTrue()
+ ->end()
->end()
->end()
->arrayNode('redis')
From 77add46a703148017dbcf7c6aa3e5feda7b99386 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 13:06:47 +0100
Subject: [PATCH 149/227] take parameter `form_show_center` into account: not
to ask center on person creation
---
.../ChillPersonBundle/Entity/Person.php | 8 +++----
.../Form/CreationPersonType.php | 22 +++++++++++++------
.../Person/PersonHasCenterValidator.php | 7 ++++--
3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index b1048ea60..7aacf6ba8 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -1182,9 +1182,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @param string $phonenumber
* @return Person
*/
- public function setPhonenumber($phonenumber = '')
+ public function setPhonenumber(?string $phonenumber = '')
{
- $this->phonenumber = $phonenumber;
+ $this->phonenumber = (string) $phonenumber;
return $this;
}
@@ -1205,9 +1205,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @param string $mobilenumber
* @return Person
*/
- public function setMobilenumber($mobilenumber = '')
+ public function setMobilenumber(?string $mobilenumber = '')
{
- $this->mobilenumber = $mobilenumber;
+ $this->mobilenumber = (string) $mobilenumber;
return $this;
}
diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
index 8fa95fe4f..3fa8f5cda 100644
--- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
@@ -25,6 +25,7 @@ use Chill\MainBundle\Form\Event\CustomizeFormEvent;
use Chill\MainBundle\Repository\CenterRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
+use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -54,14 +55,18 @@ final class CreationPersonType extends AbstractType
private EventDispatcherInterface $dispatcher;
+ private bool $askCenters;
+
public function __construct(
CenterRepository $centerRepository,
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
- EventDispatcherInterface $dispatcher
+ EventDispatcherInterface $dispatcher,
+ ParameterBagInterface $parameterBag
) {
$this->centerTransformer = $centerRepository;
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
$this->dispatcher = $dispatcher;
+ $this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
}
/**
@@ -78,12 +83,15 @@ final class CreationPersonType extends AbstractType
])
->add('gender', GenderType::class, array(
'required' => true, 'placeholder' => null
- ))
- ->add('center', PickCenterType::class, [
- 'required' => false,
- 'role' => PersonVoter::CREATE,
- ])
- ;
+ ));
+
+ if ($this->askCenters) {
+ $builder
+ ->add('center', PickCenterType::class, [
+ 'required' => false,
+ 'role' => PersonVoter::CREATE,
+ ]);
+ }
if ($this->configPersonAltNamesHelper->hasAltNames()) {
$builder->add('altNames', PersonAltNameType::class, [
diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php
index 1738e6ddc..825084448 100644
--- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php
+++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php
@@ -2,6 +2,7 @@
namespace Chill\PersonBundle\Validator\Constraints\Person;
+use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Validator\Constraint;
@@ -10,10 +11,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintValidator
{
private bool $centerRequired;
+ private CenterResolverDispatcher $centerResolverDispatcher;
- public function __construct(ParameterBagInterface $parameterBag)
+ public function __construct(ParameterBagInterface $parameterBag, CenterResolverDispatcher $centerResolverDispatcher)
{
$this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required'];
+ $this->centerResolverDispatcher = $centerResolverDispatcher;
}
/**
@@ -29,7 +32,7 @@ class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintVa
return;
}
- if (NULL === $person->getCenter()) {
+ if (NULL === $this->centerResolverDispatcher->resolveCenter($person)) {
$this
->context
->buildViolation($constraint->message)
From 5fb7a6d0ae526425d6e870911b20d90e4e54a1ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 13:14:08 +0100
Subject: [PATCH 150/227] take into account form_show_centers parameters into
thirdparty form type
---
.../views/FilterOrder/base.html.twig | 42 ++++++++++---------
.../Form/ThirdPartyType.php | 30 ++++++++-----
.../views/ThirdParty/_form.html.twig | 34 ++-------------
3 files changed, 44 insertions(+), 62 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig
index 3457c883a..f9924eb11 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig
@@ -10,30 +10,32 @@
{% endif %}
- {% if form.checkboxes|length > 0 %}
- {% for checkbox_name, options in form.checkboxes %}
-
-
- {% for c in form['checkboxes'][checkbox_name].children %}
-
- {{ form_widget(c) }}
- {{ form_label(c) }}
-
- {% endfor %}
-
-
- {% if loop.last %}
+ {% if form.checkboxes is defined %}
+ {% if form.checkboxes|length > 0 %}
+ {% for checkbox_name, options in form.checkboxes %}
-
+ {% for c in form['checkboxes'][checkbox_name].children %}
+
+ {{ form_widget(c) }}
+ {{ form_label(c) }}
+
+ {% endfor %}
- {% endif %}
- {% endfor %}
+ {% if loop.last %}
+
+ {% endif %}
+ {% endfor %}
+ {% endif %}
{% endif %}
{{ form_end(form) }}
diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
index 2c7380116..e2ebfa6d9 100644
--- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
+++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
@@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
+use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -46,18 +47,22 @@ class ThirdPartyType extends AbstractType
protected EntityManagerInterface $om;
+ private bool $askCenter;
+
public function __construct(
AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage,
ThirdPartyTypeManager $typesManager,
TranslatableStringHelper $translatableStringHelper,
- EntityManagerInterface $om
+ EntityManagerInterface $om,
+ ParameterBagInterface $parameterBag
) {
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;
$this->typesManager = $typesManager;
$this->translatableStringHelper = $translatableStringHelper;
$this->om = $om;
+ $this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
}
/**
@@ -78,16 +83,19 @@ class ThirdPartyType extends AbstractType
])
->add('comment', ChillTextareaType::class, [
'required' => false
- ])
- ->add('centers', PickCenterType::class, [
- 'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
- ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
- 'choice_options' => [
- 'multiple' => true,
- 'attr' => ['class' => 'select2']
- ]
- ])
- ;
+ ]);
+
+ if ($this->askCenter) {
+ $builder
+ ->add('centers', PickCenterType::class, [
+ 'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
+ ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
+ 'choice_options' => [
+ 'multiple' => true,
+ 'attr' => ['class' => 'select2']
+ ]
+ ]);
+ }
// Contact Person ThirdParty (child)
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
index 6bc4e3da7..c53764871 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
@@ -30,38 +30,10 @@
{{ form_row(form.address) }}
-{#
-
- {{ form_label(form.address) }}
- {{ form_widget(form.address) }}
-
-
- {% if thirdParty.address %}
- {# include vue_address component #
- {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
- targetEntity: { name: 'thirdparty', id: thirdParty.id },
- mode: 'edit',
- addressId: thirdParty.address.id,
- buttonSize: 'btn-sm',
- } %}
- {#
- backUrl: path('chill_3party_3party_new'),
- #
- {% else %}
- {# include vue_address component #
- {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
- targetEntity: { name: 'thirdparty', id: thirdParty.id },
- mode: 'new',
- buttonSize: 'btn-sm',
- buttonText: 'Create a new address',
- modalTitle: 'Create a new address',
- } %}
- {% endif %}
-
-
-#}
-
{{ form_row(form.comment) }}
+
+{% if form.centers is defined %}
{{ form_row(form.centers) }}
+{% endif %}
{{ form_row(form.active) }}
From 4a15022375f8e77af3c0832c771b92f5d7b614cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Fastr=C3=A9?=
Date: Mon, 15 Nov 2021 13:15:00 +0100
Subject: [PATCH 151/227] update change log
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de73733d0..6dc54473f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,8 @@ and this project adheres to
* 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
From a7b96f175698ed48cab676a3bc35033efa532599 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 10:29:41 +0100
Subject: [PATCH 152/227] fix: SA: Fix "incorrect case" rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 15 ----
.../Command/CreateFieldsOnGroupCommand.php | 79 +++++++++----------
.../Export/Formatter/SpreadSheetFormatter.php | 2 +-
.../Entity/AccompanyingPeriod.php | 4 +-
4 files changed, 42 insertions(+), 58 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index b88679016..05c574064 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -170,11 +170,6 @@ parameters:
count: 1
path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php
- -
- message: "#^Class RuntimeException referenced with incorrect case\\: RunTimeException\\.$#"
- count: 5
- path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
-
-
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
count: 1
@@ -685,11 +680,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
- -
- message: "#^Call to method Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\SpreadSheetFormatter\\:\\:generateContent\\(\\) with incorrect case\\: generatecontent$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
-
-
message: "#^Foreach overwrites \\$key with its key variable\\.$#"
count: 1
@@ -1020,11 +1010,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
- -
- message: "#^Call to method Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:getOpenParticipations\\(\\) with incorrect case\\: getOPenParticipations$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
-
-
message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
count: 1
diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
index b037975ab..9da4803ed 100644
--- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
+++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
@@ -45,25 +45,25 @@ class CreateFieldsOnGroupCommand extends Command
{
const ARG_PATH = 'path';
const ARG_DELETE = 'delete';
-
+
/**
* @var CustomFieldProvider
*/
private $customFieldProvider;
-
+
/**
* @var EntityManager
*/
private $entityManager;
-
+
/**
* @var ValidatorInterface
*/
private $validator;
-
+
private $availableLanguages;
private $customizablesEntities;
-
+
/**
* CreateFieldsOnGroupCommand constructor.
*
@@ -87,7 +87,7 @@ class CreateFieldsOnGroupCommand extends Command
$this->customizablesEntities = $customizablesEntities;
parent::__construct();
}
-
+
protected function configure()
{
$this->setName('chill:custom_fields:populate_group')
@@ -111,7 +111,7 @@ class CreateFieldsOnGroupCommand extends Command
$em->remove($field);
}
}
-
+
/**
* @param InputInterface $input
* @param OutputInterface $output
@@ -120,18 +120,18 @@ class CreateFieldsOnGroupCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelperSet()->get('question');
-
+
$em = $this->entityManager;
-
+
$customFieldsGroups = $em
->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
->findAll();
-
+
if (count($customFieldsGroups) === 0) {
$output->writeln('There aren\'t any CustomFieldsGroup recorded'
. ' Please create at least one. ');
- }
-
+ }
+
$table = new Table($output);
$table
->setHeaders(array_merge(
@@ -141,7 +141,7 @@ class CreateFieldsOnGroupCommand extends Command
->setRows($this->_prepareRows($customFieldsGroups))
->render()
;
-
+
$question = new Question(
"Enter the customfieldGroup's id on which the custom fields should be added: ");
$question->setNormalizer(
@@ -151,24 +151,23 @@ class CreateFieldsOnGroupCommand extends Command
return $customFieldsGroup;
}
}
- throw new \RunTimeException('The id does not match an existing '
- . 'CustomFieldsGroup');
+ throw new \RuntimeException('The id does not match an existing CustomFieldsGroup');
}
);
$customFieldsGroup = $helper->ask($input, $output, $question);
-
+
if ($input->getOption(self::ARG_DELETE)) {
$this->deleteFieldsForCFGroup($customFieldsGroup);
}
-
- $fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH),
+
+ $fieldsInput = $this->_parse($input->getArgument(self::ARG_PATH),
$output);
-
+
$fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output);
}
-
- private function _prepareRows ($customFieldsGroups)
+
+ private function _prepareRows ($customFieldsGroups)
{
$rows = array();
$languages = $this->availableLanguages;
@@ -177,8 +176,8 @@ class CreateFieldsOnGroupCommand extends Command
foreach ($this->customizablesEntities as $entry) {
$customizableEntities[$entry['class']] = $entry['name'];
}
-
- array_walk($customFieldsGroups,
+
+ array_walk($customFieldsGroups,
function(CustomFieldsGroup $customFieldGroup, $key)
use ($languages, &$rows, $customizableEntities) {
//set id and entity
@@ -186,7 +185,7 @@ class CreateFieldsOnGroupCommand extends Command
$customFieldGroup->getId(),
$customizableEntities[$customFieldGroup->getEntity()]
);
-
+
foreach ($languages as $lang) {
//todo replace with service to find lang when available
$row[] = (isset($customFieldGroup->getName()[$lang])) ?
@@ -196,42 +195,42 @@ class CreateFieldsOnGroupCommand extends Command
$rows[] = $row;
}
);
-
+
return $rows;
}
-
+
private function _parse($path, OutputInterface $output)
{
$parser = new Parser();
-
+
if (!file_exists($path)) {
- throw new \RunTimeException("file does not exist");
+ throw new \RuntimeException("file does not exist");
}
-
+
try {
$values = $parser->parse(file_get_contents($path));
} catch (ParseException $ex) {
- throw new \RunTimeException("The yaml file is not valid", 0, $ex);
+ throw new \RuntimeException("The yaml file is not valid", 0, $ex);
}
-
+
return $values;
}
-
+
private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output)
{
-
+
$em = $this->entityManager;
$languages = $this->availableLanguages;
-
+
foreach($values['fields'] as $slug => $field) {
//check the cf type exists
$cfType = $this->customFieldProvider->getCustomFieldByType($field['type']);
if ($cfType === NULL) {
- throw new \RunTimeException('the type '.$field['type'].' '
+ throw new \RuntimeException('the type '.$field['type'].' '
. 'does not exists');
}
-
+
$cf = new CustomField();
$cf->setSlug($slug)
->setName($field['name'])
@@ -239,7 +238,7 @@ class CreateFieldsOnGroupCommand extends Command
->setOrdering($field['ordering'])
->setType($field['type'])
->setCustomFieldsGroup($group);
-
+
//add to table
$names = array();
foreach ($languages as $lang) {
@@ -248,17 +247,17 @@ class CreateFieldsOnGroupCommand extends Command
$cf->getName()[$lang] :
'Not available in this language';
}
-
+
if ($this->validator->validate($cf)) {
$em->persist($cf);
$output->writeln("Adding Custom Field of type "
.$cf->getType()."\t with slug ".$cf->getSlug().
"\t and names : ".implode($names, ', ')." ");
} else {
- throw new \RunTimeException("Error in field ".$slug);
+ throw new \RuntimeException("Error in field ".$slug);
}
}
-
+
$em->flush();
}
}
diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
index d14ecb9ad..aed10a29f 100644
--- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
+++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
@@ -229,7 +229,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->getContentType($this->formatterData['format']));
$this->tempfile = \tempnam(\sys_get_temp_dir(), '');
- $this->generatecontent();
+ $this->generateContent();
$f = \fopen($this->tempfile, 'r');
$response->setContent(\stream_get_contents($f));
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index 6c9c84b56..d08f39b1e 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -544,7 +544,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
*/
public function actualParticipationsByHousehold(): array
{
- $participations = $this->getOPenParticipations()->toArray();
+ $participations = $this->getOpenParticipations()->toArray();
$households = [];
foreach ($participations as $p) {
@@ -1074,7 +1074,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
*/
public function getAvailablePersonLocation(): Collection
{
- return $this->getOPenParticipations()
+ return $this->getOpenParticipations()
->filter(function(AccompanyingPeriodParticipation $p) {
return $p->getPerson()->hasCurrentHouseholdAddress();
})
From f8aeb085946f7992afc551bbdf22d04b944cd08f Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 11:41:12 +0100
Subject: [PATCH 153/227] fix: SA: Fix "might not be defined" rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 89 +------------
.../Controller/ActivityController.php | 49 +++----
.../Export/Export/StatActivityDuration.php | 116 ++++++----------
.../Controller/CalendarController.php | 106 +++++++--------
.../Form/CustomFieldsGroupType.php | 69 +++++-----
.../Controller/ParticipationController.php | 92 ++++++-------
.../Command/LoadPostalCodesCommand.php | 126 ++++++------------
.../Doctrine/DQL/OverlapsI.php | 113 +++++++---------
.../Export/Formatter/CSVFormatter.php | 83 ++++--------
.../Command/ImportPeopleFromCSVCommand.php | 55 ++++----
.../ChillPersonBundle/Entity/Person.php | 12 +-
.../Service/Import/SocialWorkMetadata.php | 6 +
.../Controller/SingleTaskController.php | 44 +++---
.../ChillTaskBundle/Form/SingleTaskType.php | 25 +---
14 files changed, 365 insertions(+), 620 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 05c574064..014dd0b57 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,15 +1,5 @@
parameters:
ignoreErrors:
- -
- message: "#^Variable \\$activities might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php
-
- -
- message: "#^Variable \\$view might not be defined\\.$#"
- count: 4
- path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -50,16 +40,6 @@ parameters:
count: 1
path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
- -
- message: "#^Variable \\$header might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
-
- -
- message: "#^Variable \\$select might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -155,11 +135,6 @@ parameters:
count: 2
path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php
- -
- message: "#^Variable \\$view might not be defined\\.$#"
- count: 4
- path: src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
-
-
message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
count: 2
@@ -260,11 +235,6 @@ parameters:
count: 1
path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php
- -
- message: "#^Variable \\$optionBuilder might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php
-
-
message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#"
count: 1
@@ -535,11 +505,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
- -
- message: "#^Variable \\$csv might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
-
-
message: "#^Method Chill\\\\MainBundle\\\\Command\\\\SetPasswordCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
count: 1
@@ -620,11 +585,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
- -
- message: "#^Variable \\$p might not be defined\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php
-
-
message: "#^Method Chill\\\\MainBundle\\\\Doctrine\\\\Type\\\\PointType\\:\\:getSqlDeclaration\\(\\) does not match parent method name\\: Doctrine\\\\DBAL\\\\Types\\\\Type\\:\\:getSQLDeclaration\\(\\)\\.$#"
count: 1
@@ -661,23 +621,8 @@ parameters:
path: src/Bundle/ChillMainBundle/Export/ExportManager.php
-
- message: "#^Function findColumnPosition not found\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
-
- -
- message: "#^Inner named functions are not supported by PHPStan\\. Consider refactoring to an anonymous function, class method, or a top\\-level\\-defined function\\. See issue \\#165 \\(https\\://github\\.com/phpstan/phpstan/issues/165\\) for more details\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\CSVFormatter\\:\\:orderingHeaders\\(\\) should return Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\type but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
-
- -
- message: "#^Variable \\$line might not be defined\\.$#"
- count: 1
+ message: "#^Foreach overwrites \\$line with its value variable\\.$#"
+ count: 2
path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
-
@@ -940,16 +885,6 @@ parameters:
count: 6
path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
- -
- message: "#^Variable \\$headers might not be defined\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
-
- -
- message: "#^Variable \\$rawHeaders might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
-
-
message: "#^Variable \\$street1Value might not be defined\\.$#"
count: 1
@@ -1255,11 +1190,6 @@ parameters:
count: 2
path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
- -
- message: "#^Variable \\$entity might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
@@ -1370,11 +1300,6 @@ parameters:
count: 4
path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
- -
- message: "#^Variable \\$course might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
-
-
message: "#^Undefined variable\\: \\$type$#"
count: 1
@@ -1400,16 +1325,6 @@ parameters:
count: 2
path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php
- -
- message: "#^Variable \\$center might not be defined\\.$#"
- count: 2
- path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
-
- -
- message: "#^Variable \\$isScopeConcerned might not be defined\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
index 9529d40c0..9b1f3f48a 100644
--- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
+++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
@@ -1,28 +1,9 @@
,
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
-use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
@@ -42,12 +23,7 @@ use Chill\ActivityBundle\Form\ActivityType;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Symfony\Component\Serializer\SerializerInterface;
-/**
- * Class ActivityController
- *
- * @package Chill\ActivityBundle\Controller
- */
-class ActivityController extends AbstractController
+final class ActivityController extends AbstractController
{
protected EventDispatcherInterface $eventDispatcher;
@@ -78,8 +54,8 @@ class ActivityController extends AbstractController
*/
public function listAction(Request $request): Response
{
- $em = $this->getDoctrine()->getManager();
$view = null;
+ $activities = [];
// TODO: add pagination
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -105,11 +81,14 @@ class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig';
}
- return $this->render($view, array(
- 'activities' => $activities,
- 'person' => $person,
- 'accompanyingCourse' => $accompanyingPeriod,
- ));
+ return $this->render(
+ $view,
+ [
+ 'activities' => $activities,
+ 'person' => $person,
+ 'accompanyingCourse' => $accompanyingPeriod,
+ ]
+ );
}
public function selectTypeAction(Request $request): Response
@@ -160,6 +139,7 @@ class ActivityController extends AbstractController
public function newAction(Request $request): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -246,7 +226,7 @@ class ActivityController extends AbstractController
$location = $em->getRepository(\Chill\MainBundle\Entity\Location::class)->find($activityData['location']);
$entity->setLocation($location);
}
-
+
if (array_key_exists('comment', $activityData)) {
$comment = new CommentEmbeddable();
$comment->setComment($activityData['comment']);
@@ -297,6 +277,7 @@ class ActivityController extends AbstractController
public function showAction(Request $request, $id): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -351,6 +332,7 @@ class ActivityController extends AbstractController
*/
public function editAction($id, Request $request): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -422,6 +404,7 @@ class ActivityController extends AbstractController
*/
public function deleteAction(Request $request, $id)
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
diff --git a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
index 8fd4ec00b..0d48130b6 100644
--- a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
+++ b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
@@ -1,21 +1,6 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
@@ -28,62 +13,47 @@ use Doctrine\ORM\EntityManagerInterface;
/**
* This export allow to compute stats on activity duration.
- *
+ *
* The desired stat must be given in constructor.
- *
- *
- * @author Julien Fastré
*/
class StatActivityDuration implements ExportInterface
{
- /**
- *
- * @var EntityManagerInterface
- */
- protected $entityManager;
-
- const SUM = 'sum';
-
+ protected EntityManagerInterface $entityManager;
+
+ public const SUM = 'sum';
+
/**
* The action for this report.
- *
- * @var string
*/
- protected $action;
-
+ protected string $action;
+
/**
- * constructor
- *
- * @param EntityManagerInterface $em
* @param string $action the stat to perform
*/
- public function __construct(
- EntityManagerInterface $em,
- $action = 'sum'
- )
+ public function __construct(EntityManagerInterface $em, string $action = 'sum')
{
$this->entityManager = $em;
$this->action = $action;
}
-
+
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
{
-
+
}
public function getDescription()
{
if ($this->action === self::SUM) {
- return "Sum activities duration by various parameters.";
+ return 'Sum activities duration by various parameters.';
}
}
public function getTitle()
{
if ($this->action === self::SUM) {
- return "Sum activity duration";
+ return 'Sum activity duration';
}
-
+
}
public function getType()
@@ -91,31 +61,34 @@ class StatActivityDuration implements ExportInterface
return 'activity';
}
- public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
+ public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
- $centers = array_map(function($el) { return $el['center']; }, $acl);
+ $centers = array_map(
+ static fn(array $el): string => $el['center'],
+ $acl
+ );
+
$qb = $this->entityManager->createQueryBuilder();
-
+
+ $select = null;
+
if ($this->action === self::SUM) {
- $select = "SUM(activity.durationTime) AS export_stat_activity";
+ $select = 'SUM(activity.durationTime) AS export_stat_activity';
}
-
- $qb->select($select)
- ->from('ChillActivityBundle:Activity', 'activity')
- ->join('activity.person', 'person')
- ->join('person.center', 'center')
- ->where($qb->expr()->in('center', ':centers'))
- ->setParameter(':centers', $centers)
- ;
-
- return $qb;
+
+ return $qb->select($select)
+ ->from('ChillActivityBundle:Activity', 'activity')
+ ->join('activity.person', 'person')
+ ->join('person.center', 'center')
+ ->where($qb->expr()->in('center', ':centers'))
+ ->setParameter(':centers', $centers);
}
-
+
public function supportsModifiers()
{
- return array('person', 'activity');
+ return ['person', 'activity'];
}
-
+
public function requiredRole()
{
return new Role(ActivityStatsVoter::STATS);
@@ -129,26 +102,17 @@ class StatActivityDuration implements ExportInterface
public function getLabels($key, array $values, $data)
{
if ($key !== 'export_stat_activity') {
- throw new \LogicException("the key $key is not used by this export");
+ throw new \LogicException(sprintf('The key %s is not used by this export', $key));
}
-
- switch ($this->action) {
- case self::SUM:
- $header = "Sum of activities duration";
- }
-
- return function($value) use ($header) {
- return $value === '_header' ?
- $header
- :
- $value
- ;
- };
+
+ $header = $this->action === self::SUM ? 'Sum of activities duration' : false;
+
+ return static fn(string $value) => $value === '_header' ? $header : $value;
}
public function getQueryKeys($data)
{
- return array('export_stat_activity');
+ return ['export_stat_activity'];
}
public function getResult($qb, $data)
diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
index 03a6188a1..c6f435ea6 100644
--- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
+++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
@@ -1,24 +1,6 @@
,
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\CalendarBundle\Controller;
@@ -26,9 +8,11 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
+use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Form;
+use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -42,11 +26,6 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Routing\Annotation\Route;
-/**
- * Class CalendarController
- *
- * @package Chill\CalendarBundle\Controller
- */
class CalendarController extends AbstractController
{
protected EventDispatcherInterface $eventDispatcher;
@@ -127,13 +106,14 @@ class CalendarController extends AbstractController
*/
public function newAction(Request $request): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = '@ChillCalendar/Calendar/newByAccompanyingCourse.html.twig';
- }
+ }
// elseif ($user instanceof User) {
// $view = '@ChillCalendar/Calendar/newUser.html.twig';
// }
@@ -163,17 +143,18 @@ class CalendarController extends AbstractController
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
return $this->redirectToRoute('chill_calendar_calendar_list', $params);
- } elseif ($form->isSubmitted() and !$form->isValid()) {
- $this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
}
+ if ($form->isSubmitted() and !$form->isValid()) {
+ $this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
+ }
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
-
+
return $this->render($view, [
'user' => $user,
'accompanyingCourse' => $accompanyingPeriod,
@@ -189,44 +170,49 @@ class CalendarController extends AbstractController
*/
public function showAction(Request $request, $id): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = '@ChillCalendar/Calendar/showByAccompanyingCourse.html.twig';
- }
+ }
elseif ($user instanceof User) {
$view = '@ChillCalendar/Calendar/showByUser.html.twig';
}
- $entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id);
-
- if (!$entity) {
- throw $this->createNotFoundException('Unable to find Calendar entity.');
- }
-
- if (null !== $accompanyingPeriod) {
- $entity->personsAssociated = $entity->getPersonsAssociated();
- $entity->personsNotAssociated = $entity->getPersonsNotAssociated();
- }
-
- // $deleteForm = $this->createDeleteForm($id, $accompanyingPeriod);
-
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
- $personsId = [];
- foreach ($entity->getPersons() as $p) {
- array_push($personsId, $p->getId());
+ /** @var Calendar $entity */
+ $entity = $em->getRepository('ChillCalendarBundle:Calendar')->find($id);
+
+ if (null === $entity) {
+ throw $this->createNotFoundException('Unable to find Calendar entity.');
}
- $professionalsId = [];
- foreach ($entity->getProfessionals() as $p) {
- array_push($professionalsId, $p->getId());
+ if (null !== $accompanyingPeriod) {
+ // @TODO: These properties are declared dynamically.
+ // It must be removed.
+ // @See https://wiki.php.net/rfc/deprecate_dynamic_properties
+ $entity->personsAssociated = $entity->getPersonsAssociated();
+ $entity->personsNotAssociated = $entity->getPersonsNotAssociated();
}
+ // $deleteForm = $this->createDeleteForm($id, $accompanyingPeriod);
+
+ $personsId = array_map(
+ static fn (Person $p): int => $p->getId(),
+ $entity->getPersons()
+ );
+
+ $professionalsId = array_map(
+ static fn (ThirdParty $thirdParty): ?int => $thirdParty->getId(),
+ $entity->getProfessionals()
+ );
+
$durationTime = $entity->getEndDate()->diff($entity->getStartDate());
$durationTimeInMinutes = $durationTime->days*1440 + $durationTime->h*60 + $durationTime->i;
@@ -242,7 +228,7 @@ class CalendarController extends AbstractController
return $this->render($view, [
'accompanyingCourse' => $accompanyingPeriod,
- 'entity' => $entity,
+ 'entity' => $entity,
'user' => $user,
'activityData' => $activityData
//'delete_form' => $deleteForm->createView(),
@@ -257,6 +243,7 @@ class CalendarController extends AbstractController
*/
public function editAction($id, Request $request): Response
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$user, $accompanyingPeriod] = $this->getEntity($request);
@@ -285,8 +272,11 @@ class CalendarController extends AbstractController
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!'));
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
+
return $this->redirectToRoute('chill_calendar_calendar_list', $params);
- } elseif ($form->isSubmitted() and !$form->isValid()) {
+ }
+
+ if ($form->isSubmitted() and !$form->isValid()) {
$this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
}
@@ -297,7 +287,7 @@ class CalendarController extends AbstractController
}
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
-
+
return $this->render($view, [
'entity' => $entity,
'form' => $form->createView(),
@@ -314,13 +304,14 @@ class CalendarController extends AbstractController
*/
public function deleteAction(Request $request, $id)
{
+ $view = null;
$em = $this->getDoctrine()->getManager();
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = '@ChillCalendar/Calendar/confirm_deleteByAccompanyingCourse.html.twig';
- }
+ }
elseif ($user instanceof User) {
$view = '@ChillCalendar/Calendar/confirm_deleteByUser.html.twig';
}
@@ -369,7 +360,7 @@ class CalendarController extends AbstractController
/**
* Creates a form to delete a Calendar entity by id.
*/
- private function createDeleteForm(int $id, ?User $user, ?AccompanyingPeriod $accompanyingPeriod): Form
+ private function createDeleteForm(int $id, ?User $user, ?AccompanyingPeriod $accompanyingPeriod): FormInterface
{
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
$params['id'] = $id;
@@ -416,17 +407,14 @@ class CalendarController extends AbstractController
];
}
- private function buildParamsToUrl(
- ?User $user,
- ?AccompanyingPeriod $accompanyingPeriod
- ): array {
+ private function buildParamsToUrl(?User $user, ?AccompanyingPeriod $accompanyingPeriod): array {
$params = [];
- if ($user) {
+ if (null !== $user) {
$params['user_id'] = $user->getId();
}
- if ($accompanyingPeriod) {
+ if (null !== $accompanyingPeriod) {
$params['accompanying_period_id'] = $accompanyingPeriod->getId();
}
diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php
index 64e461c95..138254fbc 100644
--- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php
+++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php
@@ -2,6 +2,7 @@
namespace Chill\CustomFieldsBundle\Form;
+use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -15,7 +16,7 @@ use Chill\MainBundle\Form\Type\TranslatableStringFormType;
class CustomFieldsGroupType extends AbstractType
{
-
+
private $customizableEntities; //TODO : add comment about this variable
/**
@@ -52,50 +53,48 @@ class CustomFieldsGroupType extends AbstractType
))
;
- $builder->addEventListener(FormEvents::POST_SET_DATA,
- function(FormEvent $event) use ($customizableEntities, $builder){
- $form = $event->getForm();
- $group = $event->getData();
+ $builder->addEventListener(
+ FormEvents::POST_SET_DATA,
+ function(FormEvent $event) use ($customizableEntities, $builder) {
+ $form = $event->getForm();
+ $group = $event->getData();
- //stop the function if entity is not set
- if ($group->getEntity() === NULL) {
- return;
- }
+ //stop the function if entity is not set
+ if ($group->getEntity() === NULL) {
+ return;
+ }
- if (count($customizableEntities[$group->getEntity()]['options']) > 0) {
- $optionBuilder = $builder
- ->getFormFactory()
- ->createBuilderForProperty(
- 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup',
- 'options'
- )
- ->create('options', null, array(
- 'compound' => true,
- 'auto_initialize' => false,
- 'required' => false)
- );
- }
+ $optionBuilder = null;
+ if (count($customizableEntities[$group->getEntity()]['options']) > 0) {
+ $optionBuilder = $builder
+ ->getFormFactory()
+ ->createBuilderForProperty(CustomFieldsGroup::class, 'options')
+ ->create(
+ 'options',
+ null,
+ [
+ 'compound' => true,
+ 'auto_initialize' => false,
+ 'required' => false
+ ]
+ );
foreach($customizableEntities[$group->getEntity()]['options'] as $key => $option) {
- $optionBuilder
- ->add($key, $option['form_type'], $option['form_options'])
- ;
- }
- if (isset($optionBuilder) && $optionBuilder->count() > 0) {
- $form->add($optionBuilder->getForm());
+ $optionBuilder->add($key, $option['form_type'], $option['form_options']);
}
+ }
- });
+ if ((null !== $optionBuilder) && $optionBuilder->count() > 0) {
+ $form->add($optionBuilder->getForm());
+ }
+ });
}
- /**
- * @param OptionsResolverInterface $resolver
- */
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
- 'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'
- ));
+ $resolver->setDefaults([
+ 'data_class' => CustomFieldsGroup::class,
+ ]);
}
/**
diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php
index 848c63468..df69f5afa 100644
--- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php
+++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php
@@ -23,6 +23,7 @@ use ArrayIterator;
use Chill\EventBundle\Entity\Event;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Chill\EventBundle\Entity\Participation;
@@ -183,7 +184,7 @@ class ParticipationController extends AbstractController
$participations = $this->handleRequest($request, new Participation(), true);
$ignoredParticipations = $newParticipations = [];
- foreach ($participations as $i => $participation) {
+ foreach ($participations as $participation) {
// check for authorization
$this->denyAccessUnlessGranted(ParticipationVoter::CREATE,
$participation, 'The user is not allowed to create this participation');
@@ -218,7 +219,9 @@ class ParticipationController extends AbstractController
return $this->redirectToRoute('chill_event__event_show', array(
'event_id' => $request->query->getInt('event_id', 0)
));
- } elseif (count($newParticipations) > 1) {
+ }
+
+ if (count($newParticipations) > 1) {
// if we have multiple participations, show a form with multiple participations
$form = $this->createCreateFormMultiple($newParticipations);
@@ -372,9 +375,6 @@ class ParticipationController extends AbstractController
* If the request is multiple, the $participation object is cloned.
* Limitations: the $participation should not be persisted.
*
- * @param Request $request
- * @param Participation $participation
- * @param boolean $multiple (default false)
* @return Participation|Participations[] return one single participation if $multiple == false
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found
* @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person
@@ -382,7 +382,7 @@ class ParticipationController extends AbstractController
protected function handleRequest(
Request $request,
Participation $participation,
- $multiple = false)
+ bool $multiple = false)
{
$em = $this->getDoctrine()->getManager();
if ($em->contains($participation)) {
@@ -441,11 +441,9 @@ class ParticipationController extends AbstractController
}
/**
- * @param Participation $participation
* @param null $return_path
- * @return \Symfony\Component\Form\FormInterface
*/
- public function createCreateForm(Participation $participation, $return_path = null)
+ public function createCreateForm(Participation $participation, $return_path = null): FormInterface
{
$form = $this->createForm(ParticipationType::class, $participation, array(
@@ -464,11 +462,7 @@ class ParticipationController extends AbstractController
return $form;
}
- /**
- * @param array $participations
- * @return \Symfony\Component\Form\FormInterface
- */
- public function createCreateFormMultiple(array $participations)
+ public function createCreateFormMultiple(array $participations): FormInterface
{
$form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class,
array('participations' => $participations), array(
@@ -495,18 +489,16 @@ class ParticipationController extends AbstractController
}
/**
- * show an edit form for the participation with the given id.
+ * Show an edit form for the participation with the given id.
*
- * @param int $participation_id
- * @return \Symfony\Component\HttpFoundation\Response
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation
*/
- public function editAction($participation_id)
+ public function editAction(int $participation_id): Response
{
/* @var $participation Participation */
$participation = $this->getDoctrine()->getManager()
- ->getRepository('ChillEventBundle:Participation')
+ ->getRepository(Participation::class)
->find($participation_id);
if ($participation === NULL) {
@@ -518,22 +510,17 @@ class ParticipationController extends AbstractController
$form = $this->createEditForm($participation);
- return $this->render('ChillEventBundle:Participation:edit.html.twig', array(
+ return $this->render('ChillEventBundle:Participation:edit.html.twig', [
'form' => $form->createView(),
- 'participation' => $participation
- ));
+ 'participation' => $participation,
+ ]);
}
- /**
- * @param $participation_id
- * @param Request $request
- * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
- */
- public function updateAction($participation_id, Request $request)
+ public function updateAction(int $participation_id, Request $request): Response
{
/* @var $participation Participation */
$participation = $this->getDoctrine()->getManager()
- ->getRepository('ChillEventBundle:Participation')
+ ->getRepository(Participation::class)
->find($participation_id);
if ($participation === NULL) {
@@ -556,35 +543,40 @@ class ParticipationController extends AbstractController
'The participation was updated'
));
- return $this->redirectToRoute('chill_event__event_show', array(
- 'event_id' => $participation->getEvent()->getId()
- ));
+ return $this->redirectToRoute('chill_event__event_show', [
+ 'event_id' => $participation->getEvent()->getId(),
+ ]);
}
- return $this->render('ChillEventBundle:Participation:edit.html.twig', array(
+ return $this->render('ChillEventBundle:Participation:edit.html.twig', [
'form' => $form->createView(),
- 'participation' => $participation
- ));
+ 'participation' => $participation,
+ ]);
}
- /**
- *
- * @param Participation $participation
- * @return \Symfony\Component\Form\FormInterface
- */
- public function createEditForm(Participation $participation)
+ public function createEditForm(Participation $participation): FormInterface
{
- $form = $this->createForm(ParticipationType::class, $participation, array(
- 'event_type' => $participation->getEvent()->getType(),
- 'action' => $this->generateUrl('chill_event_participation_update', array(
- 'participation_id' => $participation->getId()
- ))
- ));
+ $form = $this->createForm(
+ ParticipationType::class,
+ $participation,
+ [
+ 'event_type' => $participation->getEvent()->getType(),
+ 'action' => $this->generateUrl(
+ 'chill_event_participation_update',
+ [
+ 'participation_id' => $participation->getId(),
+ ]
+ ),
+ ]
+ );
- $form->add('submit', SubmitType::class, array(
- 'label' => 'Edit'
- ));
+ $form->add(
+ 'submit',
+ SubmitType::class, [
+ 'label' => 'Edit',
+ ]
+ );
return $form;
}
diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
index 21090a61f..248419d7f 100644
--- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
+++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
@@ -1,27 +1,13 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Command;
use Chill\MainBundle\Doctrine\Model\Point;
use Chill\MainBundle\Entity\Country;
use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -31,38 +17,19 @@ use Symfony\Component\Filesystem\Filesystem;
use Chill\MainBundle\Entity\PostalCode;
use Symfony\Component\Validator\Validator\ValidatorInterface;
-/**
- * Class LoadPostalCodesCommand
- *
- * @package Chill\MainBundle\Command
- * @author Julien Fastré
- */
class LoadPostalCodesCommand extends Command
{
-
- /**
- * @var EntityManager
- */
- private $entityManager;
-
- /**
- * @var ValidatorInterface
- */
- private $validator;
-
- /**
- * LoadPostalCodesCommand constructor.
- *
- * @param EntityManager $entityManager
- * @param ValidatorInterface $validator
- */
- public function __construct(EntityManager $entityManager, ValidatorInterface $validator)
+ private EntityManagerInterface $entityManager;
+
+ private ValidatorInterface $validator;
+
+ public function __construct(EntityManagerInterface $entityManager, ValidatorInterface $validator)
{
$this->entityManager = $entityManager;
$this->validator = $validator;
parent::__construct();
}
-
+
protected function configure()
{
$this->setName('chill:main:postal-code:populate')
@@ -78,10 +45,10 @@ class LoadPostalCodesCommand extends Command
->addArgument('csv_file', InputArgument::REQUIRED, "the path to "
. "the csv file. See the help for specifications.")
->addOption(
- 'delimiter',
- 'd',
- InputOption::VALUE_OPTIONAL,
- "The delimiter character of the csv file",
+ 'delimiter',
+ 'd',
+ InputOption::VALUE_OPTIONAL,
+ "The delimiter character of the csv file",
",")
->addOption(
'enclosure',
@@ -99,31 +66,26 @@ class LoadPostalCodesCommand extends Command
)
;
}
-
+
protected function execute(InputInterface $input, OutputInterface $output)
{
- try {
- $csv = $this->getCSVResource($input);
- } catch (\RuntimeException $e) {
- $output->writeln('Error during opening the csv file : '.
- $e->getMessage().' ');
- }
-
+ $csv = $this->getCSVResource($input);
+
if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERY_VERBOSE) {
$output->writeln('The content of the file is ...');
$output->write(file_get_contents($input->getArgument('csv_file')));
}
-
+
$num = 0;
$line = 0;
-
+
while (($row = fgetcsv(
- $csv,
- 0,
- $input->getOption('delimiter'),
- $input->getOption('enclosure'),
+ $csv,
+ 0,
+ $input->getOption('delimiter'),
+ $input->getOption('enclosure'),
$input->getOption('escape'))) !== false) {
-
+
try{
$this->addPostalCode($row, $output);
$num++;
@@ -136,31 +98,31 @@ class LoadPostalCodesCommand extends Command
}
$line ++;
}
-
+
$this->entityManager->flush();
-
+
$output->writeln(''.$num.' were added ! ');
}
-
+
private function getCSVResource(InputInterface $input)
{
$fs = new Filesystem();
$filename = $input->getArgument('csv_file');
-
+
if (!$fs->exists($filename)) {
throw new \RuntimeException("The file does not exists or you do not "
. "have the right to read it.");
}
-
+
$resource = fopen($filename, 'r');
-
+
if ($resource == FALSE) {
throw new \RuntimeException("The file '$filename' could not be opened.");
}
-
+
return $resource;
}
-
+
private function addPostalCode($row, OutputInterface $output)
{
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
@@ -170,28 +132,28 @@ class LoadPostalCodesCommand extends Command
$country = $em
->getRepository(Country::class)
->findOneBy(array('countryCode' => $row[2]));
-
+
if ($country === NULL) {
throw new CountryCodeNotFoundException(sprintf("The country with code %s is not found. Aborting to insert postal code with %s - %s",
$row[2], $row[0], $row[1]));
}
-
+
// try to find an existing postal code
$existingPC = $em
->getRepository(PostalCode::class)
->findBy(array('code' => $row[0], 'name' => $row[1]));
-
+
if (count($existingPC) > 0) {
- throw new ExistingPostalCodeException(sprintf("A postal code with code : %s and name : %s already exists, skipping",
+ throw new ExistingPostalCodeException(sprintf("A postal code with code : %s and name : %s already exists, skipping",
$row[0], $row[1]));
}
-
+
$postalCode = (new PostalCode())
->setCode($row[0])
->setName($row[1])
->setCountry($country)
;
-
+
if (NULL != $row[3]){
$postalCode->setRefPostalCodeId($row[3]);
}
@@ -205,7 +167,7 @@ class LoadPostalCodesCommand extends Command
}
$errors = $this->validator->validate($postalCode);
-
+
if ($errors->count() == 0) {
$em->persist($postalCode);
} else {
@@ -213,12 +175,12 @@ class LoadPostalCodesCommand extends Command
foreach ($errors as $error) {
$msg .= " ".$error->getMessage();
}
-
+
throw new PostalCodeNotValidException($msg);
}
-
-
-
+
+
+
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln(sprintf('Creating postal code with code: %s, name: %s, countryCode: %s',
$postalCode->getCode(), $postalCode->getName(), $postalCode->getCountry()->getCountryCode()));
@@ -229,15 +191,15 @@ class LoadPostalCodesCommand extends Command
class ExistingPostalCodeException extends \Exception
{
-
+
}
class CountryCodeNotFoundException extends \Exception
{
-
+
}
class PostalCodeNotValidException extends \Exception
{
-
+
}
diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php
index ae9df72f4..083567960 100644
--- a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php
+++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php
@@ -1,58 +1,43 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\MainBundle\Doctrine\DQL;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
+use Doctrine\ORM\Query\AST\PathExpression;
use Doctrine\ORM\Query\Lexer;
+use Doctrine\ORM\Query\Parser;
/**
* DQL function for OVERLAPS function in postgresql
- *
- * If a value is null in period start, it will be replaced by -infinity.
+ *
+ * If a value is null in period start, it will be replaced by -infinity.
* If a value is null in period end, it will be replaced by infinity
- *
*/
class OverlapsI extends FunctionNode
{
private $firstPeriodStart;
-
+
private $firstPeriodEnd;
-
+
private $secondPeriodStart;
-
+
private $secondPeriodEnd;
-
+
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
- return '('
- .$this->makeCase($sqlWalker, $this->firstPeriodStart, 'start').', '
- .$this->makeCase($sqlWalker, $this->firstPeriodEnd, 'end').
- ') OVERLAPS ('
- .$this->makeCase($sqlWalker, $this->secondPeriodStart, 'start').', '
- .$this->makeCase($sqlWalker, $this->secondPeriodEnd, 'end').')'
- ;
+ return sprintf(
+ '(%s, %s) OVERLAPS (%s, %s)',
+ $this->makeCase($sqlWalker, $this->firstPeriodStart, 'start'),
+ $this->makeCase($sqlWalker, $this->firstPeriodEnd, 'end'),
+ $this->makeCase($sqlWalker, $this->secondPeriodStart, 'start'),
+ $this->makeCase($sqlWalker, $this->secondPeriodEnd, 'end')
+ );
}
-
- protected function makeCase($sqlWalker, $part, $position)
+
+ protected function makeCase($sqlWalker, $part, string $position): string
{
- //return $part->dispatch($sqlWalker);
-
switch ($position) {
case 'start' :
$p = '-infinity';
@@ -60,51 +45,51 @@ class OverlapsI extends FunctionNode
case 'end':
$p = 'infinity';
break;
+ default:
+ throw new \Exception('Unexpected position value.');
}
-
- if ($part instanceof \Doctrine\ORM\Query\AST\PathExpression) {
- return 'CASE WHEN '
- .' '.$part->dispatch($sqlWalker).' IS NOT NULL '
- . 'THEN '.
- $part->dispatch($sqlWalker)
- . ' ELSE '.
- "'".$p."'::date "
- . 'END';
- } else {
- return 'CASE WHEN '
- .' '.$part->dispatch($sqlWalker).'::date IS NOT NULL '
- . 'THEN '.
- $part->dispatch($sqlWalker)
- . '::date ELSE '.
- "'".$p."'::date "
- . 'END';
+
+ if ($part instanceof PathExpression) {
+ return sprintf(
+ "CASE WHEN %s IS NOT NULL THEN %s ELSE '%s'::date END",
+ $part->dispatch($sqlWalker),
+ $part->dispatch($sqlWalker),
+ $p
+ );
}
+
+ return sprintf(
+ "CASE WHEN %s::date IS NOT NULL THEN %s::date ELSE '%s'::date END",
+ $part->dispatch($sqlWalker),
+ $part->dispatch($sqlWalker),
+ $p
+ );
}
- public function parse(\Doctrine\ORM\Query\Parser $parser)
+ public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
-
+
$parser->match(Lexer::T_OPEN_PARENTHESIS);
-
+
$this->firstPeriodStart = $parser->StringPrimary();
-
+
$parser->match(Lexer::T_COMMA);
-
+
$this->firstPeriodEnd = $parser->StringPrimary();
-
+
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
-
+
$parser->match(Lexer::T_COMMA);
-
+
$parser->match(Lexer::T_OPEN_PARENTHESIS);
-
+
$this->secondPeriodStart = $parser->StringPrimary();
-
+
$parser->match(Lexer::T_COMMA);
-
+
$this->secondPeriodEnd = $parser->StringPrimary();
-
+
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
index e77556a43..d64de7ae6 100644
--- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
+++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php
@@ -1,48 +1,25 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Export\Formatter;
-use Chill\MainBundle\Export\ExportInterface;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
use Chill\MainBundle\Export\FormatterInterface;
-use Symfony\Component\Translation\TranslatorInterface;
-use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
use Chill\MainBundle\Export\ExportManager;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-// command to get the report with curl : curl --user "center a_social:password" "http://localhost:8000/fr/exports/generate/count_person?export[filters][person_gender_filter][enabled]=&export[filters][person_nationality_filter][enabled]=&export[filters][person_nationality_filter][form][nationalities]=&export[aggregators][person_nationality_aggregator][order]=1&export[aggregators][person_nationality_aggregator][form][group_by_level]=country&export[submit]=&export[_token]=RHpjHl389GrK-bd6iY5NsEqrD5UKOTHH40QKE9J1edU" --globoff
-
/**
- *
- *
- * @author Julien Fastré
+ * Command to get the report with curl:
+ * curl --user "center a_social:password" "http://localhost:8000/fr/exports/generate/count_person?export[filters][person_gender_filter][enabled]=&export[filters][person_nationality_filter][enabled]=&export[filters][person_nationality_filter][form][nationalities]=&export[aggregators][person_nationality_aggregator][order]=1&export[aggregators][person_nationality_aggregator][form][group_by_level]=country&export[submit]=&export[_token]=RHpjHl389GrK-bd6iY5NsEqrD5UKOTHH40QKE9J1edU" --globoff
* @deprecated this formatter is not used any more.
*/
class CSVFormatter implements FormatterInterface
{
- /**
- *
- * @var TranslatorInterface
- */
- protected $translator;
+ protected TranslatorInterface $translator;
protected $result;
@@ -85,11 +62,7 @@ class CSVFormatter implements FormatterInterface
}
/**
- *
* @uses appendAggregatorForm
- * @param FormBuilderInterface $builder
- * @param type $exportAlias
- * @param array $aggregatorAliases
*/
public function buildForm(FormBuilderInterface $builder, $exportAlias, array $aggregatorAliases)
{
@@ -172,20 +145,35 @@ class CSVFormatter implements FormatterInterface
* If two aggregators have the same order, the second given will be placed
* after. This is not significant for the first ordering.
*
- * @param type $formatterData
- * @return type
*/
- protected function orderingHeaders($formatterData)
+ protected function orderingHeaders(array $formatterData)
{
$this->formatterData = $formatterData;
- uasort($this->formatterData, function($a, $b) {
+ uasort(
+ $this->formatterData,
+ static fn(array $a, array $b): int => ($a['order'] <= $b['order'] ? -1 : 1)
+ );
+ }
- return ($a['order'] <= $b['order'] ? -1 : 1);
- });
+ private function findColumnPosition(&$columnHeaders, $columnToFind): int
+ {
+ $i = 0;
+ foreach($columnHeaders as $set) {
+ if ($set === $columnToFind) {
+ return $i;
+ }
+ $i++;
+ }
+
+ //we didn't find it, adding the column
+ $columnHeaders[] = $columnToFind;
+
+ return $i++;
}
protected function generateContent()
{
+ $line = null;
$rowKeysNb = count($this->getRowHeaders());
$columnKeysNb = count($this->getColumnHeaders());
$resultsKeysNb = count($this->export->getQueryKeys($this->exportData));
@@ -196,21 +184,6 @@ class CSVFormatter implements FormatterInterface
$contentData = array();
$content = array();
- function findColumnPosition(&$columnHeaders, $columnToFind) {
- $i = 0;
- foreach($columnHeaders as $set) {
- if ($set === $columnToFind) {
- return $i;
- }
- $i++;
- }
-
- //we didn't find it, adding the column
- $columnHeaders[] = $columnToFind;
-
- return $i++;
- }
-
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
@@ -244,7 +217,7 @@ class CSVFormatter implements FormatterInterface
// add the column headers
/* @var $columns string[] the column for this row */
$columns = array_slice($row, $rowKeysNb, $columnKeysNb);
- $columnPosition = findColumnPosition($columnHeaders, $columns);
+ $columnPosition = $this->findColumnPosition($columnHeaders, $columns);
//fill with blank at the position given by the columnPosition + nbRowHeaders
for ($i=0; $i < $columnPosition; $i++) {
diff --git a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
index 8922a9bb8..99bac1e5a 100644
--- a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
+++ b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
@@ -4,6 +4,8 @@ namespace Chill\PersonBundle\Command;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\NonUniqueResultException;
+use Doctrine\ORM\NoResultException;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
@@ -360,6 +362,7 @@ EOF
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $headers = $rawHeaders = [];
$this->input = $input;
$this->output = $output;
@@ -453,15 +456,15 @@ EOF
}
/**
- *
- * @param type $firstRow
* @return array where keys are column number, and value is information mapped
*/
- protected function processingHeaders($firstRow)
+ protected function processingHeaders(array $firstRow): array
{
- $availableOptions = array_map(function($m) { return $m[0]; }, self::$mapping);
- $matchedColumnHeaders = array();
- $headers = array();
+ $availableOptions = array_map(
+ static fn (array $m) => $m[0],
+ self::$mapping
+ );
+ $matchedColumnHeaders = $headers = [];
foreach($availableOptions as $option) {
$matchedColumnHeaders[$option] = $this->input->getOption($option);
@@ -482,13 +485,10 @@ EOF
}
/**
- *
- * @param array $row
* @param array $headers the processed header : an array as prepared by self::processingHeaders
- * @return Person
* @throws \Exception
*/
- protected function createPerson($row, $headers)
+ protected function createPerson(array $row, array $headers): Person
{
// trying to get the opening date
$openingDateString = trim($row[array_search('opening_date', $headers)]);
@@ -580,30 +580,27 @@ EOF
}
/**
- * @param $row
- * @param $headers
* @return Center|mixed|null|object
*/
- protected function getCenter($row, $headers)
+ protected function getCenter(array $row, array $headers)
{
if ($this->input->hasOption('force-center') && !empty($this->input->getOption('force-center'))) {
- return $this->em->getRepository('ChillMainBundle:Center')
- ->find($this->input->getOption('force-center'));
- } else {
- $columnCenter = \array_search('center', $headers);
- $centerName = \trim($row[$columnCenter]);
+ return $this->em->getRepository(Center::class)->find($this->input->getOption('force-center'));
+ }
- try {
- return $this->em->createQuery('SELECT c FROM ChillMainBundle:Center c '
- . 'WHERE c.name = :center_name')
- ->setParameter('center_name', $centerName)
- ->getSingleResult()
- ;
- } catch (\Doctrine\ORM\NonUniqueResultException $e) {
- return $this->guessCenter($centerName);
- } catch (\Doctrine\ORM\NoResultException $e) {
- return $this->guessCenter($centerName);
- }
+ $columnCenter = array_search('center', $headers);
+ $centerName = trim($row[$columnCenter]);
+
+ try {
+ return $this
+ ->em
+ ->createQuery('SELECT c FROM ChillMainBundle:Center c WHERE c.name = :center_name')
+ ->setParameter('center_name', $centerName)
+ ->getSingleResult();
+ } catch (NonUniqueResultException $e) {
+ return $this->guessCenter($centerName);
+ } catch (NoResultException $e) {
+ return $this->guessCenter($centerName);
}
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 98c4dbb0e..5ea7aaf00 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -76,13 +76,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
{
/**
* The person's id
- * @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private $id;
+ private int $id;
/**
* The person's first name
@@ -732,12 +731,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return false;
}
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
+ public function getId(): int
{
return $this->id;
}
@@ -1846,7 +1840,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
{
return $this->updatedBy;
}
-
+
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
diff --git a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php
index 4683344dd..5a6da93ae 100644
--- a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php
+++ b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php
@@ -274,6 +274,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
$jsonCriterias
);
+ $entity = null;
+
switch (true) {
case count($results) === 0:
$entity = $repository->getClassName();
@@ -291,6 +293,10 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
);
}
+ if (null === $entity) {
+ throw new Exception('Unable to create entity.');
+ }
+
return $entity;
}
diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
index d8944ae93..7325cc79e 100644
--- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
+++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
@@ -1,5 +1,7 @@
getDoctrine()->getManager();
$task = $em->getRepository(SingleTask::class)->find($id);
- if (!$task) {
+ if (null === $task) {
throw $this->createNotFoundException('Unable to find Task entity.');
}
@@ -415,19 +408,24 @@ final class SingleTaskController extends AbstractController
}
}
- if($task->getContext() instanceof Person){
- return $this->render('@ChillTask/SingleTask/Person/confirm_delete.html.twig', array(
- 'task' => $task,
- 'delete_form' => $form->createView()
- ));
- } else {
- return $this->render('@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig', array(
- 'task' => $task,
- 'delete_form' => $form->createView(),
- 'accompanyingCourse' => $course
- ));
+ if ($task->getContext() instanceof Person) {
+ return $this->render(
+ '@ChillTask/SingleTask/Person/confirm_delete.html.twig',
+ [
+ 'task' => $task,
+ 'delete_form' => $form->createView(),
+ ]
+ );
}
+ return $this->render(
+ '@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig',
+ [
+ 'task' => $task,
+ 'delete_form' => $form->createView(),
+ 'accompanyingCourse' => $course
+ ]
+ );
}
/**
diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
index a3dd1777f..85fe632b7 100644
--- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
+++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
@@ -1,20 +1,7 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\TaskBundle\Form;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
@@ -48,6 +35,9 @@ class SingleTaskType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
+ $center = null;
+ $isScopeConcerned = false;
+
if (NULL !== $task = $options['data']) {
$center = $this->centerResolverDispatcher->resolveCenter($task);
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($task);
@@ -74,8 +64,7 @@ class SingleTaskType extends AbstractType
'required' => false
]);
- if ($this->parameterBag->get('chill_main')['acl']['form_show_scopes']
- && $isScopeConcerned) {
+ if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
$builder
->add('circle', ScopePickerType::class, [
'center' => $center,
From a3eb23478a2de66088243bc3433f96f5a03e12e3 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 11:52:52 +0100
Subject: [PATCH 154/227] fix: SA: Fix "Call to sprintf" rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 20 -----
.../CustomFieldsGroupToIdTransformer.php | 27 ++++---
.../CRUD/Controller/CRUDController.php | 79 +++++++------------
.../Security/UserProvider/UserProvider.php | 52 ++++--------
4 files changed, 62 insertions(+), 116 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 014dd0b57..dba0fad72 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -235,11 +235,6 @@ parameters:
count: 1
path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php
- -
- message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
-
-
message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
count: 3
@@ -385,11 +380,6 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
- -
- message: "#^Call to sprintf contains 2 placeholders, 0 values given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
@@ -405,11 +395,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
- -
- message: "#^Method Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\:\\:createNotFoundException\\(\\) invoked with 3 parameters, 0\\-2 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
-
message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
count: 1
@@ -795,11 +780,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php
- -
- message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php
-
-
message: "#^Variable \\$message on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
index f637281ba..31708b582 100644
--- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
+++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
@@ -33,12 +33,12 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
if (null === $customFieldsGroup) {
return "";
}
-
+
if (!$customFieldsGroup instanceof CustomFieldsGroup) {
throw new TransformationFailedException(sprintf('Transformation failed: '
. 'the expected type of the transforme function is an '
. 'object of type Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
- . '%s given (value : %s)', gettype($customFieldsGroup),
+ . '%s given (value : %s)', gettype($customFieldsGroup),
$customFieldsGroup));
}
@@ -57,26 +57,31 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
if (!$id) {
return null;
}
-
+
if ($id instanceof CustomFieldsGroup) {
- throw new TransformationFailedException(sprintf(
+ throw new TransformationFailedException(
+ sprintf(
'The transformation failed: the expected argument on '
. 'reverseTransform is an object of type int,'
. 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
- . 'given', gettype($id)));
+ . 'given'
+ )
+ );
}
$customFieldsGroup = $this->om
- ->getRepository('ChillCustomFieldsBundle:customFieldsGroup')->find($id)
+ ->getRepository(CustomFieldsGroup::class)->find($id)
;
if (null === $customFieldsGroup) {
- throw new TransformationFailedException(sprintf(
- 'Le group avec le numéro "%s" ne peut pas être trouvé!',
- $id
- ));
+ throw new TransformationFailedException(
+ sprintf(
+ 'Le group avec le numéro "%s" ne peut pas être trouvé!',
+ $id
+ )
+ );
}
return $customFieldsGroup;
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
index d3112fd97..3f4fb8414 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
@@ -1,22 +1,4 @@
- *
- * 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 .
- */
namespace Chill\MainBundle\CRUD\Controller;
@@ -37,58 +19,38 @@ use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Serializer\SerializerInterface;
-/**
- * Class CRUDController
- *
- * @package Chill\MainBundle\CRUD\Controller
- */
class CRUDController extends AbstractController
{
-
/**
* The crud configuration
*
* This configuration si defined by `chill_main['crud']`.
- *
- * @var array
*/
- protected $crudConfig;
+ protected array $crudConfig;
- /**
- * @param array $config
- */
- public function setCrudConfig(array $config)
+ public function setCrudConfig(array $config): void
{
$this->crudConfig = $config;
}
- /**
- * @param $parameter
- * @return Response
- */
- public function CRUD($parameter)
+ public function CRUD(?string $parameter): Response
{
return new Response($parameter);
}
/**
- * @param Request $request
* @param $id
- * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
- public function delete(Request $request, $id)
+ public function delete(Request $request, $id): Response
{
return $this->deleteAction('delete', $request, $id);
}
/**
- * @param string $action
- * @param Request $request
* @param $id
* @param null $formClass
- * @return null|\Symfony\Component\HttpFoundation\RedirectResponse|Response|void
*/
- protected function deleteAction(string $action, Request $request, $id, $formClass = null)
+ protected function deleteAction(string $action, Request $request, $id, $formClass = null): Response
{
$this->onPreDelete($action, $request, $id);
@@ -101,8 +63,13 @@ class CRUDController extends AbstractController
}
if (NULL === $entity) {
- throw $this->createNotFoundException(sprintf("The %s with id %s "
- . "is not found"), $this->getCrudName(), $id);
+ throw $this->createNotFoundException(
+ sprintf(
+ 'The %s with id %s is not found',
+ $this->getCrudName(),
+ $id
+ )
+ );
}
$response = $this->checkACL($action, $entity);
@@ -141,7 +108,9 @@ class CRUDController extends AbstractController
return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', ['id' => $entity->getId()]);
- } elseif ($form->isSubmitted()) {
+ }
+
+ if ($form->isSubmitted()) {
$this->addFlash('error', $this->generateFormErrorMessage($action, $form));
}
@@ -505,8 +474,13 @@ class CRUDController extends AbstractController
}
if (NULL === $entity) {
- throw $this->createNotFoundException(sprintf("The %s with id %s "
- . "is not found", $this->getCrudName(), $id));
+ throw $this->createNotFoundException(
+ sprintf(
+ 'The %s with id %s is not found',
+ $this->getCrudName(),
+ $id
+ )
+ );
}
$response = $this->checkACL($action, $entity);
@@ -598,8 +572,13 @@ class CRUDController extends AbstractController
$entity = $this->getEntity($action, $id, $request);
if (NULL === $entity) {
- throw $this->createNotFoundException(sprintf("The %s with id %s "
- . "is not found", $this->getCrudName(), $id));
+ throw $this->createNotFoundException(
+ sprintf(
+ 'The %s with id %s is not found',
+ $this->getCrudName(),
+ $id
+ )
+ );
}
$response = $this->checkACL($action, $entity);
diff --git a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php
index b741fd2c2..b2e09775b 100644
--- a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php
+++ b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php
@@ -1,22 +1,10 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\MainBundle\Security\UserProvider;
+use Doctrine\ORM\NoResultException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityManagerInterface;
@@ -24,25 +12,15 @@ use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
-/**
- *
- *
- * @author Julien Fastré
- */
class UserProvider implements UserProviderInterface
{
- /**
- *
- * @var EntityManagerInterface
- */
- protected $em;
-
+ protected EntityManagerInterface $em;
+
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
-
public function loadUserByUsername($username): UserInterface
{
try {
@@ -50,14 +28,18 @@ class UserProvider implements UserProviderInterface
"SELECT u FROM %s u "
. "WHERE u.usernameCanonical = UNACCENT(LOWER(:pattern)) "
. "OR "
- . "u.emailCanonical = UNACCENT(LOWER(:pattern))",
+ . "u.emailCanonical = UNACCENT(LOWER(:pattern))",
User::class))
->setParameter('pattern', $username)
->getSingleResult();
- } catch (\Doctrine\ORM\NoResultException $e) {
- throw new UsernameNotFoundException(sprintf('Bad credentials.', $username));
+ } catch (NoResultException $e) {
+ throw new UsernameNotFoundException(
+ sprintf('Bad credentials.'),
+ 0,
+ $e
+ );
}
-
+
return $user;
}
@@ -66,13 +48,13 @@ class UserProvider implements UserProviderInterface
if (!$user instanceof User) {
throw new UnsupportedUserException("Unsupported user class: cannot reload this user");
}
-
+
$reloadedUser = $this->em->getRepository(User::class)->find($user->getId());
-
+
if (NULL === $reloadedUser) {
throw new UsernameNotFoundException(sprintf('User with ID "%s" could not be reloaded.', $user->getId()));
}
-
+
return $reloadedUser;
}
From c68bda5c9b894236860fe1bacca8c9467052eb07 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 12:16:02 +0100
Subject: [PATCH 155/227] fix: SA: Fix "...invoked with..." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 65 --------
.../Timeline/TimelineActivityProvider.php | 157 ++++++------------
.../Controller/AsideActivityController.php | 5 +-
.../Controller/DocumentCategoryController.php | 29 ++--
.../CRUD/Controller/ApiController.php | 114 ++++++-------
.../CRUD/Controller/CRUDController.php | 13 +-
.../Controller/UserController.php | 83 ++++-----
.../ChillMainBundle/Search/SearchApi.php | 9 +-
.../Authorization/AuthorizationHelper.php | 38 ++---
.../Command/ImportPeopleFromCSVCommand.php | 1 +
.../ChillPersonBundle/Entity/Person.php | 24 +--
11 files changed, 183 insertions(+), 355 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index dba0fad72..7b09a7d50 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -85,16 +85,6 @@ parameters:
count: 2
path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
- -
- message: "#^Method Chill\\\\ActivityBundle\\\\Timeline\\\\TimelineActivityProvider\\:\\:getFromClausePerson\\(\\) invoked with 1 parameter, 0 required\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php
-
-
message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
count: 2
@@ -250,11 +240,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
- -
- message: "#^Class Chill\\\\DocStoreBundle\\\\Entity\\\\DocumentCategory constructor invoked with 0 parameters, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
@@ -360,16 +345,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getEntity\\(\\) invoked with 4 parameters, 3 required\\.$#"
- count: 3
- path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\ApiController\\:\\:entityPostAction\\(\\) invoked with 4 parameters, 3 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
-
-
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
count: 1
@@ -385,16 +360,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:onPreDelete\\(\\) invoked with 3 parameters, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
-
message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
count: 1
@@ -520,21 +485,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Controller/UserController.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createAddLinkGroupCenterForm\\(\\) invoked with 1 parameter, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/UserController.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditPasswordForm\\(\\) invoked with 2 parameters, 1 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/UserController.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:getDeleteLinkGroupCenterByUser\\(\\) invoked with 1 parameter, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/UserController.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -720,11 +670,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\Search\\\\SearchApi\\:\\:buildUnionQuery\\(\\) invoked with 4 parameters, 3 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Search/SearchApi.php
-
-
message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
count: 2
@@ -750,11 +695,6 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:userCanReachCenter\\(\\) invoked with 3 parameters, 2 required\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -945,11 +885,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Entity/Person.php
- -
- message: "#^Method Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:getCurrentPersonAddress\\(\\) invoked with 1 parameter, 0 required\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/Person.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
diff --git a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
index a1c6b6c65..fb0a5c45c 100644
--- a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
+++ b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
@@ -1,94 +1,53 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Timeline;
+use Chill\MainBundle\Entity\User;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Timeline\TimelineProviderInterface;
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
-use Doctrine\ORM\EntityManager;
-use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
+use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
-use Doctrine\ORM\Mapping\ClassMetadata;
use Chill\PersonBundle\Entity\Person;
-use Chill\MainBundle\Entity\Scope;
use Chill\ActivityBundle\Entity\Activity;
use Chill\MainBundle\Timeline\TimelineSingleQuery;
+use Symfony\Component\Security\Core\User\UserInterface;
-/**
- * Provide activity for inclusion in timeline
- *
-*/
class TimelineActivityProvider implements TimelineProviderInterface
{
-
- /**
- *
- * @var EntityManager
- */
- protected $em;
-
- /**
- *
- * @var AuthorizationHelper
- */
- protected $helper;
-
- /**
- *
- * @var \Chill\MainBundle\Entity\User
- */
- protected $user;
+ protected EntityManagerInterface $em;
+
+ protected AuthorizationHelperInterface $helper;
+
+ protected UserInterface $user;
protected ActivityACLAwareRepository $aclAwareRepository;
private const SUPPORTED_CONTEXTS = [ 'center', 'person'];
-
- /**
- * TimelineActivityProvider constructor.
- *
- * @param EntityManager $em
- * @param AuthorizationHelper $helper
- * @param TokenStorageInterface $storage
- */
+
public function __construct(
- EntityManager $em,
- AuthorizationHelper $helper,
+ EntityManagerInterface $em,
+ AuthorizationHelperInterface $helper,
TokenStorageInterface $storage,
ActivityACLAwareRepository $aclAwareRepository
- )
- {
+ ) {
$this->em = $em;
$this->helper = $helper;
$this->aclAwareRepository = $aclAwareRepository;
-
- if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
+
+ if (!$storage->getToken()->getUser() instanceof User)
{
throw new \RuntimeException('A user should be authenticated !');
}
-
+
$this->user = $storage->getToken()->getUser();
}
-
+
/**
- *
+ *
* {@inheritDoc}
*/
public function fetchQuery($context, array $args)
@@ -97,23 +56,23 @@ class TimelineActivityProvider implements TimelineProviderInterface
return TimelineSingleQuery::fromArray($this->aclAwareRepository
->queryTimelineIndexer($context, $args));
}
-
+
$metadataActivity = $this->em->getClassMetadata(Activity::class);
[$where, $parameters] = $this->getWhereClauseForPerson($args['person']);
-
+
return TimelineSingleQuery::fromArray([
'id' => $metadataActivity->getTableName()
.'.'.$metadataActivity->getColumnName('id'),
'type' => 'activity',
'date' => $metadataActivity->getTableName()
.'.'.$metadataActivity->getColumnName('date'),
- 'FROM' => $this->getFromClausePerson($args['person']),
+ 'FROM' => $this->getFromClausePerson(),
'WHERE' => $where,
'parameters' => $parameters
]);
}
-
+
private function getWhereClauseForPerson(Person $person)
{
$parameters = [];
@@ -125,15 +84,15 @@ class TimelineActivityProvider implements TimelineProviderInterface
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
$scopes_ids = [];
- // first parameter: activity.person_id
+ // first parameter: activity.person_id
$parameters[] = $person->getId();
- // loop on reachable scopes
+ // loop on reachable scopes
foreach ($reachableScopes as $scope) {
if (\in_array($scope->getId(), $scopes_ids)) {
continue;
}
- $scopes_ids[] = '?';
+ $scopes_ids[] = '?';
$parameters[] = $scope->getId();
}
@@ -151,47 +110,40 @@ class TimelineActivityProvider implements TimelineProviderInterface
$parameters
];
}
-
- private function getFromClausePerson()
+
+ private function getFromClausePerson(): string
{
$metadataActivity = $this->em->getClassMetadata(Activity::class);
$metadataPerson = $this->em->getClassMetadata(Person::class);
$associationMapping = $metadataActivity->getAssociationMapping('person');
-
- return $metadataActivity->getTableName().' JOIN '
- .$metadataPerson->getTableName().' ON '
- .$metadataPerson->getTableName().'.'.
- $associationMapping['joinColumns'][0]['referencedColumnName']
- .' = '
- .$associationMapping['joinColumns'][0]['name']
- ;
+
+ return sprintf(
+ "%s JOIN %s ON %s.%s = %s",
+ $metadataActivity->getTableName(),
+ $metadataPerson->getTableName(),
+ $metadataPerson->getTableName(),
+ $associationMapping['joinColumns'][0]['referencedColumnName'],
+ $associationMapping['joinColumns'][0]['name']
+ );
}
-
- /**
- *
- * {@inheritDoc}
- */
- public function getEntities(array $ids)
+
+ public function getEntities(array $ids): array
{
$activities = $this->em->getRepository(Activity::class)
->findBy(array('id' => $ids));
-
+
$result = array();
foreach($activities as $activity) {
$result[$activity->getId()] = $activity;
}
-
+
return $result;
}
- /**
- *
- * {@inheritDoc}
- */
- public function getEntityTemplate($entity, $context, array $args)
+ public function getEntityTemplate($entity, $context, array $args): array
{
$this->checkContext($context);
-
+
return [
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
'template_data' => [
@@ -201,26 +153,25 @@ class TimelineActivityProvider implements TimelineProviderInterface
];
}
- /**
- *
- * {@inheritDoc}
- */
- public function supportsType($type)
+ public function supportsType($type): bool
{
return $type === 'activity';
}
-
+
/**
- * check if the context is supported
- *
- * @param string $context
+ * Check if the context is supported.
+ *
* @throws \LogicException if the context is not supported
*/
- private function checkContext($context)
+ private function checkContext(string $context)
{
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
- throw new \LogicException("The context '$context' is not "
- . "supported. Currently only 'person' is supported");
+ throw new \LogicException(
+ sprintf(
+ "The context '%s' is not supported. Currently only 'person' is supported",
+ $context
+ )
+ );
}
}
diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php
index 3e3b38033..9e9964314 100644
--- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php
+++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php
@@ -15,8 +15,7 @@ use Doctrine\Common\Collections\Criteria;
final class AsideActivityController extends CRUDController
{
-
- private $categoryRepository;
+ private AsideActivityCategoryRepository $categoryRepository;
public function __construct(AsideActivityCategoryRepository $categoryRepository)
{
@@ -25,7 +24,7 @@ final class AsideActivityController extends CRUDController
protected function buildQueryEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null)
{
- $qb = parent::buildQueryEntities($action, $request, $filterOrder);
+ $qb = parent::buildQueryEntities($action, $request);
if ('index' === $action) {
$qb->where($qb->expr()->eq('e.agent', ':user'));
diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
index 4d2d3246e..301487fd7 100644
--- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
+++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php
@@ -1,5 +1,7 @@
getDoctrine()->getManager();
- $categories = $em->getRepository("ChillDocStoreBundle:DocumentCategory")->findAll();
+ $categories = $em->getRepository(DocumentCategory::class)->findAll();
return $this->render(
'ChillDocStoreBundle:DocumentCategory:index.html.twig',
- ['document_categories' => $categories]);
+ [
+ 'document_categories' => $categories,
+ ]
+ );
}
/**
@@ -37,13 +40,10 @@ class DocumentCategoryController extends AbstractController
public function new(Request $request): Response
{
$em = $this->getDoctrine()->getManager();
- $documentCategory = new DocumentCategory();
- $documentCategory
- ->setBundleId('Chill\DocStoreBundle\ChillDocStoreBundle');
- $documentCategory
- ->setIdInsideBundle(
- $em->getRepository("ChillDocStoreBundle:DocumentCategory")
- ->nextIdInsideBundle());
+ $documentCategory = new DocumentCategory(
+ ChillDocStoreBundle::class,
+ $em->getRepository(DocumentCategory::class)->nextIdInsideBundle()
+ );
$documentCategory
->setDocumentClass(PersonDocument::class);
@@ -56,11 +56,10 @@ class DocumentCategoryController extends AbstractController
$em->flush();
return $this->redirectToRoute('document_category_index');
- } else {
- $documentCategory->setBundleId(
- 'Chill\DocStoreBundle\ChillDocStoreBundle');
}
+ $documentCategory->setBundleId(ChillDocStoreBundle::class);
+
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
'document_category' => $documentCategory,
'form' => $form->createView(),
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
index e3717f654..a2555bf81 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
@@ -1,5 +1,7 @@
getEntity($action, $id, $request, $_format);
-
+ $entity = $this->getEntity($action, $id, $request);
+
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
-
+
if ($postFetch instanceof Response) {
return $postFetch;
}
-
+
$response = $this->checkACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
}
-
+
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
@@ -86,7 +88,7 @@ class ApiController extends AbstractCRUDController
case Request::METHOD_PATCH:
return $this->entityPut('_entity', $request, $id, $_format);
case Request::METHOD_POST:
- return $this->entityPostAction('_entity', $request, $id, $_format);
+ return $this->entityPostAction('_entity', $request, $id);
case Request::METHOD_DELETE:
return $this->entityDelete('_entity', $request, $id, $_format);
default:
@@ -112,9 +114,9 @@ class ApiController extends AbstractCRUDController
} catch (NotEncodableValueException $e) {
throw new BadRequestException("invalid json", 400, $e);
}
-
+
$errors = $this->validate($action, $request, $_format, $entity);
-
+
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors);
if ($response instanceof Response) {
return $response;
@@ -126,12 +128,12 @@ class ApiController extends AbstractCRUDController
return $response;
}
-
+
$response = $this->checkACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
}
-
+
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
@@ -148,33 +150,33 @@ class ApiController extends AbstractCRUDController
if ($response instanceof Response) {
return $response;
}
-
+
return $this->json(
$entity,
Response::HTTP_OK,
- [],
+ [],
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
);
}
public function entityPut($action, Request $request, $id, string $_format): Response
{
- $entity = $this->getEntity($action, $id, $request, $_format);
-
+ $entity = $this->getEntity($action, $id, $request);
+
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
if ($postFetch instanceof Response) {
return $postFetch;
}
-
+
if (NULL === $entity) {
throw $this->createNotFoundException(sprintf("The %s with id %s "
. "is not found", $this->getCrudName(), $id));
}
-
+
$response = $this->checkACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
}
-
+
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
@@ -184,7 +186,7 @@ class ApiController extends AbstractCRUDController
if ($response instanceof Response) {
return $response;
}
-
+
try {
$entity = $this->deserialize($action, $request, $_format, $entity);
} catch (NotEncodableValueException $e) {
@@ -215,13 +217,13 @@ class ApiController extends AbstractCRUDController
return $this->json(
$entity,
Response::HTTP_OK,
- [],
+ [],
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
);
}
public function entityDelete($action, Request $request, $id, string $_format): Response
{
- $entity = $this->getEntity($action, $id, $request, $_format);
+ $entity = $this->getEntity($action, $id, $request);
if (NULL === $entity) {
throw $this->createNotFoundException(sprintf("The %s with id %s "
@@ -287,7 +289,7 @@ class ApiController extends AbstractCRUDController
protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface
{
$validationGroups = $this->getValidationGroups($action, $request, $_format, $entity);
-
+
return $this->getValidator()->validate($entity, null, $validationGroups);
}
@@ -309,7 +311,7 @@ class ApiController extends AbstractCRUDController
return $this->getSerializer()->deserialize($request->getContent(), $this->getEntityClass(), $_format, $context);
}
-
+
/**
* Base action for indexing entities
@@ -327,11 +329,11 @@ class ApiController extends AbstractCRUDController
/**
* Build an index page.
- *
+ *
* Some steps may be overriden during this process of rendering.
- *
+ *
* This method:
- *
+ *
* 1. Launch `onPreIndex`
* x. check acl. If it does return a response instance, return it
* x. launch `onPostCheckACL`. If it does return a response instance, return it
@@ -342,7 +344,7 @@ class ApiController extends AbstractCRUDController
* x. fetch the results, using `getQueryResult`
* x. Launch `onPostIndexFetchQuery`. If it does return a response instance, return it
* 4. Serialize the entities in a Collection, using `SerializeCollection`
- *
+ *
* @param string $action
* @param Request $request
* @return type
@@ -350,50 +352,50 @@ class ApiController extends AbstractCRUDController
protected function indexApiAction($action, Request $request, $_format)
{
$this->onPreIndex($action, $request, $_format);
-
+
$response = $this->checkACL($action, $request, $_format);
if ($response instanceof Response) {
return $response;
}
-
+
if (!isset($entity)) {
$entity = '';
}
-
+
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
return $response;
}
-
+
$totalItems = $this->countEntities($action, $request, $_format);
$paginator = $this->getPaginatorFactory()->create($totalItems);
-
- $response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems,
+
+ $response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems,
$paginator);
-
+
if ($response instanceof Response) {
return $response;
}
-
+
$query = $this->queryEntities($action, $request, $_format, $paginator);
-
- $response = $this->onPostIndexBuildQuery($action, $request, $_format, $totalItems,
+
+ $response = $this->onPostIndexBuildQuery($action, $request, $_format, $totalItems,
$paginator, $query);
-
+
if ($response instanceof Response) {
return $response;
}
-
+
$entities = $this->getQueryResult($action, $request, $_format, $totalItems, $paginator, $query);
-
- $response = $this->onPostIndexFetchQuery($action, $request, $_format, $totalItems,
+
+ $response = $this->onPostIndexFetchQuery($action, $request, $_format, $totalItems,
$paginator, $entities);
-
+
if ($response instanceof Response) {
return $response;
}
-
- return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
+
+ return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
}
/**
@@ -402,7 +404,7 @@ class ApiController extends AbstractCRUDController
* This method:
*
* 1. Fetch the base entity (throw 404 if not found)
- * 2. checkACL,
+ * 2. checkACL,
* 3. run onPostCheckACL, return response if any,
* 4. deserialize posted data into the entity given by $postedDataType, with the context in $postedDataContext
* 5. run 'add+$property' for POST method, or 'remove+$property' for DELETE method
@@ -410,7 +412,7 @@ class ApiController extends AbstractCRUDController
* 7. run onAfterValidation
* 8. if errors, return a 422 response with errors
* 9. if $forcePersist === true, persist the entity
- * 10. flush the data
+ * 10. flush the data
* 11. run onAfterFlush
* 12. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
*
@@ -425,7 +427,7 @@ class ApiController extends AbstractCRUDController
* @throw BadRequestException if unable to deserialize the posted data
* @throw BadRequestException if the method is not POST or DELETE
*
- */
+ */
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
{
$entity = $this->getEntity($action, $id, $request);
@@ -500,14 +502,14 @@ class ApiController extends AbstractCRUDController
return $this->json(
$postedData,
Response::HTTP_OK,
- [],
+ [],
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
);
}
throw new \Exception('Unable to handle such request method.');
}
-
+
/**
* Serialize collections
*
@@ -520,7 +522,7 @@ class ApiController extends AbstractCRUDController
return $this->json($model, Response::HTTP_OK, [], $context);
}
-
+
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
{
@@ -537,7 +539,7 @@ class ApiController extends AbstractCRUDController
}
/**
- * Get the context for serialization post alter query (in case of
+ * Get the context for serialization post alter query (in case of
* PATCH, PUT, or POST method)
*
* This is called **after** the entity was altered.
@@ -565,7 +567,7 @@ class ApiController extends AbstractCRUDController
throw new \RuntimeException(sprintf("the config does not have any role for the ".
"method %s nor a global role for the whole action. Add those to your ".
"configuration or override the required method", $request->getMethod()));
-
+
}
protected function getSerializer(): SerializerInterface
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
index 3f4fb8414..762654fbb 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
@@ -52,7 +52,7 @@ class CRUDController extends AbstractController
*/
protected function deleteAction(string $action, Request $request, $id, $formClass = null): Response
{
- $this->onPreDelete($action, $request, $id);
+ $this->onPreDelete($action, $request);
$entity = $this->getEntity($action, $id, $request);
@@ -311,11 +311,12 @@ class CRUDController extends AbstractController
*/
protected function buildQueryEntities(string $action, Request $request)
{
- $query = $this->getDoctrine()->getManager()
+ $query = $this
+ ->getDoctrine()
+ ->getManager()
->createQueryBuilder()
->select('e')
- ->from($this->getEntityClass(), 'e')
- ;
+ ->from($this->getEntityClass(), 'e');
$this->customizeQuery($action, $request, $query);
@@ -340,7 +341,7 @@ class CRUDController extends AbstractController
*/
protected function queryEntities(string $action, Request $request, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
{
- $query = $this->buildQueryEntities($action, $request, $filterOrder)
+ $query = $this->buildQueryEntities($action, $request)
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
->setMaxResults($paginator->getItemsPerPage());
@@ -389,7 +390,7 @@ class CRUDController extends AbstractController
*/
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
{
- return $this->buildQueryEntities($action, $request, $filterOrder)
+ return $this->buildQueryEntities($action, $request)
->select('COUNT(e)')
->getQuery()
->getSingleScalarResult()
diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php
index 735546eba..bb8203011 100644
--- a/src/Bundle/ChillMainBundle/Controller/UserController.php
+++ b/src/Bundle/ChillMainBundle/Controller/UserController.php
@@ -1,5 +1,7 @@
createEditPasswordForm($user, $request);
+ $editForm = $this->createEditPasswordForm($user);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
@@ -208,7 +194,7 @@ class UserController extends CRUDController
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
* name="admin_user_add_groupcenter")
*/
- public function addLinkGroupCenterAction(Request $request, $uid): RedirectResponse
+ public function addLinkGroupCenterAction(Request $request, $uid): Response
{
$em = $this->getDoctrine()->getManager();
@@ -238,23 +224,22 @@ class UserController extends CRUDController
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit',
\array_merge(['id' => $uid], $returnPathParams)));
- } else {
- foreach($this->validator->validate($user) as $error)
+ }
+
+ foreach($this->validator->validate($user) as $error) {
$this->addFlash('error', $error->getMessage());
}
}
- return $this->render('@ChillMain/User/edit.html.twig', array(
+ return $this->render('@ChillMain/User/edit.html.twig', [
'entity' => $user,
'edit_form' => $this->createEditForm($user)->createView(),
- 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
+ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user, $request)->createView(),
'delete_groupcenter_form' => array_map(
- function(\Symfony\Component\Form\Form $form) {
- return $form->createView();
-
- },
- iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
- ));
+ static fn(Form $form) => $form->createView(),
+ iterator_to_array($this->getDeleteLinkGroupCenterByUser($user, $request), true)
+ )
+ ]);
}
private function getPersistedGroupCenter(GroupCenter $groupCenter)
@@ -279,10 +264,8 @@ class UserController extends CRUDController
* Creates a form to delete a link to a GroupCenter
*
* @param mixed $permissionsGroup The entity id
- *
- * @return \Symfony\Component\Form\Form The form
*/
- private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request)
+ private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request): FormInterface
{
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
@@ -291,39 +274,29 @@ class UserController extends CRUDController
array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()])))
->setMethod('DELETE')
->add('submit', SubmitType::class, array('label' => 'Delete'))
- ->getForm()
- ;
+ ->getForm();
}
/**
- * create a form to add a link to a groupcenter
- *
- * @param User $user
- * @return \Symfony\Component\Form\Form
+ * Create a form to add a link to a groupcenter.
*/
- private function createAddLinkGroupCenterForm(User $user, Request $request)
+ private function createAddLinkGroupCenterForm(User $user, Request $request): FormInterface
{
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
return $this->createFormBuilder()
- ->setAction($this->generateUrl('admin_user_add_groupcenter',
- array_merge($returnPathParams, ['uid' => $user->getId()])))
- ->setMethod('POST')
- ->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
- ->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
- ->getForm()
- ;
+ ->setAction($this->generateUrl('admin_user_add_groupcenter',
+ array_merge($returnPathParams, ['uid' => $user->getId()])))
+ ->setMethod('POST')
+ ->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
+ ->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
+ ->getForm();
}
- /**
- *
- * @param User $user
- */
private function getDeleteLinkGroupCenterByUser(User $user, Request $request)
{
foreach ($user->getGroupCenters() as $groupCenter) {
- yield $groupCenter->getId() => $this
- ->createDeleteLinkGroupCenterForm($user, $groupCenter, $request);
+ yield $groupCenter->getId() => $this->createDeleteLinkGroupCenterForm($user, $groupCenter, $request);
}
}
}
diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php
index 877f1c330..30ecb8d3d 100644
--- a/src/Bundle/ChillMainBundle/Search/SearchApi.php
+++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php
@@ -1,5 +1,7 @@
em = $em;
$this->providers[] = $searchPerson;
$this->providers[] = $thirdPartyApiSearch;
@@ -126,7 +125,7 @@ class SearchApi
private function fetchRawResult($queries, $types, $parameters, $paginator): array
{
- list($union, $parameters) = $this->buildUnionQuery($queries, $types, $parameters, $paginator);
+ list($union, $parameters) = $this->buildUnionQuery($queries, $types, $parameters);
$rsm = new ResultSetMappingBuilder($this->em);
$rsm->addScalarResult('key', 'key', Types::STRING)
->addScalarResult('metadata', 'metadata', Types::JSON)
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
index 03adbdbc9..53ee73216 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
@@ -1,21 +1,6 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Security\Authorization;
@@ -43,7 +28,6 @@ use Chill\MainBundle\Entity\RoleScope;
* Helper for authorizations.
*
* Provides methods for user and entities information.
- *
*/
class AuthorizationHelper implements AuthorizationHelperInterface
{
@@ -74,11 +58,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
/**
* Determines if a user is active on this center
*
- * If
- *
- * @param User $user
* @param Center|Center[] $center May be an array of center
- * @return bool
*/
public function userCanReachCenter(User $user, $center): bool
{
@@ -89,7 +69,9 @@ class AuthorizationHelper implements AuthorizationHelperInterface
}
}
return false;
- } elseif ($center instanceof Center) {
+ }
+
+ if ($center instanceof Center) {
foreach ($user->getGroupCenters() as $groupCenter) {
if ($center->getId() === $groupCenter->getCenter()->getId()) {
return true;
@@ -99,12 +81,16 @@ class AuthorizationHelper implements AuthorizationHelperInterface
return false;
}
- throw new \UnexpectedValueException(sprintf("The entity given is not an ".
- "instance of %s, %s given", Center::class, get_class($center)));
+ throw new \UnexpectedValueException(
+ sprintf(
+ 'The entity given is not an instance of %s, %s given',
+ Center::class,
+ get_class($center)
+ )
+ );
}
/**
- *
* Determines if the user has access to the given entity.
*
* if the entity implements Chill\MainBundle\Entity\HasScopeInterface,
@@ -243,7 +229,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
}
foreach ($centers as $center) {
- if ($this->userCanReachCenter($user, $center, $role)) {
+ if ($this->userCanReachCenter($user, $center)) {
$results[] = $center;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
index 99bac1e5a..9b73fa817 100644
--- a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
+++ b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
@@ -494,6 +494,7 @@ EOF
$openingDateString = trim($row[array_search('opening_date', $headers)]);
$openingDate = $this->processDate($openingDateString, $this->input->getOption('opening_date_format'));
+ // @TODO: Fix the constructor parameter, $openingDate does not exists.
$person = $openingDate instanceof \DateTime ? new Person($openingDate) : new Person();
// add the center
$center = $this->getCenter($row, $headers);
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 5ea7aaf00..e17bd5ceb 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -1,26 +1,8 @@
,
- *
- * 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 .
- */
+namespace Chill\PersonBundle\Entity;
use ArrayIterator;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
@@ -1330,7 +1312,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function getLastAddress(DateTime $from = null)
{
- return $this->getCurrentPersonAddress($from);
+ return $this->getCurrentPersonAddress();
}
/**
From 8ede116cf50578049982bbf3efe457ae425b6c07 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 13:55:55 +0100
Subject: [PATCH 156/227] fix: SA: Split critical issues in its own file.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 220 ------------------
phpstan-critical.neon | 212 +++++++++++++++++
phpstan.neon.dist | 1 +
.../Authorization/AuthorizationHelper.php | 53 ++---
.../AuthorizationHelperInterface.php | 12 +-
.../Entity/AccompanyingPeriod.php | 16 +-
.../AccompanyingPeriodWorkRepository.php | 4 +-
.../ChillPersonBundle/Search/PersonSearch.php | 33 +--
.../Normalizer/MembersEditorNormalizer.php | 24 +-
.../Normalizer/PersonNormalizer.php | 46 +++-
.../Widget/PersonListWidget.php | 87 ++-----
.../PersonFilteringInterface.php | 5 +-
12 files changed, 333 insertions(+), 380 deletions(-)
create mode 100644 phpstan-critical.neon
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 7b09a7d50..e7ac9187c 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -70,11 +70,6 @@ parameters:
count: 1
path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
- -
- message: "#^Undefined variable\\: \\$person$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -85,21 +80,6 @@ parameters:
count: 2
path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
-
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
-
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -125,11 +105,6 @@ parameters:
count: 2
path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php
- -
- message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
- count: 2
- path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -225,11 +200,6 @@ parameters:
count: 1
path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php
- -
- message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
- count: 3
- path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
-
-
message: "#^Instantiated class PhpOffice\\\\PhpWord\\\\TemplateProcessor not found\\.$#"
count: 1
@@ -320,11 +290,6 @@ parameters:
count: 2
path: src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php
- -
- message: "#^Undefined variable\\: \\$id$#"
- count: 1
- path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
-
-
message: "#^Casting to string something that's already string\\.$#"
count: 5
@@ -340,11 +305,6 @@ parameters:
count: 2
path: src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
-
-
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
count: 1
@@ -380,11 +340,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
-
-
message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -400,11 +355,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
-
-
message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
count: 1
@@ -460,11 +410,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
-
-
message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#"
count: 1
@@ -480,11 +425,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Controller/PostalCodeController.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/UserController.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -535,11 +475,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/RoleScope.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -635,11 +570,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php
- -
- message: "#^Undefined variable\\: \\$current$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -660,36 +590,11 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php
-
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
-
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
-
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -815,26 +720,11 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
-
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
-
-
message: "#^Variable method call on mixed\\.$#"
count: 1
@@ -855,31 +745,11 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/DependencyInjection/CompilerPass/AccompanyingPeriodTimelineCompilerPass.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
- -
- message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
-
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Household\\\\PersonHouseholdAddress\\:\\:\\$relation\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/Household/PersonHouseholdAddress.php
-
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:\\$currentHouseholdParticipationAt\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Entity/Person.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -950,11 +820,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
- -
- message: "#^Undefined variable\\: \\$choiceSlug$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -975,11 +840,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
@@ -1005,11 +865,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Household/MembersEditor.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Household\\\\MembersEditorFactory\\:\\:\\$validator\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php
-
-
message: "#^Foreach overwrites \\$action with its value variable\\.$#"
count: 1
@@ -1020,36 +875,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Undefined variable\\: \\$action$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Undefined variable\\: \\$limit$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Undefined variable\\: \\$offset$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Undefined variable\\: \\$orderBy$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 2
@@ -1075,11 +900,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
- -
- message: "#^Variable variables are not allowed\\.$#"
- count: 4
- path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -1095,16 +915,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php
- -
- message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
-
- -
- message: "#^Variable method call on object\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
@@ -1115,16 +925,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php
- -
- message: "#^Undefined variable\\: \\$value$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php
-
- -
- message: "#^Parameter \\$personRepostory of method Chill\\\\PersonBundle\\\\Widget\\\\PersonListWidget\\:\\:__construct\\(\\) has invalid type Chill\\\\PersonBundle\\\\Widget\\\\PersonRepository\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -1190,11 +990,6 @@ parameters:
count: 1
path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
- -
- message: "#^Undefined variable\\: \\$choiceSlug$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -1205,21 +1000,11 @@ parameters:
count: 1
path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php
- -
- message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#"
- count: 4
- path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 4
path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
- -
- message: "#^Undefined variable\\: \\$type$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
-
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
@@ -1295,11 +1080,6 @@ parameters:
count: 1
path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
- -
- message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
new file mode 100644
index 000000000..e071ed30c
--- /dev/null
+++ b/phpstan-critical.neon
@@ -0,0 +1,212 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:\\$currentHouseholdParticipationAt\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Entity/Person.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Household\\\\PersonHouseholdAddress\\:\\:\\$relation\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/Household/PersonHouseholdAddress.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+
+ -
+ message: "#^Undefined variable\\: \\$person$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Household\\\\MembersEditorFactory\\:\\:\\$validator\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php
+
+ -
+ message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Undefined variable\\: \\$action$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Undefined variable\\: \\$limit$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Undefined variable\\: \\$offset$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Undefined variable\\: \\$orderBy$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Variable variables are not allowed\\.$#"
+ count: 4
+ path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+
+ -
+ message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
+
+ -
+ message: "#^Undefined variable\\: \\$value$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php
+
+ -
+ message: "#^Undefined variable\\: \\$choiceSlug$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
+
+ -
+ message: "#^Undefined variable\\: \\$choiceSlug$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
+
+ -
+ message: "#^Undefined variable\\: \\$type$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
+
+ -
+ message: "#^Undefined variable\\: \\$id$#"
+ count: 1
+ path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/UserController.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/RoleScope.php
+
+ -
+ message: "#^Undefined variable\\: \\$current$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#"
+ count: 4
+ path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
+ count: 2
+ path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#"
+ count: 2
+ path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#"
+ count: 1
+ path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
+ count: 2
+ path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
+
+ -
+ message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
+ count: 3
+ path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
+
+ -
+ message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
+
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 242e35626..2c312943b 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -17,5 +17,6 @@ parameters:
- src/Bundle/*/src/Resources/*
includes:
+ - phpstan-critical.neon
- phpstan-baseline.neon
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
index 53ee73216..b90556b69 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
@@ -23,6 +23,7 @@ use Chill\MainBundle\Security\RoleProvider;
use Doctrine\ORM\EntityManagerInterface;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\RoleScope;
+use Symfony\Component\Security\Core\User\UserInterface;
/**
* Helper for authorizations.
@@ -145,19 +146,21 @@ class AuthorizationHelper implements AuthorizationHelperInterface
if ($this->scopeResolverDispatcher->isConcerned($entity)) {
$scope = $this->scopeResolverDispatcher->resolveScope($entity);
- if (NULL === $scope) {
- return true;
- } elseif (is_iterable($scope)) {
- foreach ($scope as $s) {
- if ($s === $roleScope->getScope()) {
- return true;
- }
- }
- } else {
- if ($scope === $roleScope->getScope()) {
- return true;
- }
- }
+ if (NULL === $scope) {
+ return true;
+ }
+
+ if (is_iterable($scope)) {
+ foreach ($scope as $s) {
+ if ($s === $roleScope->getScope()) {
+ return true;
+ }
+ }
+ } else {
+ if ($scope === $roleScope->getScope()) {
+ return true;
+ }
+ }
} else {
return true;
}
@@ -176,14 +179,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface
/**
* Get reachable Centers for the given user, role,
- * and optionnaly Scope
+ * and optionally Scope
*
- * @param User $user
- * @param string|Role $role
- * @param null|Scope $scope
* @return Center[]|array
*/
- public function getReachableCenters(User $user, string $role, ?Scope $scope = null): array
+ public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
{
if ($role instanceof Role) {
$role = $role->getRole();
@@ -199,11 +199,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface
if ($scope === null) {
$centers[] = $groupCenter->getCenter();
break 1;
- } else {
- if ($scope->getId() == $roleScope->getScope()->getId()){
- $centers[] = $groupCenter->getCenter();
- break 1;
- }
+ }
+
+ if ($scope->getId() == $roleScope->getScope()->getId()){
+ $centers[] = $groupCenter->getCenter();
+ break 1;
}
}
}
@@ -242,12 +242,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface
*
* @deprecated Use getReachableCircles
*
- * @param User $user
- * @param string role
* @param Center|Center[] $center
* @return Scope[]|array
*/
- public function getReachableScopes(User $user, string $role, $center): array
+ public function getReachableScopes(UserInterface $user, string $role, $center): array
{
if ($role instanceof Role) {
$role = $role->getRole();
@@ -259,12 +257,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface
/**
* Return all reachable circle for a given user, center and role
*
- * @param User $user
* @param string|Role $role
* @param Center|Center[] $center
* @return Scope[]
*/
- public function getReachableCircles(User $user, $role, $center)
+ public function getReachableCircles(UserInterface $user, $role, $center)
{
$scopes = [];
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php
index 31709bcd5..2ad30f8f3 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php
@@ -4,29 +4,23 @@ namespace Chill\MainBundle\Security\Authorization;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
-use Chill\MainBundle\Entity\User;
-use Symfony\Component\Security\Core\Role\Role;
+use Symfony\Component\Security\Core\User\UserInterface;
interface AuthorizationHelperInterface
{
-
/**
* Get reachable Centers for the given user, role,
* and optionnaly Scope
*
- * @param User $user
- * @param string|Role $role
* @param null|Scope $scope
* @return Center[]
*/
- public function getReachableCenters(User $user, string $role, ?Scope $scope = null): array;
+ public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array;
/**
- * @param User $user
- * @param string $role
* @param Center|Center[]|array $center
* @return array
*/
- public function getReachableScopes(User $user, string $role, $center): array;
+ public function getReachableScopes(UserInterface $user, string $role, $center): array;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index d08f39b1e..15f33abe7 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -1044,9 +1044,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
{
if (count($this->getPersons()) === 0){
return null;
- } else {
- return $this->getPersons()->first()->getCenter();
}
+
+ return $this->getPersons()->first()->getCenter();
}
/**
@@ -1116,7 +1116,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
{
if ($this->getPersonLocation() instanceof Person) {
return 'person';
- } elseif ($this->getAddressLocation() instanceof Address) {
+ }
+
+ if ($this->getAddressLocation() instanceof Address) {
return 'address';
} else {
return 'none';
@@ -1137,11 +1139,11 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
public function getGroupSequence()
{
- if ($this->getStep() == self::STEP_DRAFT)
- {
+ if ($this->getStep() == self::STEP_DRAFT) {
return [[self::STEP_DRAFT]];
- } elseif ($this->getStep() == self::STEP_CONFIRMED)
- {
+ }
+
+ if ($this->getStep() == self::STEP_CONFIRMED) {
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
index 872feebbe..c1eea373e 100644
--- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
@@ -1,5 +1,7 @@
findOneBy($criteria);
+ return $this->repository->findOneBy($criteria);
}
public function getClassName()
diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
index 7fff34d7d..d83749147 100644
--- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php
@@ -1,22 +1,7 @@
- *
- * 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 .
- */
+declare(strict_types=1);
+
namespace Chill\PersonBundle\Search;
use Chill\MainBundle\Search\AbstractSearch;
@@ -38,7 +23,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
protected PaginatorFactory $paginatorFactory;
protected PersonACLAwareRepositoryInterface $personACLAwareRepository;
- const NAME = "person_regular";
+ public const NAME = "person_regular";
private const POSSIBLE_KEYS = [
'_default', 'firstname', 'lastname', 'birthdate', 'birthdate-before',
@@ -102,7 +87,9 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION],
'paginator' => $paginator
));
- } elseif ($format === 'json') {
+ }
+
+ if ($format === 'json') {
return [
'results' => $this->search($terms, $start, $limit, \array_merge($options, [ 'simplify' => true ])),
'pagination' => [
@@ -113,14 +100,9 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
}
/**
- *
- * @param string $pattern
- * @param int $start
- * @param int $limit
- * @param array $options
* @return Person[]
*/
- protected function search(array $terms, $start, $limit, array $options = array())
+ protected function search(array $terms, int $start, int $limit, array $options = [])
{
[
'_default' => $default,
@@ -131,7 +113,6 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
'birthdate-after' => $birthdateAfter,
'gender' => $gender,
'nationality' => $countryCode,
-
] = $terms + \array_fill_keys(self::POSSIBLE_KEYS, null);
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
index b2c21c048..f3bcd74af 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
@@ -1,5 +1,7 @@
denormalizeLeave($data, $type, $format, $context);
- } else {
- return $this->denormalizeMove($data, $type, $format, $context);
}
+
+ return $this->denormalizeMove($data, $type, $format, $context);
}
private function performChecks($data): void
{
- if (NULL == $data['concerned'] ?? NULL
+ if (NULL == $data['concerned'] ?? NULL
&& FALSE === ·\is_array('concerned')) {
throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'");
}
@@ -55,8 +57,8 @@ class MembersEditorNormalizer implements DenormalizerInterface, DenormalizerAwar
$editor = $this->factory->createEditor(null);
foreach ($data['concerned'] as $key => $concerned) {
- $person = $this->denormalizer->denormalize($concerned['person'] ?? null, Person::class,
- $format, $context);
+ $person = $this->denormalizer->denormalize($concerned['person'] ?? null, Person::class,
+ $format, $context);
$startDate = $this->denormalizer->denormalize($concerned['start_date'] ?? null, \DateTimeImmutable::class,
$format, $context);
@@ -80,18 +82,18 @@ class MembersEditorNormalizer implements DenormalizerInterface, DenormalizerAwar
$householdContext = $context;
$householdContext['groups'][] = 'create';
- $household = $this->denormalizer->denormalize($data['destination'], Household::class,
+ $household = $this->denormalizer->denormalize($data['destination'], Household::class,
$format, $householdContext);
if (NULL === $household) {
- throw new Exception\InvalidArgumentException("household could not be denormalized. Impossible to process");
+ throw new Exception\InvalidArgumentException("household could not be denormalized. Impossible to process");
}
$editor = $this->factory->createEditor($household);
foreach ($data['concerned'] as $key => $concerned) {
- $person = $this->denormalizer->denormalize($concerned['person'] ?? null, Person::class,
- $format, $context);
+ $person = $this->denormalizer->denormalize($concerned['person'] ?? null, Person::class,
+ $format, $context);
$position = $this->denormalizer->denormalize($concerned['position'] ?? null, Position::class,
$format, $context);
$startDate = $this->denormalizer->denormalize($concerned['start_date'] ?? null, \DateTimeImmutable::class,
@@ -110,10 +112,10 @@ class MembersEditorNormalizer implements DenormalizerInterface, DenormalizerAwar
"person, position or start_date.");
}
- $editor->addMovement($startDate, $person, $position, $holder,
+ $editor->addMovement($startDate, $person, $position, $holder,
$comment);
}
-
+
return $editor;
}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
index 019f3989e..b7e0069ee 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
@@ -67,7 +67,7 @@ class PersonNormalizer implements
$this->centerResolverDispatcher = $centerResolverDispatcher;
}
- public function normalize($person, string $format = null, array $context = array())
+ public function normalize($person, string $format = null, array $context = [])
{
/** @var Household $household */
$household = $person->getCurrentHousehold();
@@ -128,22 +128,44 @@ class PersonNormalizer implements
$person = new Person();
}
- foreach (['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender']
- as $item) {
- if (\array_key_exists($item, $data)) {
- $person->{'set'.\ucfirst($item)}($data[$item]);
+ $properties = ['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender'];
+
+ $properties = array_filter(
+ $properties,
+ static fn (string $property): bool => array_key_exists($property, $data)
+ );
+
+ foreach ($properties as $item) {
+ $callable = [$person, sprintf('set%s', ucfirst($item))];
+
+ if (is_callable($callable)) {
+ $closure = \Closure::fromCallable($callable);
+
+ $closure($data[$item]);
}
}
- foreach ([
+ $propertyToClassMapping = [
'birthdate' => \DateTime::class,
'deathdate' => \DateTime::class,
- 'center' => Center::class
- ] as $item => $class) {
- if (\array_key_exists($item, $data)) {
- $object = $this->denormalizer->denormalize($data[$item], $class, $format, $context);
- if ($object instanceof $class) {
- $person->{'set'.\ucfirst($item)}($object);
+ 'center' => Center::class,
+ ];
+
+ $propertyToClassMapping = array_filter(
+ $propertyToClassMapping,
+ static fn (string $item): bool => array_key_exists($item, $data)
+ );
+
+ foreach ($propertyToClassMapping as $item => $class) {
+ $object = $this->denormalizer->denormalize($data[$item], $class, $format, $context);
+
+ if ($object instanceof $class) {
+ $callable = [$object, sprintf('set%s', ucfirst($item))];
+
+ if (is_callable($callable)) {
+ $closure = \Closure::fromCallable($callable);
+
+ $closure($object);
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
index d8e61f499..f1a631882 100644
--- a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
+++ b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
@@ -1,35 +1,22 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\PersonBundle\Widget;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Templating\Widget\WidgetInterface;
-use Doctrine\ORM\EntityRepository;
+use Chill\PersonBundle\Repository\PersonRepository;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr;
use Doctrine\DBAL\Types\Types;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Role\Role;
use Doctrine\ORM\EntityManager;
-use Chill\CustomFieldsBundle\Entity\CustomField;
use Twig\Environment;
/**
@@ -42,45 +29,22 @@ use Twig\Environment;
*/
class PersonListWidget implements WidgetInterface
{
- /**
- * Repository for persons
- *
- * @var PersonRepository
- */
- protected $personRepository;
+ protected PersonRepository $personRepository;
- /**
- * The entity manager
- *
- * @var EntityManager
- */
- protected $entityManager;
+ protected EntityManagerInterface $entityManager;
- /**
- * the authorization helper
- *
- * @var AuthorizationHelper;
- */
- protected $authorizationHelper;
+ protected AuthorizationHelperInterface $authorizationHelper;
- /**
- *
- * @var TokenStorage
- */
- protected $tokenStorage;
+ protected TokenStorageInterface $tokenStorage;
- /**
- *
- * @var UserInterface
- */
- protected $user;
+ protected UserInterface $user;
public function __construct(
PersonRepository $personRepostory,
- EntityManager $em,
- AuthorizationHelper $authorizationHelper,
- TokenStorage $tokenStorage
- ) {
+ EntityManagerInterface $em,
+ AuthorizationHelperInterface $authorizationHelper,
+ TokenStorageInterface $tokenStorage
+ ) {
$this->personRepository = $personRepostory;
$this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage;
@@ -88,11 +52,8 @@ class PersonListWidget implements WidgetInterface
}
/**
- *
- * @param type $place
* @param array $context
* @param array $config
- * @return string
*/
public function render(Environment $env, $place, array $context, array $config)
{
@@ -134,8 +95,10 @@ class PersonListWidget implements WidgetInterface
. "implements %s", $config['filtering_class'],
PersonListWidget\PersonFilteringInterface::class));
}
- $ids = $filteringClass->getPersonIds($this->entityManager,
- $this->getUser());
+ $ids = $filteringClass->getPersonIds(
+ $this->entityManager,
+ $this->getUser()
+ );
$in = (new Expr())->in('person.id', ':ids');
$and->add($in);
$qb->setParameter('ids', $ids);
@@ -178,12 +141,7 @@ class PersonListWidget implements WidgetInterface
);
}
- /**
- *
- * @return UserInterface
- * @throws \RuntimeException
- */
- private function getUser()
+ private function getUser(): UserInterface
{
$token = $this->tokenStorage->getToken();
@@ -193,9 +151,10 @@ class PersonListWidget implements WidgetInterface
$user = $token->getUser();
- if (!$user instanceof UserInterface || $user == null) {
- throw new \RuntimeException("the user should implement UserInterface. "
- . "Are you logged in ?");
+ if ($user === null) {
+ throw new \RuntimeException(
+ 'The user should implement UserInterface. Are you logged in ?'
+ );
}
return $user;
diff --git a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget/PersonFilteringInterface.php b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget/PersonFilteringInterface.php
index d1de741ab..b21151b83 100644
--- a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget/PersonFilteringInterface.php
+++ b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget/PersonFilteringInterface.php
@@ -22,6 +22,8 @@ namespace Chill\PersonBundle\Widget\PersonListWidget;
use Doctrine\ORM\EntityManager;
use Chill\MainBundle\Entity\User;
+use Doctrine\ORM\EntityManagerInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
/**
@@ -78,8 +80,7 @@ interface PersonFilteringInterface
}
* ```
*
- * @param EntityManager $em
* @return int[] an array of persons id to show
*/
- public function getPersonIds(EntityManager $em, User $user);
+ public function getPersonIds(EntityManagerInterface $em, UserInterface $user);
}
From 8bebe1f9048e3f837a50369b3c1c1e4ef45eb8a1 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 14:49:42 +0100
Subject: [PATCH 157/227] fix: SA: Split configurations across multiple files.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 856 -----------------------------------------
phpstan-critical.neon | 338 ++++++++---------
phpstan-types.neon | 857 ++++++++++++++++++++++++++++++++++++++++++
phpstan.neon.dist | 1 +
4 files changed, 1027 insertions(+), 1025 deletions(-)
create mode 100644 phpstan-types.neon
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index e7ac9187c..6db3d38b2 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,205 +1,20 @@
parameters:
ignoreErrors:
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Entity/Activity.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Entity/ActivityReason.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php
-
-
message: "#^Variable property access on \\$this\\(Chill\\\\ActivityBundle\\\\Entity\\\\ActivityType\\)\\.$#"
count: 3
path: src/Bundle/ChillActivityBundle/Entity/ActivityType.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php
-
- -
- message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getDescription\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
-
- -
- message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getTitle\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
-
- -
- message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
- count: 3
- path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 3
- path: src/Bundle/ChillBudgetBundle/Form/ChargeType.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillBudgetBundle/Form/ResourceType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php
-
-
message: "#^Foreach overwrites \\$key with its key variable\\.$#"
count: 1
path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/AbstractCustomField.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 3
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 4
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
-
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php
-
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldDate\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php
-
-
message: "#^Anonymous function has an unused use \\$entries\\.$#"
count: 1
path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldLongChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php
-
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldNumber\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php
-
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldText\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php
-
- -
- message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldTitle\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php
-
- -
- message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php
-
-
message: "#^Instantiated class PhpOffice\\\\PhpWord\\\\TemplateProcessor not found\\.$#"
count: 1
@@ -210,11 +25,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
-
-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1
@@ -225,86 +35,11 @@ parameters:
count: 3
path: src/Bundle/ChillEventBundle/Controller/ParticipationController.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Entity/Participation.php
-
- -
- message: "#^Method Chill\\\\EventBundle\\\\Entity\\\\Participation\\:\\:offsetGet\\(\\) should return mixed but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Entity/Participation.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
- -
- message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\EventTypeType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/EventTypeType.php
-
- -
- message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\RoleType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/RoleType.php
-
- -
- message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\StatusType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/StatusType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Form/Type/PickEventType.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillEventBundle/Search/EventSearch.php
-
- -
- message: "#^Method Chill\\\\EventBundle\\\\Search\\\\EventSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillEventBundle/Search/EventSearch.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php
-
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 5
- path: src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
-
-
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
count: 1
@@ -315,181 +50,26 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
- -
- message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
-
message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Resolver\\\\Resolver\\:\\:getConfigValue\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php
-
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
-
-
message: "#^Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillUserSendRenewPasswordCodeCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadAndUpdateLanguagesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
-
- -
- message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadCountriesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadPostalCodesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Command\\\\SetPasswordCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php
-
-
message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Controller/ExportController.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/PasswordController.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/PostalCodeController.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php
-
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 5
- path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php
-
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/SearchableServicesCompilerPass.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php
-
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
-
-
message: "#^Method Chill\\\\MainBundle\\\\Doctrine\\\\Type\\\\PointType\\:\\:getSqlDeclaration\\(\\) does not match parent method name\\: Doctrine\\\\DBAL\\\\Types\\\\Type\\:\\:getSQLDeclaration\\(\\)\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/Address.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/User.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/User.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 6
- path: src/Bundle/ChillMainBundle/Export/ExportManager.php
-
-
message: "#^Foreach overwrites \\$line with its value variable\\.$#"
count: 2
@@ -505,81 +85,16 @@ parameters:
count: 3
path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php
- -
- message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php
-
- -
- message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php
-
- -
- message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/ChillTextareaType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 3
- path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
-
-
message: "#^Variable \\$value in empty\\(\\) always exists and is not falsy\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
- -
- message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php
-
-
message: "#^Chill\\\\MainBundle\\\\Routing\\\\Loader\\\\ChillRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
count: 1
@@ -590,126 +105,21 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php
-
-
message: "#^Variable \\$message on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 3
- path: src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
-
- -
- message: "#^Method Chill\\\\MainBundle\\\\Timeline\\\\TimelineBuilder\\:\\:getTemplateData\\(\\) should return array but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php
-
-
message: "#^Variable \\$sqls on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
-
- -
- message: "#^Method Chill\\\\PersonBundle\\\\Command\\\\ChillPersonMoveCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
-
- -
- message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
-
-
message: "#^Class Chill\\\\PersonBundle\\\\Entity\\\\Person constructor invoked with 1 parameter, 0 required\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 6
- path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
-
-
message: "#^Variable \\$street1Value might not be defined\\.$#"
count: 1
@@ -720,11 +130,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
-
-
message: "#^Variable method call on mixed\\.$#"
count: 1
@@ -740,56 +145,11 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/DependencyInjection/CompilerPass/AccompanyingPeriodTimelineCompilerPass.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/Person.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Entity/PersonPhone.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php
-
-
message: "#^Anonymous function has an unused use \\$key\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
-
message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'address_country_name' \\(string\\)\\.$#"
count: 1
@@ -820,66 +180,16 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php
-
- -
- message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php
-
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Household/MembersEditor.php
-
-
message: "#^Foreach overwrites \\$action with its value variable\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid return type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\QueryBuilder\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Repository/PersonRepository.php
-
-
message: "#^Foreach overwrites \\$action with its value variable\\.$#"
count: 1
@@ -890,66 +200,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
-
- -
- message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\PersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php
-
- -
- message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\SimilarityPersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Search/SimilarityPersonSearch.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReportACL.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php
-
- -
- message: "#^Method Chill\\\\ReportBundle\\\\DataFixtures\\\\ORM\\\\LoadReports\\:\\:getRandomChoice\\(\\) should return array\\\\|string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 4
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 2
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
-
message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_address_country_name' \\(string\\)\\.$#"
count: 1
@@ -990,123 +240,17 @@ parameters:
count: 1
path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php
-
- -
- message: "#^Method Chill\\\\ReportBundle\\\\Security\\\\Authorization\\\\ReportVoter\\:\\:supports\\(\\) should return bool but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 4
- path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/DataFixtures/ORM/LoadTaskACL.php
-
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 3
- path: src/Bundle/ChillTaskBundle/Entity/AbstractTask.php
-
-
message: "#^Chill\\\\TaskBundle\\\\Entity\\\\RecurringTask\\:\\:__construct\\(\\) does not call parent constructor from Chill\\\\TaskBundle\\\\Entity\\\\AbstractTask\\.$#"
count: 1
path: src/Bundle/ChillTaskBundle/Entity/RecurringTask.php
- -
- message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
- count: 2
- path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 5
- path: src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php
-
-
message: "#^Constructor of class Chill\\\\TaskBundle\\\\Security\\\\Authorization\\\\TaskVoter has an unused parameter \\$voterHelperFactory\\.$#"
count: 1
path: src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php
- -
- message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\SingleTaskTaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
-
- -
- message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\TaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 4
- path: src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php
-
- -
- message: "#^Method Chill\\\\ThirdPartyBundle\\\\Search\\\\ThirdPartySearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php
-
- -
- message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php
-
- -
- message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php
-
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index e071ed30c..f7389d8d7 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -1,212 +1,212 @@
parameters:
- ignoreErrors:
- -
- message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+ ignoreErrors:
+ -
+ message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:\\$currentHouseholdParticipationAt\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Entity/Person.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:\\$currentHouseholdParticipationAt\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Entity/Person.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Household\\\\PersonHouseholdAddress\\:\\:\\$relation\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/Household/PersonHouseholdAddress.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Household\\\\PersonHouseholdAddress\\:\\:\\$relation\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/Household/PersonHouseholdAddress.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
- -
- message: "#^Undefined variable\\: \\$person$#"
- count: 1
- path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
+ -
+ message: "#^Undefined variable\\: \\$person$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Household\\\\MembersEditorFactory\\:\\:\\$validator\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Household\\\\MembersEditorFactory\\:\\:\\$validator\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php
- -
- message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Undefined variable\\: \\$action$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Undefined variable\\: \\$action$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Undefined variable\\: \\$limit$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Undefined variable\\: \\$limit$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Undefined variable\\: \\$offset$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Undefined variable\\: \\$offset$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Undefined variable\\: \\$orderBy$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+ -
+ message: "#^Undefined variable\\: \\$orderBy$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
- -
- message: "#^Variable variables are not allowed\\.$#"
- count: 4
- path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+ -
+ message: "#^Variable variables are not allowed\\.$#"
+ count: 4
+ path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
- -
- message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
+ -
+ message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
- -
- message: "#^Undefined variable\\: \\$value$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php
+ -
+ message: "#^Undefined variable\\: \\$value$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php
- -
- message: "#^Undefined variable\\: \\$choiceSlug$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
+ -
+ message: "#^Undefined variable\\: \\$choiceSlug$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
- -
- message: "#^Undefined variable\\: \\$choiceSlug$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
+ -
+ message: "#^Undefined variable\\: \\$choiceSlug$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
- -
- message: "#^Undefined variable\\: \\$type$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
+ -
+ message: "#^Undefined variable\\: \\$type$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
- -
- message: "#^Undefined variable\\: \\$id$#"
- count: 1
- path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
+ -
+ message: "#^Undefined variable\\: \\$id$#"
+ count: 1
+ path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/UserController.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/UserController.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/RoleScope.php
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/RoleScope.php
- -
- message: "#^Undefined variable\\: \\$current$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
+ -
+ message: "#^Undefined variable\\: \\$current$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php
+ -
+ message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+ -
+ message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#"
- count: 3
- path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+ -
+ message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
- -
- message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#"
- count: 4
- path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+ -
+ message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#"
+ count: 4
+ path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
+ count: 2
+ path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#"
+ count: 2
+ path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
+ -
+ message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#"
+ count: 1
+ path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
- -
- message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
- count: 2
- path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
+ -
+ message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
+ count: 2
+ path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
- -
- message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
- count: 3
- path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
+ -
+ message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
+ count: 3
+ path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
- -
- message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
+ -
+ message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
diff --git a/phpstan-types.neon b/phpstan-types.neon
new file mode 100644
index 000000000..f10574600
--- /dev/null
+++ b/phpstan-types.neon
@@ -0,0 +1,857 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Entity/Activity.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Entity/ActivityReason.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php
+
+ -
+ message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getDescription\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
+
+ -
+ message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getTitle\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
+
+ -
+ message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#"
+ count: 3
+ path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillActivityBundle/Form/ActivityType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 3
+ path: src/Bundle/ChillBudgetBundle/Form/ChargeType.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillBudgetBundle/Form/ResourceType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/AbstractCustomField.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 3
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 4
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldDate\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldLongChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldNumber\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldText\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php
+
+ -
+ message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldTitle\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php
+
+ -
+ message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Entity/Participation.php
+
+ -
+ message: "#^Method Chill\\\\EventBundle\\\\Entity\\\\Participation\\:\\:offsetGet\\(\\) should return mixed but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Entity/Participation.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
+
+ -
+ message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\EventTypeType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/EventTypeType.php
+
+ -
+ message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\RoleType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/RoleType.php
+
+ -
+ message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\StatusType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/StatusType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Form/Type/PickEventType.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillEventBundle/Search/EventSearch.php
+
+ -
+ message: "#^Method Chill\\\\EventBundle\\\\Search\\\\EventSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillEventBundle/Search/EventSearch.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php
+
+ -
+ message: "#^Casting to string something that's already string\\.$#"
+ count: 5
+ path: src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
+
+ -
+ message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Resolver\\\\Resolver\\:\\:getConfigValue\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php
+
+ -
+ message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillUserSendRenewPasswordCodeCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadAndUpdateLanguagesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
+
+ -
+ message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadCountriesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadPostalCodesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Command\\\\SetPasswordCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/PasswordController.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Controller/PostalCodeController.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php
+
+ -
+ message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 5
+ path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php
+
+ -
+ message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/SearchableServicesCompilerPass.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php
+
+ -
+ message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/Address.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/User.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Entity/User.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 6
+ path: src/Bundle/ChillMainBundle/Export/ExportManager.php
+
+ -
+ message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php
+
+ -
+ message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php
+
+ -
+ message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/Type/ChillTextareaType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 3
+ path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
+
+ -
+ message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 3
+ path: src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
+
+ -
+ message: "#^Method Chill\\\\MainBundle\\\\Timeline\\\\TimelineBuilder\\:\\:getTemplateData\\(\\) should return array but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
+
+ -
+ message: "#^Method Chill\\\\PersonBundle\\\\Command\\\\ChillPersonMoveCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php
+
+ -
+ message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 6
+ path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/DependencyInjection/CompilerPass/AccompanyingPeriodTimelineCompilerPass.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Entity/Person.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Entity/PersonPhone.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php
+
+ -
+ message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Household/MembersEditor.php
+
+ -
+ message: "#^Method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid return type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\QueryBuilder\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Repository/PersonRepository.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 3
+ path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+
+ -
+ message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\PersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php
+
+ -
+ message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\SimilarityPersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Search/SimilarityPersonSearch.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReportACL.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php
+
+ -
+ message: "#^Method Chill\\\\ReportBundle\\\\DataFixtures\\\\ORM\\\\LoadReports\\:\\:getRandomChoice\\(\\) should return array\\\\|string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 4
+ path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 2
+ path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php
+
+ -
+ message: "#^Method Chill\\\\ReportBundle\\\\Security\\\\Authorization\\\\ReportVoter\\:\\:supports\\(\\) should return bool but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 4
+ path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/DataFixtures/ORM/LoadTaskACL.php
+
+ -
+ message: "#^Casting to string something that's already string\\.$#"
+ count: 3
+ path: src/Bundle/ChillTaskBundle/Entity/AbstractTask.php
+
+ -
+ message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
+ count: 2
+ path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 5
+ path: src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php
+
+ -
+ message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\SingleTaskTaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
+
+ -
+ message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\TaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 4
+ path: src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php
+
+ -
+ message: "#^Method Chill\\\\ThirdPartyBundle\\\\Search\\\\ThirdPartySearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php
+
+ -
+ message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php
+
+ -
+ message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
+ count: 1
+ path: src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php
+
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 2c312943b..46b6698ec 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -17,6 +17,7 @@ parameters:
- src/Bundle/*/src/Resources/*
includes:
+ - phpstan-types.neon
- phpstan-critical.neon
- phpstan-baseline.neon
From 7462babbeb62b4d23b7fd144adde2220ec7dfaf5 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:06:43 +0100
Subject: [PATCH 158/227] fix: SA: Fix "...an unused use..." rule.
Also fix a critical bug in `ListPerson.php`.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 45 -----
.../CustomFields/CustomFieldLongChoice.php | 64 ++-----
.../Export/Export/ListPerson.php | 181 ++++++------------
.../Security/Authorization/TaskVoter.php | 61 ++----
4 files changed, 83 insertions(+), 268 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 6db3d38b2..457367a5c 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -10,11 +10,6 @@ parameters:
count: 1
path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php
- -
- message: "#^Anonymous function has an unused use \\$entries\\.$#"
- count: 1
- path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
-
-
message: "#^Instantiated class PhpOffice\\\\PhpWord\\\\TemplateProcessor not found\\.$#"
count: 1
@@ -145,41 +140,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
- -
- message: "#^Anonymous function has an unused use \\$key\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'address_country_name' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'address_isnoaddress' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'birthdate' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'countryOfBirth' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'gender' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'nationality' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
@@ -245,11 +205,6 @@ parameters:
count: 1
path: src/Bundle/ChillTaskBundle/Entity/RecurringTask.php
- -
- message: "#^Constructor of class Chill\\\\TaskBundle\\\\Security\\\\Authorization\\\\TaskVoter has an unused parameter \\$voterHelperFactory\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
index feca7e351..85eba7071 100644
--- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
+++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php
@@ -1,21 +1,6 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\CustomFieldsBundle\CustomFields;
@@ -29,36 +14,21 @@ use Symfony\Bridge\Twig\TwigEngine;
use Chill\MainBundle\Form\Type\Select2ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-/**
- *
- *
- * @author Julien Fastré
- */
class CustomFieldLongChoice extends AbstractCustomField
{
- /**
- *
- * @var OptionRepository
- */
- private $optionRepository;
+ private OptionRepository $optionRepository;
- /**
- *
- * @var TranslatableStringHelper
- */
- private $translatableStringHelper;
+ private TranslatableStringHelper $translatableStringHelper;
- /**
- * @var TwigEngine
- */
- private $templating;
+ private TwigEngine $templating;
- const KEY = 'key';
+ public const KEY = 'key';
- public function __construct(OptionRepository $optionRepository,
+ public function __construct(
+ OptionRepository $optionRepository,
TranslatableStringHelper $translatableStringHelper,
- TwigEngine $twigEngine)
- {
+ TwigEngine $twigEngine
+ ) {
$this->optionRepository = $optionRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->templating = $twigEngine;
@@ -76,12 +46,7 @@ class CustomFieldLongChoice extends AbstractCustomField
'choice_label' => function(Option $option) use ($translatableStringHelper) {
return $translatableStringHelper->localize($option->getText());
},
- 'choice_value' => function ($key) use ($entries) {
- if ($key === NULL) {
- return null;
- }
- return $key->getId();
- },
+ 'choice_value' => static fn (Option $key): ?int => $key === null ? null : $key->getId(),
'multiple' => false,
'expanded' => false,
'required' => $customField->isRequired(),
@@ -89,15 +54,16 @@ class CustomFieldLongChoice extends AbstractCustomField
'group_by' => function(Option $option) use ($translatableStringHelper) {
if ($option->hasParent()) {
return $translatableStringHelper->localize($option->getParent()->getText());
- } else {
- return $translatableStringHelper->localize($option->getText());
}
+
+ return $translatableStringHelper->localize($option->getText());
},
'label' => $translatableStringHelper->localize($customField->getName())
));
- $builder->get($customField->getSlug())
- ->addModelTransformer(new CustomFieldDataTransformer($this, $customField));
+ $builder
+ ->get($customField->getSlug())
+ ->addModelTransformer(new CustomFieldDataTransformer($this, $customField));
}
public function buildOptionsForm(FormBuilderInterface $builder)
diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
index dc36c8c57..508905ba4 100644
--- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
+++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php
@@ -1,5 +1,7 @@
customFieldProvider = $customFieldProvider;
}
- /**
- * {@inheritDoc}
- *
- * @param FormBuilderInterface $builder
- */
public function buildForm(FormBuilderInterface $builder)
{
$choices = array_combine($this->fields, $this->fields);
@@ -99,13 +78,13 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
'expanded' => true,
'choices' => $choices,
'label' => 'Fields to include in export',
- 'choice_attr' => function($val, $key, $index) {
+ 'choice_attr' => static function(string $val): array {
// add a 'data-display-target' for address fields
if (substr($val, 0, 8) === 'address_') {
return ['data-display-target' => 'address_date'];
- } else {
- return [];
}
+
+ return [];
},
'constraints' => [new Callback(array(
'callback' => function($selected, ExecutionContextInterface $context) {
@@ -133,9 +112,10 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
public function validateForm($data, ExecutionContextInterface $context)
{
// get the field starting with address_
- $addressFields = array_filter(function($el) {
- return substr($el, 0, 8) === 'address_';
- }, $this->fields);
+ $addressFields = array_filter(
+ $this->fields,
+ static fn(string $el): bool => substr($el, 0, 8) === 'address_'
+ );
// check if there is one field starting with address in data
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
@@ -168,41 +148,23 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
->getResult();
}
- /**
- * {@inheritDoc}
- *
- * @return type
- */
public function getAllowedFormattersTypes()
{
return array(FormatterInterface::TYPE_LIST);
}
- /**
- * {@inheritDoc}
- *
- * @return string
- */
public function getDescription()
{
return "Create a list of people according to various filters.";
}
- /**
- * {@inheritDoc}
- *
- * @param type $key
- * @param array $values
- * @param type $data
- * @return type
- */
public function getLabels($key, array $values, $data)
{
switch ($key) {
case 'birthdate':
// for birthdate, we have to transform the string into a date
// to format the date correctly.
- return function($value) {
+ return static function($value) {
if ($value === '_header') { return 'birthdate'; }
if (empty($value))
@@ -257,31 +219,33 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
return $this->translatableStringHelper->localize(json_decode($value, true));
};
case 'address_isnoaddress':
- return function($value) use ($key) {
- if ($value === '_header') { return 'address.address_homeless'; }
-
- if ($value) {
- return 'X';
- } else {
- return '';
+ return static function(?string $value): string {
+ if ($value === '_header') {
+ return 'address.address_homeless';
}
+
+ if (null !== $value) {
+ return 'X';
+ }
+
+ return '';
};
default:
// for fields which are associated with person
if (in_array($key, $this->fields)) {
- return function($value) use ($key) {
+ return static function($value) use ($key) {
if ($value === '_header') { return \strtolower($key); }
return $value;
};
- } else {
- return $this->getLabelForCustomField($key, $values, $data);
}
+
+ return $this->getLabelForCustomField($key, $values, $data);
}
}
-
+
private function getLabelForCustomField($key, array $values, $data)
{
// for fields which are custom fields
@@ -292,45 +256,39 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
$cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType());
$defaultFunction = function($value) use ($cf) {
if ($value === '_header') {
- return $this->translatableStringHelper->localize($cf->getName());
+ return $this->translatableStringHelper->localize($cf->getName());
}
return $this->customFieldProvider
->getCustomFieldByType($cf->getType())
->render(json_decode($value, true), $cf, 'csv');
};
-
+
if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) {
return function($value) use ($cf, $cfType, $key) {
$slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug'];
$decoded = \json_decode($value, true);
-
+
if ($value === '_header') {
-
+
$label = $cfType->getChoices($cf)[$slugChoice];
-
+
return $this->translatableStringHelper->localize($cf->getName())
.' | '.$label;
}
-
+
if ($slugChoice === '_other' and $cfType->isChecked($cf, $choiceSlug, $decoded)) {
return $cfType->extractOtherValue($cf, $decoded);
- } else {
- return $cfType->isChecked($cf, $slugChoice, $decoded);
}
+
+ return $cfType->isChecked($cf, $slugChoice, $decoded);
};
-
- } else {
- return $defaultFunction;
+
}
+
+ return $defaultFunction;
}
- /**
- * {@inheritDoc}
- *
- * @param type $data
- * @return type
- */
public function getQueryKeys($data)
{
$fields = array();
@@ -340,78 +298,55 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
$fields[] = $key;
}
}
-
+
// add the key from slugs and return
return \array_merge($fields, \array_keys($this->slugs));
}
/**
- * clean a slug to be usable by DQL
- *
- * @param string $slugsanitize
- * @param string $type the type of the customfield, if required (currently only for choices)
- * @return string
+ * Clean a slug to be usable by DQL.
*/
- private function slugToDQL($slug, $type = "default", array $additionalInfos = [])
+ private function slugToDQL(string $slug, string $type = "default", array $additionalInfos = []): string
{
- $uid = 'slug_'.\uniqid();
-
+ $uid = 'slug_' . \uniqid('', true);
+
$this->slugs[$uid] = [
'slug' => $slug,
'type' => $type,
'additionnalInfos' => $additionalInfos
];
-
+
return $uid;
}
private function DQLToSlug($cleanedSlug)
- {
+ {
return $this->slugs[$cleanedSlug]['slug'];
}
-
+
/**
- *
- * @param type $cleanedSlug
- * @return an array with keys = 'slug', 'type', 'additionnalInfo'
+ * @return array An array with keys = 'slug', 'type', 'additionnalInfo'
*/
- private function extractInfosFromSlug($slug)
+ private function extractInfosFromSlug($slug): array
{
return $this->slugs[$slug];
}
- /**
- * {@inheritDoc}
- *
- */
public function getResult($query, $data)
{
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
- /**
- * {@inheritDoc}
- *
- * @return string
- */
public function getTitle()
{
return "List peoples";
}
- /**
- * {@inheritDoc}
- *
- */
public function getType()
{
return Declarations::PERSON_TYPE;
}
- /**
- * {@inheritDoc}
- *
- */
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
{
$centers = array_map(function($el) { return $el['center']; }, $acl);
@@ -459,7 +394,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
foreach($cfType->getChoices($cf) as $choiceSlug => $label) {
$slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]);
$qb->addSelect(
- sprintf('GET_JSON_FIELD_BY_KEY(person.cFData, :slug%s) AS %s',
+ sprintf('GET_JSON_FIELD_BY_KEY(person.cFData, :slug%s) AS %s',
$slug, $slug));
$qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug());
}
@@ -483,19 +418,11 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
return $qb;
}
- /**
- *
- * {@inheritDoc}
- */
public function requiredRole()
{
return new Role(PersonVoter::LISTS);
}
- /**
- *
- * {@inheritDoc}
- */
public function supportsModifiers()
{
return array(Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN);
diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php
index 39d9eef32..a3f1fff92 100644
--- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php
+++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php
@@ -1,26 +1,13 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
namespace Chill\TaskBundle\Security\Authorization;
use Chill\EventBundle\Entity\Event;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
@@ -41,13 +28,13 @@ use Chill\TaskBundle\Security\Authorization\AuthorizationEvent;
final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
- const CREATE_COURSE = 'CHILL_TASK_TASK_CREATE_FOR_COURSE';
- const CREATE_PERSON = 'CHILL_TASK_TASK_CREATE_FOR_PERSON';
- const DELETE = 'CHILL_TASK_TASK_DELETE';
- const SHOW = 'CHILL_TASK_TASK_SHOW';
- const UPDATE = 'CHILL_TASK_TASK_UPDATE';
+ public const CREATE_COURSE = 'CHILL_TASK_TASK_CREATE_FOR_COURSE';
+ public const CREATE_PERSON = 'CHILL_TASK_TASK_CREATE_FOR_PERSON';
+ public const DELETE = 'CHILL_TASK_TASK_DELETE';
+ public const SHOW = 'CHILL_TASK_TASK_SHOW';
+ public const UPDATE = 'CHILL_TASK_TASK_UPDATE';
- const ROLES = [
+ public const ROLES = [
self::CREATE_COURSE,
self::CREATE_PERSON,
self::DELETE,
@@ -55,33 +42,23 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
self::UPDATE,
];
- protected AuthorizationHelper $authorizationHelper;
+ private AccessDecisionManagerInterface $accessDecisionManager;
- protected AccessDecisionManagerInterface $accessDecisionManager;
+ private LoggerInterface $logger;
- protected LoggerInterface $logger;
-
- protected EventDispatcherInterface $eventDispatcher;
-
- protected CenterResolverDispatcher $centerResolverDispatcher;
-
- protected VoterHelperInterface $voter;
+ private EventDispatcherInterface $eventDispatcher;
+ private VoterHelperInterface $voter;
public function __construct(
- VoterHelperFactoryInterface $voterHelperFactory,
AccessDecisionManagerInterface $accessDecisionManager,
- AuthorizationHelper $authorizationHelper,
EventDispatcherInterface $eventDispatcher,
LoggerInterface $logger,
- CenterResolverDispatcher $centerResolverDispatcher,
VoterHelperFactoryInterface $voterFactory
) {
$this->accessDecisionManager = $accessDecisionManager;
- $this->authorizationHelper = $authorizationHelper;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
- $this->centerResolverDispatcher = $centerResolverDispatcher;
$this->voter = $voterFactory
->generate(AbstractTask::class)
@@ -89,8 +66,7 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
->addCheckFor(Person::class, [self::SHOW, self::CREATE_PERSON])
->addCheckFor(AccompanyingPeriod::class, [self::SHOW, self::CREATE_COURSE])
->addCheckFor(null, [self::SHOW])
- ->build()
- ;
+ ->build();
}
public function supports($attribute, $subject)
@@ -98,13 +74,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
return $this->voter->supports($attribute, $subject);
}
- /**
- *
- * @param string $attribute
- * @param AbstractTask $subject
- * @param TokenInterface $token
- * @return boolean
- */
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
$this->logger->debug(sprintf("Voting from %s class", self::class));
@@ -118,7 +87,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
$this->eventDispatcher->dispatch(AuthorizationEvent::VOTE, $event);
if ($event->hasVote()) {
-
$this->logger->debug("The TaskVoter is overriding by "
.AuthorizationEvent::VOTE, [
'vote' => $event->getVote(),
@@ -167,5 +135,4 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
{
return [];
}
-
}
From 5a85d497ab5346d590c6720b22df11f02f73bd98 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:12:31 +0100
Subject: [PATCH 159/227] fix: SA: Fix "...Switch condition type..." rule.
Also fix a critical bug in `ReportList.php`.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 40 ------
.../Export/Export/ReportList.php | 133 ++++++------------
2 files changed, 46 insertions(+), 127 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 457367a5c..cab6a5eeb 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -160,46 +160,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_address_country_name' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_birthdate' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_countryOfBirth' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_gender' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_nationality' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_date' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_scope' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
- -
- message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_user' \\(string\\)\\.$#"
- count: 1
- path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
-
-
message: "#^Chill\\\\TaskBundle\\\\Entity\\\\RecurringTask\\:\\:__construct\\(\\) does not call parent constructor from Chill\\\\TaskBundle\\\\Entity\\\\AbstractTask\\.$#"
count: 1
diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php
index 9524f860a..432cb8e3f 100644
--- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php
+++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php
@@ -1,7 +1,7 @@
- */
class ReportList implements ListInterface, ExportElementValidatedInterface
{
- /**
- *
- * @var CustomFieldsGroup
- */
- protected $customfieldsGroup;
+ protected CustomFieldsGroup $customfieldsGroup;
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
+ protected TranslatableStringHelper $translatableStringHelper;
- /**
- *
- * @var TranslatorInterface
- */
- protected $translator;
+ protected TranslatorInterface $translator;
- /**
- *
- * @var CustomFieldProvider
- */
- protected $customFieldProvider;
+ protected CustomFieldProvider $customFieldProvider;
- protected $em;
+ protected EntityManagerInterface $em;
- protected $fields = array(
+ protected array $fields = [
'person_id', 'person_firstName', 'person_lastName', 'person_birthdate',
'person_placeOfBirth', 'person_gender', 'person_memo', 'person_email', 'person_phonenumber',
'person_countryOfBirth', 'person_nationality', 'person_address_street_address_1',
'person_address_street_address_2', 'person_address_valid_from', 'person_address_postcode_label',
'person_address_postcode_code', 'person_address_country_name', 'person_address_country_code',
'report_id', 'report_user', 'report_date', 'report_scope'
- );
+ ];
- protected $slugs = [];
+ protected array $slugs = [];
function __construct(
CustomFieldsGroup $customfieldsGroup,
@@ -85,7 +65,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
}
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
+ public function buildForm(FormBuilderInterface $builder)
{
$choices = array_combine($this->fields, $this->fields);
@@ -97,7 +77,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
}
// Add a checkbox to select fields
- $builder->add('fields', ChoiceType::class, array(
+ $builder->add('fields', ChoiceType::class, [
'multiple' => true,
'expanded' => true,
'choices' => $choices,
@@ -106,11 +86,11 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
// add a 'data-display-target' for address fields
if (substr($val, 0, 8) === 'address_') {
return ['data-display-target' => 'address_date'];
- } else {
- return [];
}
+
+ return [];
},
- 'choice_label' => function($key, $label) {
+ 'choice_label' => function(string $key, string $label): string {
switch (\substr($key, 0, 7)) {
case 'person_':
return $this->translator->trans(\substr($key, 7, \strlen($key) - 7)).
@@ -123,7 +103,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
' ('.$this->translator->trans("Report's question").')';;
}
},
- 'constraints' => [new Callback(array(
+ 'constraints' => [new Callback([
'callback' => function($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
@@ -131,24 +111,25 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
->addViolation();
}
}
- ))]
- ));
+ ])]
+ ]);
// add a date field for addresses
- $builder->add('address_date', ChillDateType::class, array(
+ $builder->add('address_date', ChillDateType::class, [
'label' => "Address valid at this date",
'data' => new \DateTime(),
'required' => false,
'block_name' => 'list_export_form_address_date'
- ));
+ ]);
}
public function validateForm($data, ExecutionContextInterface $context)
{
// get the field starting with address_
- $addressFields = array_filter(function($el) {
- return substr($el, 0, 8) === 'address_';
- }, $this->fields);
+ $addressFields = array_filter(
+ $this->fields,
+ static fn(string $el): bool => substr($el, 0, 8) === 'address_'
+ );
// check if there is one field starting with address in data
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
@@ -177,7 +158,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
public function getAllowedFormattersTypes()
{
- return array(FormatterInterface::TYPE_LIST);
+ return [FormatterInterface::TYPE_LIST];
}
public function getDescription()
@@ -190,13 +171,6 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
);
}
- /**
- * {@inheritDoc}
- *
- * @param type $key
- * @param array $values
- * @param type $data
- */
public function getLabels($key, array $values, $data): \Closure
{
switch ($key) {
@@ -284,7 +258,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
->getRepository('ChillMainBundle:Country');
// load all countries in a single query
- $countryRepository->findBy(array('countryCode' => $values));
+ $countryRepository->findBy(['countryCode' => $values]);
return function($value) use ($key, $countryRepository) {
if ($value === '_header') { return \strtolower($key); }
@@ -317,9 +291,9 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
return $value;
};
- } else {
- return $this->getLabelForCustomField($key, $values, $data);
}
+
+ return $this->getLabelForCustomField($key, $values, $data);
}
}
@@ -330,7 +304,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
/* @var $cf CustomField */
$cf = $this->em
->getRepository(CustomField::class)
- ->findOneBy(array('slug' => $this->DQLToSlug($key)));
+ ->findOneBy(['slug' => $this->DQLToSlug($key)]);
$cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType());
$defaultFunction = function($value) use ($cf) {
@@ -358,19 +332,19 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
if ($slugChoice === '_other' and $cfType->isChecked($cf, $choiceSlug, $decoded)) {
return $cfType->extractOtherValue($cf, $decoded);
- } else {
- return $cfType->isChecked($cf, $slugChoice, $decoded);
}
+
+ return $cfType->isChecked($cf, $slugChoice, $decoded);
};
- } else {
- return $defaultFunction;
}
+
+ return $defaultFunction;
}
public function getQueryKeys($data)
{
- $fields = array();
+ $fields = [];
foreach ($data['fields'] as $key) {
if (in_array($key, $this->fields)) {
@@ -382,16 +356,9 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
return \array_merge($fields, \array_keys($this->slugs));
}
- /**
- * clean a slug to be usable by DQL
- *
- * @param string $slugsanitize
- * @param string $type the type of the customfield, if required (currently only for choices)
- * @return string
- */
private function slugToDQL($slug, $type = "default", array $additionalInfos = [])
{
- $uid = 'slug_'.\uniqid();
+ $uid = 'slug_' . \uniqid('', true);
$this->slugs[$uid] = [
'slug' => $slug,
@@ -407,11 +374,6 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
return $this->slugs[$cleanedSlug]['slug'];
}
- /**
- *
- * @param type $cleanedSlug
- * @return an array with keys = 'slug', 'type', 'additionnalInfo'
- */
private function extractInfosFromSlug($slug)
{
return $this->slugs[$slug];
@@ -437,7 +399,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
return 'report';
}
- public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
+ public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function($el) { return $el['center']; }, $acl);
@@ -533,17 +495,14 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
}
}
- $qb
- ->from(Report::class, 'report')
- ->leftJoin('report.person', 'person')
- ->join('person.center', 'center')
- ->andWhere($qb->expr()->eq('report.cFGroup', ':cFGroup'))
- ->setParameter('cFGroup', $this->customfieldsGroup)
- ->andWhere('center IN (:authorized_centers)')
- ->setParameter('authorized_centers', $centers);
- ;
-
- return $qb;
+ return $qb
+ ->from(Report::class, 'report')
+ ->leftJoin('report.person', 'person')
+ ->join('person.center', 'center')
+ ->andWhere($qb->expr()->eq('report.cFGroup', ':cFGroup'))
+ ->setParameter('cFGroup', $this->customfieldsGroup)
+ ->andWhere('center IN (:authorized_centers)')
+ ->setParameter('authorized_centers', $centers);
}
public function requiredRole()
From e2a8437807cabcfd58959e4ac5a65153a35822ee Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:14:43 +0100
Subject: [PATCH 160/227] fix: SA: Fix "...Short ternary operator..." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 -----
.../EntityRepository/DocumentCategoryRepository.php | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index cab6a5eeb..3e8d79b3d 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -20,11 +20,6 @@ parameters:
count: 1
path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
- -
- message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
- count: 1
- path: src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php
-
-
message: "#^Variable \\$participation might not be defined\\.$#"
count: 3
diff --git a/src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php b/src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php
index d803405e4..72c068d18 100644
--- a/src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php
+++ b/src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php
@@ -34,6 +34,6 @@ class DocumentCategoryRepository extends EntityRepository
'SELECT MAX(c.idInsideBundle) + 1 FROM ChillDocStoreBundle:DocumentCategory c')
->getSingleResult();
- return $array_res[1] ?: 0;
+ return reset($array_res);
}
}
From 479f0ce9ed48a5533669f6147654dd242d5db59f Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:17:29 +0100
Subject: [PATCH 161/227] fix: SA: Fix "...does not match parent method..."
rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 ----
.../Doctrine/Type/PointType.php | 26 +++++++------------
2 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 3e8d79b3d..56aeb1615 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -55,11 +55,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Controller/ExportController.php
- -
- message: "#^Method Chill\\\\MainBundle\\\\Doctrine\\\\Type\\\\PointType\\:\\:getSqlDeclaration\\(\\) does not match parent method name\\: Doctrine\\\\DBAL\\\\Types\\\\Type\\:\\:getSQLDeclaration\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php
-
-
message: "#^Foreach overwrites \\$line with its value variable\\.$#"
count: 2
diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php
index 0a0c160cd..9e42048f7 100644
--- a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php
+++ b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php
@@ -1,5 +1,7 @@
toWKT();
}
+
+ return $value->toWKT();
}
public function canRequireSQLConversion()
From d382cf35bad3138551bfad957f5db28b3b5d9fb5 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:18:59 +0100
Subject: [PATCH 162/227] fix: SA: Fix "...Variable in isset() is never
defined...." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 -----
.../ChillMainBundle/CRUD/Controller/CRUDController.php | 5 +----
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 56aeb1615..5ec4539e8 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -40,11 +40,6 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
- -
- message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
-
-
message: "#^Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
count: 1
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
index 762654fbb..94479e233 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php
@@ -202,7 +202,6 @@ class CRUDController extends AbstractController
*
* @param string $action
* @param Request $request
- * @return type
*/
protected function indexEntityAction($action, Request $request)
{
@@ -213,9 +212,7 @@ class CRUDController extends AbstractController
return $response;
}
- if (!isset($entity)) {
- $entity = '';
- }
+ $entity = '';
$response = $this->onPostCheckACL($action, $request, $entity);
if ($response instanceof Response) {
From 11651fdb2af0042667193313e24966e6ca8f9e6a Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:21:26 +0100
Subject: [PATCH 163/227] fix: SA: Fix "...does not call parent
constructor...." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 10 ----
.../Routing/Loader/ChillRoutesLoader.php | 60 ++++---------------
2 files changed, 13 insertions(+), 57 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 5ec4539e8..945770f10 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -75,16 +75,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
- -
- message: "#^Chill\\\\MainBundle\\\\Routing\\\\Loader\\\\ChillRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
-
- -
- message: "#^Foreach overwrites \\$resource with its value variable\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
-
-
message: "#^Variable \\$message on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
diff --git a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
index b7a719073..e9b084e6d 100644
--- a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
+++ b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php
@@ -1,22 +1,6 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Routing\Loader;
@@ -25,52 +9,34 @@ use Symfony\Component\Routing\RouteCollection;
/**
* Import routes from bundles
- *
- * Routes must be defined in configuration, add an entry
- * under `chill_main.routing.resources`
- *
- *
*
- * @author Julien Fastré
+ * Routes must be defined in configuration, add an entry
+ * under `chill_main.routing.resources`
*/
class ChillRoutesLoader extends Loader
{
- private $routes;
-
-
-
+ private array $routes;
+
public function __construct(array $routes)
{
$this->routes = $routes;
+
+ parent::__construct();
}
-
- /**
- * {@inheritDoc}
- *
- * @param type $resource
- * @param type $type
- * @return RouteCollection
- */
+
public function load($resource, $type = null)
{
$collection = new RouteCollection();
-
- foreach ($this->routes as $resource) {
+
+ foreach ($this->routes as $routeResource) {
$collection->addCollection(
- $this->import($resource, NULL)
- );
+ $this->import($routeResource, NULL)
+ );
}
-
+
return $collection;
}
- /**
- * {@inheritDoc}
- *
- * @param type $resource
- * @param type $type
- * @return boolean
- */
public function supports($resource, $type = null)
{
return 'chill_routes' === $type;
From c94fb2efbf3f9d0bcd0bf5fc35d30b519a70e7ab Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:23:56 +0100
Subject: [PATCH 164/227] fix: SA: Fix "...variable always exists and is not
falsy...." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 --
.../DateIntervalTransformer.php | 73 +++++++------------
2 files changed, 28 insertions(+), 50 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 945770f10..e7ec53126 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -70,11 +70,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php
- -
- message: "#^Variable \\$value in empty\\(\\) always exists and is not falsy\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
-
-
message: "#^Variable \\$message on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
index 29a81447c..4d4e2d79d 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php
@@ -1,48 +1,25 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\MainBundle\Form\Type\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
-/**
- *
- *
- * @author Julien Fastré
- */
class DateIntervalTransformer implements DataTransformerInterface
{
- /**
- *
- * @param \DateInterval $value
- * @throws UnexpectedTypeException
- */
public function transform($value)
{
if (empty($value)) {
return null;
}
-
+
if (!$value instanceof \DateInterval) {
throw new UnexpectedTypeException($value, \DateInterval::class);
}
-
+
if ($value->d > 0) {
// we check for weeks (weeks are converted to 7 days)
if ($value->d % 7 === 0) {
@@ -50,43 +27,49 @@ class DateIntervalTransformer implements DataTransformerInterface
'n' => $value->d / 7,
'unit' => 'W'
];
- } else {
- return [
- 'n' => $value->d,
- 'unit' => 'D'
- ];
}
- } elseif ($value->m > 0) {
+
+ return [
+ 'n' => $value->d,
+ 'unit' => 'D'
+ ];
+ }
+
+ if ($value->m > 0) {
return [
'n' => $value->m,
'unit' => 'M'
];
- } elseif ($value->y > 0) {
+ }
+
+ if ($value->y > 0) {
return [
'n' => $value->y,
'unit' => 'Y'
];
}
-
- throw new TransformationFailedException('the date interval does not '
- . 'contains any days, months or years');
+
+ throw new TransformationFailedException(
+ 'The date interval does not contains any days, months or years.'
+ );
}
public function reverseTransform($value)
{
- if (empty($value) or empty($value['n'])) {
+ if (empty($value) || empty($value['n'])) {
return null;
}
-
+
$string = 'P'.$value['n'].$value['unit'];
-
+
try {
return new \DateInterval($string);
} catch (\Exception $e) {
- throw new TransformationFailedException("Could not transform value "
- . "into DateInterval", 1542, $e);
+ throw new TransformationFailedException(
+ 'Could not transform value into DateInterval',
+ 1542,
+ $e
+ );
}
-
-
}
}
From 75d2d50dd23b5da773ee6e4a1aa2b198ba4c9d8c Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:25:48 +0100
Subject: [PATCH 165/227] fix: SA: Fix "...Variable in isset() is never
defined...." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 -----
.../CRUD/Controller/ApiController.php | 14 ++++++++------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index e7ec53126..40b6b2425 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -30,11 +30,6 @@ parameters:
count: 1
path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php
- -
- message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
-
-
message: "#^Variable method call on object\\.$#"
count: 2
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
index a2555bf81..3a390a286 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
@@ -347,7 +347,6 @@ class ApiController extends AbstractCRUDController
*
* @param string $action
* @param Request $request
- * @return type
*/
protected function indexApiAction($action, Request $request, $_format)
{
@@ -358,9 +357,7 @@ class ApiController extends AbstractCRUDController
return $response;
}
- if (!isset($entity)) {
- $entity = '';
- }
+ $entity = '';
$response = $this->onPostCheckACL($action, $request, $_format, $entity);
if ($response instanceof Response) {
@@ -370,8 +367,13 @@ class ApiController extends AbstractCRUDController
$totalItems = $this->countEntities($action, $request, $_format);
$paginator = $this->getPaginatorFactory()->create($totalItems);
- $response = $this->onPreIndexBuildQuery($action, $request, $_format, $totalItems,
- $paginator);
+ $response = $this->onPreIndexBuildQuery(
+ $action,
+ $request,
+ $_format,
+ $totalItems,
+ $paginator
+ );
if ($response instanceof Response) {
return $response;
From a17c22c74fa9f51f292668d42562715994df3b50 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:27:46 +0100
Subject: [PATCH 166/227] fix: SA: Fix "...does not call parent
constructor...." rule.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 -----
src/Bundle/ChillTaskBundle/Entity/AbstractTask.php | 5 -----
src/Bundle/ChillTaskBundle/Entity/SingleTask.php | 5 ++---
3 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 40b6b2425..eaa4dc3b2 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -125,11 +125,6 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php
- -
- message: "#^Chill\\\\TaskBundle\\\\Entity\\\\RecurringTask\\:\\:__construct\\(\\) does not call parent constructor from Chill\\\\TaskBundle\\\\Entity\\\\AbstractTask\\.$#"
- count: 1
- path: src/Bundle/ChillTaskBundle/Entity/RecurringTask.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php
index d34a0b05f..c4b76736e 100644
--- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php
+++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php
@@ -90,11 +90,6 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
*/
private $closed = false;
- public function __construct()
- {
-
- }
-
/**
* Set type
*
diff --git a/src/Bundle/ChillTaskBundle/Entity/SingleTask.php b/src/Bundle/ChillTaskBundle/Entity/SingleTask.php
index cef59a10a..579143718 100644
--- a/src/Bundle/ChillTaskBundle/Entity/SingleTask.php
+++ b/src/Bundle/ChillTaskBundle/Entity/SingleTask.php
@@ -2,6 +2,7 @@
namespace Chill\TaskBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\Collection;
@@ -103,9 +104,7 @@ class SingleTask extends AbstractTask
public function __construct()
{
- $this->taskPlaceEvents = $events = new \Doctrine\Common\Collections\ArrayCollection;
-
- parent::__construct();
+ $this->taskPlaceEvents = new ArrayCollection();
}
From 8879734ea2382aaaccf9ce33bcef5df412b15394 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:30:53 +0100
Subject: [PATCH 167/227] fix: SA: Fix "...does not call parent constructor...
and ...Access to an undefined property..." rules.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 5 --
phpstan-critical.neon | 5 --
.../CRUD/Routing/CRUDRoutesLoader.php | 71 ++++++-------------
3 files changed, 21 insertions(+), 60 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index eaa4dc3b2..9d9a5affd 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -35,11 +35,6 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php
- -
- message: "#^Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
-
-
message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#"
count: 1
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index f7389d8d7..cb0ac38ce 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -100,11 +100,6 @@ parameters:
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
-
-
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
count: 1
diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
index 36aadb8b7..85ef4c66c 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php
@@ -1,22 +1,6 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
namespace Chill\MainBundle\CRUD\Routing;
@@ -27,22 +11,13 @@ use Symfony\Component\HttpFoundation\Request;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\CRUD\Controller\CRUDController;
-/**
- * Class CRUDRoutesLoader
- * Load the route for CRUD
- *
- * @package Chill\MainBundle\CRUD\Routing
- */
class CRUDRoutesLoader extends Loader
{
protected array $crudConfig = [];
protected array $apiCrudConfig = [];
-
- /**
- * @var bool
- */
- private $isLoaded = false;
+
+ private bool $isLoaded = false;
private const ALL_SINGLE_METHODS = [
Request::METHOD_GET,
@@ -52,19 +27,15 @@ class CRUDRoutesLoader extends Loader
];
private const ALL_INDEX_METHODS = [ Request::METHOD_GET, Request::METHOD_HEAD ];
-
- /**
- * CRUDRoutesLoader constructor.
- *
- * @param $crudConfig the config from cruds
- * @param $apicrudConfig the config from api_crud
- */
- public function __construct(array $crudConfig, array $apiConfig)
+
+ public function __construct(array $crudConfig, array $apiCrudConfig)
{
$this->crudConfig = $crudConfig;
- $this->apiConfig = $apiConfig;
+ $this->apiCrudConfig = $apiCrudConfig;
+
+ parent::__construct();
}
-
+
/**
* @param mixed $resource
* @param null $type
@@ -74,7 +45,7 @@ class CRUDRoutesLoader extends Loader
{
return 'CRUD' === $type;
}
-
+
/**
* Load routes for CRUD and CRUD Api
*/
@@ -85,17 +56,17 @@ class CRUDRoutesLoader extends Loader
}
$collection = new RouteCollection();
-
+
foreach ($this->crudConfig as $crudConfig) {
$collection->addCollection($this->loadCrudConfig($crudConfig));
}
- foreach ($this->apiConfig as $crudConfig) {
+ foreach ($this->apiCrudConfig as $crudConfig) {
$collection->addCollection($this->loadApi($crudConfig));
}
return $collection;
}
-
+
/**
* Load routes for CRUD (without api)
*
@@ -112,7 +83,7 @@ class CRUDRoutesLoader extends Loader
$defaults = [
'_controller' => $controller.':'.($action['controller_action'] ?? $name)
];
-
+
if ($name === 'index') {
$path = "{_locale}".$crudConfig['base_path'];
$route = new Route($path, $defaults);
@@ -126,10 +97,10 @@ class CRUDRoutesLoader extends Loader
];
$route = new Route($path, $defaults, $requirements);
}
-
+
$collection->add('chill_crud_'.$crudConfig['name'].'_'.$name, $route);
}
-
+
return $collection;
}
@@ -186,14 +157,14 @@ class CRUDRoutesLoader extends Loader
if (count($methods) === 0) {
throw new \RuntimeException("The api configuration named \"{$crudConfig['name']}\", action \"{$name}\", ".
"does not have any allowed methods. You should remove this action from the config ".
- "or allow, at least, one method");
+ "or allow, at least, one method");
}
if ('_entity' === $name && \in_array(Request::METHOD_POST, $methods)) {
unset($methods[\array_search(Request::METHOD_POST, $methods)]);
- $entityPostRoute = $this->createEntityPostRoute($name, $crudConfig, $action,
+ $entityPostRoute = $this->createEntityPostRoute($name, $crudConfig, $action,
$controller);
- $collection->add("chill_api_single_{$crudConfig['name']}_{$name}_create",
+ $collection->add("chill_api_single_{$crudConfig['name']}_{$name}_create",
$entityPostRoute);
}
@@ -205,7 +176,7 @@ class CRUDRoutesLoader extends Loader
$route = new Route($path, $defaults, $requirements);
$route->setMethods($methods);
-
+
$collection->add('chill_api_single_'.$crudConfig['name'].'_'.$name, $route);
}
From 68a21fcc0af5278ce18e2c2bd0c8ea0343893064 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:32:35 +0100
Subject: [PATCH 168/227] fix: SA: Fix "...Instantiated class not found..."
rules.
SA stands for Static Analysis.
---
phpstan-baseline.neon | 15 -------------
.../Controller/HouseholdMemberController.php | 22 +++++++++----------
.../ORM/LoadSocialWorkMetadata.php | 19 ++++++----------
3 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 9d9a5affd..a3a2f6e04 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -80,26 +80,11 @@ parameters:
count: 1
path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php
- -
- message: "#^Instantiated class Chill\\\\PersonBundle\\\\Controller\\\\BadRequestExceptions not found\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
-
-
message: "#^Variable method call on mixed\\.$#"
count: 1
path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php
- -
- message: "#^Caught class Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\Throwable not found\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
-
- -
- message: "#^Instantiated class Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\Exception not found\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
-
-
message: "#^Foreach overwrites \\$value with its value variable\\.$#"
count: 1
diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
index 2cfd12842..2d6f70f85 100644
--- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php
@@ -38,7 +38,7 @@ class HouseholdMemberController extends ApiController
$this->translator = $translator;
$this->periodRepository = $periodRepository;
}
-
+
/**
* @Route(
* "/api/1.0/person/household/members/move.{_format}",
@@ -75,7 +75,7 @@ class HouseholdMemberController extends ApiController
}
foreach ($editor->getPersistable() as $el) {
- $em->persist($el);
+ $em->persist($el);
}
$em->flush();
@@ -89,8 +89,8 @@ class HouseholdMemberController extends ApiController
*
* * persons[]: an id of the person to add to the form
* * household: the id of the destination household
- * * allow_leave_without_household: if present, the editor will allow
- * to leave household without joining another
+ * * allow_leave_without_household: if present, the editor will allow
+ * to leave household without joining another
*
* @Route(
* "/{_locale}/person/household/members/editor",
@@ -105,7 +105,7 @@ class HouseholdMemberController extends ApiController
$ids = $request->query->get('persons', []);
if (0 === count($ids)) {
- throw new BadRequestExceptions("parameters persons in query ".
+ throw new BadRequestException("parameters persons in query ".
"is not an array or empty");
}
@@ -114,7 +114,7 @@ class HouseholdMemberController extends ApiController
;
foreach ($persons as $person) {
- $this->denyAccessUnlessGranted(PersonVoter::SEE, $person,
+ $this->denyAccessUnlessGranted(PersonVoter::SEE, $person,
"You are not allowed to see person with id {$person->getId()}"
);
}
@@ -140,11 +140,11 @@ class HouseholdMemberController extends ApiController
;
$data = [
- 'persons' => $persons ?? false ?
+ 'persons' => $persons ?? false ?
$this->getSerializer()->normalize($persons, 'json', [ 'groups' => [ 'read' ]]) : [],
'household' => $household ?? false ?
$this->getSerializer()->normalize($household, 'json', [ 'groups' => [ 'read' ]]) : null,
- 'positions' =>
+ 'positions' =>
$this->getSerializer()->normalize($positions, 'json', [ 'groups' => [ 'read' ]]),
'allowHouseholdCreate' => $allowHouseholdCreate ?? true,
'allowHouseholdSearch' => $allowHouseholdSearch ?? true,
@@ -182,7 +182,7 @@ class HouseholdMemberController extends ApiController
// TODO ACL
$form = $this->createForm(HouseholdMemberType::class, $member, [
- 'validation_groups' => [ 'household_memberships' ]
+ 'validation_groups' => [ 'household_memberships' ]
]);
$form->handleRequest($request);
@@ -190,12 +190,12 @@ class HouseholdMemberController extends ApiController
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $this->translator
- ->trans('household.successfully saved member'))
+ ->trans('household.successfully saved member'))
;
return $this->redirect(
$request->get('returnPath', null) ??
- $this->generator->generate('chill_person_household_summary', [ 'household_id' =>
+ $this->generator->generate('chill_person_household_summary', [ 'household_id' =>
$member->getHousehold()->getId() ])
);
}
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
index f96fb5fc2..eee7df7b6 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php
@@ -1,32 +1,30 @@
importer = $importer;
}
- /**
- * @inheritDoc
- */
public function load(ObjectManager $manager)
{
try {
$csv = Reader::createFromPath(__DIR__.'/data/social_work_metadata.csv');
- } catch (Throwable $e) {
- throw new Exception('Error while loading CSV.',0, $e);
+ } catch (\Throwable $e) {
+ throw new \Exception('Error while loading CSV.',0, $e);
}
$csv->setDelimiter(";");
@@ -34,9 +32,6 @@ class LoadSocialWorkMetadata extends \Doctrine\Bundle\FixturesBundle\Fixture imp
$this->importer->import($csv);
}
- /**
- * @inheritDoc
- */
public function getOrder()
{
return 9500;
From f11df95f59d1b1f3e0b1911fb1bb2440ec69d9a3 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 15:46:33 +0100
Subject: [PATCH 169/227] fix: Follow up
8879734ea2382aaaccf9ce33bcef5df412b15394 and fix service definition.
---
src/Bundle/ChillMainBundle/config/services/crud.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/config/services/crud.yaml b/src/Bundle/ChillMainBundle/config/services/crud.yaml
index c5c05f344..5d1940a87 100644
--- a/src/Bundle/ChillMainBundle/config/services/crud.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/crud.yaml
@@ -2,14 +2,14 @@ services:
Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader:
arguments:
$crudConfig: '%chill_main_crud_route_loader_config%'
- $apiConfig: '%chill_main_api_route_loader_config%'
+ $apiCrudConfig: '%chill_main_api_route_loader_config%'
tags: [ routing.loader ]
Chill\MainBundle\CRUD\Resolver\Resolver:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$crudConfig: '%chill_main_crud_route_loader_config%'
-
+
Chill\MainBundle\CRUD\Templating\TwigCRUDResolver:
arguments:
$resolver: '@Chill\MainBundle\CRUD\Resolver\Resolver'
From 6cfcf91757f4f5fcc4c6725ff300c51cb058238d Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 16:28:20 +0100
Subject: [PATCH 170/227] fix: Follow up
f8aeb085946f7992afc551bbdf22d04b944cd08f and fix parameters type.
---
.../Controller/ActivityController.php | 96 +++++++++----------
.../ChillActivityBundle/Entity/Activity.php | 23 +----
2 files changed, 50 insertions(+), 69 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
index 9b1f3f48a..543aa1f6b 100644
--- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
+++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
@@ -4,15 +4,20 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
+use Chill\ActivityBundle\Entity\ActivityReason;
+use Chill\ActivityBundle\Entity\ActivityTypeCategory;
use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
+use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
+use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Form;
+use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -65,10 +70,10 @@ final class ActivityController extends AbstractController
$activities = $this->activityACLAwareRepository
->findByPerson($person, ActivityVoter::SEE, 0, null);
- $event = new PrivacyEvent($person, array(
+ $event = new PrivacyEvent($person, [
'element_class' => Activity::class,
'action' => 'list'
- ));
+ ]);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$view = 'ChillActivityBundle:Activity:listPerson.html.twig';
@@ -106,11 +111,11 @@ final class ActivityController extends AbstractController
$data = [];
- $activityTypeCategories = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityTypeCategory::class)
+ $activityTypeCategories = $em->getRepository(ActivityTypeCategory::class)
->findBy(['active' => true], ['ordering' => 'ASC']);
foreach ($activityTypeCategories as $activityTypeCategory) {
- $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
+ $activityTypes = $em->getRepository(ActivityType::class)
->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
$data[] = [
@@ -119,12 +124,6 @@ final class ActivityController extends AbstractController
];
}
- if ($request->query->has('activityData')) {
- $activityData = $request->query->get('activityData');
- } else {
- $activityData = [];
- }
-
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
@@ -133,7 +132,7 @@ final class ActivityController extends AbstractController
'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
'data' => $data,
- 'activityData' => $activityData
+ 'activityData' => $request->query->get('activityData', []),
]);
}
@@ -151,7 +150,7 @@ final class ActivityController extends AbstractController
}
$activityType_id = $request->get('activityType_id', 0);
- $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
+ $activityType = $em->getRepository(ActivityType::class)
->find($activityType_id);
if (isset($activityType) && !$activityType->isActive()) {
@@ -210,20 +209,20 @@ final class ActivityController extends AbstractController
if (array_key_exists('personsId', $activityData)) {
foreach($activityData['personsId'] as $personId){
- $concernedPerson = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($personId);
+ $concernedPerson = $em->getRepository(Person::class)->find($personId);
$entity->addPerson($concernedPerson);
}
}
if (array_key_exists('professionalsId', $activityData)) {
foreach($activityData['professionalsId'] as $professionalsId){
- $professional = $em->getRepository(\Chill\ThirdPartyBundle\Entity\ThirdParty::class)->find($professionalsId);
+ $professional = $em->getRepository(ThirdParty::class)->find($professionalsId);
$entity->addThirdParty($professional);
}
}
if (array_key_exists('location', $activityData)) {
- $location = $em->getRepository(\Chill\MainBundle\Entity\Location::class)->find($activityData['location']);
+ $location = $em->getRepository(Location::class)->find($activityData['location']);
$entity->setLocation($location);
}
@@ -288,13 +287,15 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:showPerson.html.twig';
}
- $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
+ /** @var Activity $entity */
+ $entity = $em->getRepository(Activity::class)->find($id);
- if (!$entity) {
+ if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
if (null !== $accompanyingPeriod) {
+ // @TODO: Properties created dynamically.
$entity->personsAssociated = $entity->getPersonsAssociated();
$entity->personsNotAssociated = $entity->getPersonsNotAssociated();
}
@@ -302,7 +303,7 @@ final class ActivityController extends AbstractController
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity);
- $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
+ $deleteForm = $this->createDeleteForm($entity->getId(), $person, $accompanyingPeriod);
// TODO
/*
@@ -318,17 +319,16 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Template not found');
}
- return $this->render($view, array(
+ return $this->render($view, [
'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
- ));
+ ]);
}
/**
* Displays a form to edit an existing Activity entity.
- *
*/
public function editAction($id, Request $request): Response
{
@@ -343,9 +343,10 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
- $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
+ /** @var Activity $entity */
+ $entity = $em->getRepository(Activity::class)->find($id);
- if (!$entity) {
+ if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
@@ -366,11 +367,12 @@ final class ActivityController extends AbstractController
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
- $params['id'] = $id;
+ $params['id'] = $entity->getId();
+
return $this->redirectToRoute('chill_activity_activity_show', $params);
}
- $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
+ $deleteForm = $this->createDeleteForm($entity->getId(), $person, $accompanyingPeriod);
/*
* TODO
@@ -388,19 +390,18 @@ final class ActivityController extends AbstractController
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
- return $this->render($view, array(
+ return $this->render($view, [
'entity' => $entity,
'edit_form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
'activity_json' => $activity_array
- ));
+ ]);
}
/**
* Deletes a Activity entity.
- *
*/
public function deleteAction(Request $request, $id)
{
@@ -415,8 +416,8 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
- /* @var $activity Activity */
- $activity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
+ /* @var Activity $activity */
+ $activity = $em->getRepository(Activity::class)->find($id);
if (!$activity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
@@ -425,27 +426,28 @@ final class ActivityController extends AbstractController
// TODO
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
- $form = $this->createDeleteForm($id, $person, $accompanyingPeriod);
+ $form = $this->createDeleteForm($activity->getId(), $person, $accompanyingPeriod);
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
-
- $this->logger->notice("An activity has been removed", array(
+ $this->logger->notice("An activity has been removed", [
'by_user' => $this->getUser()->getUsername(),
'activity_id' => $activity->getId(),
'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
'comment' => $activity->getComment()->getComment(),
'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
'reasons_ids' => $activity->getReasons()
- ->map(function ($ar) { return $ar->getId(); })
+ ->map(
+ static fn (ActivityReason $ar): int => $ar->getId()
+ )
->toArray(),
'type_id' => $activity->getType()->getId(),
'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
'date' => $activity->getDate()->format('Y-m-d'),
'attendee' => $activity->getAttendee()
- ));
+ ]);
$em->remove($activity);
$em->flush();
@@ -454,6 +456,7 @@ final class ActivityController extends AbstractController
->trans("The activity has been successfully removed."));
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
+
return $this->redirectToRoute('chill_activity_activity_list', $params);
}
}
@@ -462,18 +465,18 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Template not found');
}
- return $this->render($view, array(
+ return $this->render($view, [
'activity' => $activity,
'delete_form' => $form->createView(),
'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
- ));
+ ]);
}
/**
* Creates a form to delete a Activity entity by id.
*/
- private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): Form
+ private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): FormInterface
{
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
$params['id'] = $id;
@@ -481,9 +484,8 @@ final class ActivityController extends AbstractController
return $this->createFormBuilder()
->setAction($this->generateUrl('chill_activity_activity_delete', $params))
->setMethod('DELETE')
- ->add('submit', SubmitType::class, array('label' => 'Delete'))
- ->getForm()
- ;
+ ->add('submit', SubmitType::class, ['label' => 'Delete'])
+ ->getForm();
}
private function getEntity(Request $request): array
@@ -515,21 +517,19 @@ final class ActivityController extends AbstractController
}
return [
- $person, $accompanyingPeriod
+ $person,
+ $accompanyingPeriod
];
}
- private function buildParamsToUrl(
- ?Person $person,
- ?AccompanyingPeriod $accompanyingPeriod
- ): array {
+ private function buildParamsToUrl(?Person $person, ?AccompanyingPeriod $accompanyingPeriod): array {
$params = [];
- if ($person) {
+ if (null !== $person) {
$params['person_id'] = $person->getId();
}
- if ($accompanyingPeriod) {
+ if (null !== $accompanyingPeriod) {
$params['accompanying_period_id'] = $accompanyingPeriod->getId();
}
diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php
index e25448f10..4ed654c85 100644
--- a/src/Bundle/ChillActivityBundle/Entity/Activity.php
+++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php
@@ -1,27 +1,8 @@
- *
- * 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 .
- */
-
namespace Chill\ActivityBundle\Entity;
use Chill\DocStoreBundle\Entity\Document;
-use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Entity\Location;
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
@@ -38,7 +19,7 @@ use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
-use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
+use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
@@ -202,7 +183,7 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this->id;
}
- public function setUser(User $user): self
+ public function setUser(UserInterface $user): self
{
$this->user = $user;
From db2010082a7bddba324d9660ba9002bae3e6deeb Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 16:37:45 +0100
Subject: [PATCH 171/227] fix: SA: Fix "...Access to an undefined property..."
rule.
SA stands for Static Analysis.
---
phpstan-critical.neon | 5 ---
.../JsonCustomFieldToArrayTransformer.php | 45 ++++++++-----------
2 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index cb0ac38ce..31bd2f99f 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -195,11 +195,6 @@ parameters:
count: 2
path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
- -
- message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#"
- count: 3
- path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
-
-
message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
count: 1
diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
index 6b54df801..2d04c036d 100644
--- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
+++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php
@@ -1,28 +1,27 @@
om = $om;
$customFields = $this->om
- ->getRepository('ChillCustomFieldsBundle:CustomField')
+ ->getRepository(CustomField::class)
->findAll();
-
+
+ // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
$customFieldsLablels = array_map(
function($e) { return $e->getLabel(); },
$customFields);
@@ -36,20 +35,12 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
{
echo $customFieldsJSON;
- if($customFieldsJSON === null) { // lors de la creation
- $customFieldsArray = array();
+ if($customFieldsJSON === null) {
+ $customFieldsArray = [];
} else {
- $customFieldsArray = json_decode($customFieldsJSON,true);
+ $customFieldsArray = json_decode($customFieldsJSON, true, 512, JSON_THROW_ON_ERROR);
}
- /*
- echo " - 4 - ";
-
- var_dump($customFieldsArray);
-
- echo " - 5 - ";
- */
-
$customFieldsArrayRet = array();
foreach ($customFieldsArray as $key => $value) {
@@ -62,7 +53,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
} else {
$entityClass = substr($type, 10, -1);
}
-
+
$customFieldsArrayRet[$key] = $this->om
->getRepository('ChillCustomFieldsBundle:' . $entityClass)
->findOneById($value);
@@ -86,10 +77,10 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
{
/*
echo " - - 7 - ";
-
+
var_dump(array_keys($customFieldsArray));
-
+
echo " - - 8 - ";
var_dump(array_keys($this->customField));
@@ -112,7 +103,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
//$entityClass = substr($type, 10, -1);
//echo $entityClasss;
if(strpos($type, 'ManyToOnePersist') === 0) {
- // PEUT ETRE A FAIRE SI SEULEMENT $value->getId() ne renvoie rien...
+ // PEUT ETRE A FAIRE SI SEULEMENT $value->getId() ne renvoie rien...
//
//
$this->om->persist($value); // pas bon ici
@@ -121,7 +112,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
// et faire le persist qd fait sur l'obj parent
// regarder : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
// ou : http://symfony.com/doc/current/cookbook/doctrine/event_listeners_subscribers.html
- // dans yml :
+ // dans yml :
// lifecycleCallbacks:
// prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersist ]
$this->om->flush(); // sinon l'id pose pbm
@@ -142,4 +133,4 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
return json_encode($customFieldsArrayRet);
}
-}
\ No newline at end of file
+}
From 5432242376f17b894247b97d3ec39cf5ec1e8bf4 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 17:13:39 +0100
Subject: [PATCH 172/227] fix: SA: Fix many critical rules.
SA stands for Static Analysis.
---
phpstan-critical.neon | 70 -----
.../src/Entity/AsideActivityCategory.php | 4 +-
.../src/Form/AsideActivityCategoryType.php | 11 +-
.../src/Form/AsideActivityFormType.php | 4 +-
.../DataFixtures/ORM/LoadCalendarRange.php | 8 +-
.../Controller/FamilyMemberController.php | 70 ++---
.../Controller/AbstractCRUDController.php | 117 ++++----
.../Command/ChillImportUsersCommand.php | 271 +++++++-----------
.../Controller/AdminCountryCRUDController.php | 14 +-
.../Controller/UserController.php | 21 +-
.../ChillMainBundle/Entity/RoleScope.php | 52 +---
.../Pagination/PageGenerator.php | 45 +--
.../ChillMainBundle/Routing/MenuComposer.php | 91 +++---
.../Search/SearchApiResult.php | 6 +-
.../Authorization/AbstractChillVoter.php | 25 +-
.../Controller/TimelinePersonController.php | 57 ++--
.../DataFixtures/ORM/LoadHousehold.php | 12 +-
.../Form/CreationPersonType.php | 35 +--
.../Timeline/TimelineReportProvider.php | 87 +++---
19 files changed, 345 insertions(+), 655 deletions(-)
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index 31bd2f99f..2e2f778d8 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -90,51 +90,21 @@ parameters:
count: 1
path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
- -
- message: "#^Undefined variable\\: \\$id$#"
- count: 1
- path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
-
-
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
- -
- message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
-
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
-
-
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Controller/UserController.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Entity/RoleScope.php
-
-
message: "#^Undefined variable\\: \\$current$#"
count: 1
path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#"
- count: 1
- path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php
-
- -
- message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#"
- count: 2
- path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php
-
-
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
count: 1
@@ -155,46 +125,6 @@ parameters:
count: 3
path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
-
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#"
- count: 2
- path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
-
- -
- message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#"
- count: 1
- path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
-
- -
- message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#"
- count: 4
- path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
-
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
-
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#"
- count: 2
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
-
- -
- message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#"
- count: 1
- path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
-
- -
- message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#"
- count: 2
- path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
-
-
message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
count: 1
diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
index 09087226c..143e430f7 100644
--- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
+++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
@@ -44,13 +44,15 @@ class AsideActivityCategory
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
* @ORM\JoinColumn(nullable=true)
*/
- private $parent;
+ private AsideActivityCategory $parent;
/**
* @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent")
*/
private $children;
+ private AsideActivityCategory $oldParent;
+
public function __construct()
{
$this->children = new ArrayCollection();
diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
index 0060ab1b9..e438998b0 100644
--- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
+++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php
@@ -1,5 +1,7 @@
translatableStringHelper = $translatableStringHelper;
+ public function __construct(
+ CategoryRender $categoryRender
+ ) {
$this->categoryRender = $categoryRender;
}
diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
index 53ce5bd40..f517279bb 100644
--- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
+++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php
@@ -25,18 +25,16 @@ use Symfony\Component\Templating\EngineInterface;
final class AsideActivityFormType extends AbstractType
{
- protected array $timeChoices;
+ private array $timeChoices;
private TokenStorageInterface $storage;
private CategoryRender $categoryRender;
public function __construct (
- TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag,
TokenStorageInterface $storage,
CategoryRender $categoryRender
){
$this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration');
- $this->translatableStringHelper = $translatableStringHelper;
$this->storage = $storage;
$this->categoryRender = $categoryRender;
}
diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
index c23871c26..42218da03 100644
--- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
+++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php
@@ -1,5 +1,7 @@
chillMainLogger = $chillMainLogger;
}
-
+
/**
* @Route(
* "{_locale}/family-members/family-members/by-person/{id}",
@@ -54,11 +42,11 @@ class FamilyMemberController extends Controller
public function indexAction(Person $person)
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::SHOW, $person);
-
+
$familyMembers = $this->em
->getRepository(FamilyMember::class)
->findByPerson($person);
-
+
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:index.html.twig', array(
'person' => $person,
'familyMembers' => $familyMembers
@@ -76,26 +64,26 @@ class FamilyMemberController extends Controller
$familyMember = (new FamilyMember())
->setPerson($person)
;
-
+
$this->denyAccessUnlessGranted(FamilyMemberVoter::CREATE, $familyMember);
-
+
$form = $this->createForm(FamilyMemberType::class, $familyMember);
$form->add('submit', SubmitType::class);
-
+
$form->handleRequest($request);
-
+
if ($form->isSubmitted() and $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($familyMember);
$em->flush();
-
+
$this->addFlash('success', $this->translator->trans('Family member created'));
-
+
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $person->getId()
]);
}
-
+
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:new.html.twig', array(
'form' => $form->createView(),
'person' => $person
@@ -111,37 +99,37 @@ class FamilyMemberController extends Controller
public function editAction(FamilyMember $familyMember, Request $request)
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::UPDATE, $familyMember);
-
+
$form = $this->createForm(FamilyMemberType::class, $familyMember);
$form->add('submit', SubmitType::class);
-
+
$form->handleRequest($request);
-
+
if ($form->isSubmitted() and $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->flush();
-
+
$this->addFlash('success', $this->translator->trans('Family member updated'));
-
+
return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId()
]);
}
-
+
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:edit.html.twig', array(
'familyMember' => $familyMember,
'form' => $form->createView(),
'person' => $familyMember->getPerson()
));
}
-
+
/**
- *
+ *
* @Route(
* "{_locale}/family-members/family-members/{id}/delete",
* name="chill_family_members_family_members_delete"
* )
- *
+ *
* @param FamilyMember $familyMember
* @param Request $request
* @return \Symfony\Component\BrowserKit\Response
@@ -183,7 +171,7 @@ class FamilyMemberController extends Controller
'delete_form' => $form->createView()
));
}
-
+
/**
* @Route(
* "{_locale}/family-members/family-members/{id}/view",
@@ -193,12 +181,12 @@ class FamilyMemberController extends Controller
public function viewAction(FamilyMember $familyMember)
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::SHOW, $familyMember);
-
+
return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:view.html.twig', array(
'familyMember' => $familyMember
));
}
-
+
/**
* Creates a form to delete a help request entity by id.
*
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
index a1d28483d..451ce8aab 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
@@ -1,5 +1,7 @@
getDoctrine()
+ $e = $this
+ ->getDoctrine()
->getRepository($this->getEntityClass())
->find($id);
- if (NULL === $e) {
+ if (null === $e) {
throw $this->createNotFoundException(sprintf("The object %s for id %s is not found", $this->getEntityClass(), $id));
}
@@ -47,61 +46,50 @@ class AbstractCRUDController extends AbstractController
/**
* Create an entity.
- *
- * @param string $action
- * @param Request $request
+ *
* @return object
*/
protected function createEntity(string $action, Request $request): object
{
- $type = $this->getEntityClass();
-
- return new $type;
+ return $this->getEntityClass();
}
/**
* Count the number of entities
*
- * By default, count all entities. You can customize the query by
+ * By default, count all entities. You can customize the query by
* using the method `customizeQuery`.
- *
- * @param string $action
- * @param Request $request
- * @return int
*/
protected function countEntities(string $action, Request $request, $_format): int
{
return $this->buildQueryEntities($action, $request)
->select('COUNT(e)')
->getQuery()
- ->getSingleScalarResult()
- ;
+ ->getSingleScalarResult();
}
/**
* Query the entity.
- *
+ *
* By default, get all entities. You can customize the query by using the
* method `customizeQuery`.
- *
+ *
* The method `orderEntity` is called internally to order entities.
- *
+ *
* It returns, by default, a query builder.
- *
*/
protected function queryEntities(string $action, Request $request, string $_format, PaginatorInterface $paginator)
{
$query = $this->buildQueryEntities($action, $request)
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
->setMaxResults($paginator->getItemsPerPage());
-
+
// allow to order queries and return the new query
return $this->orderQuery($action, $query, $request, $paginator, $_format);
}
/**
* Add ordering fields in the query build by self::queryEntities
- *
*/
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
{
@@ -112,14 +100,12 @@ class AbstractCRUDController extends AbstractController
* Build the base query for listing all entities.
*
* This method is used internally by `countEntities` `queryEntities`
- *
+ *
* This base query does not contains any `WHERE` or `SELECT` clauses. You
* can add some by using the method `customizeQuery`.
*
* The alias for the entity is "e".
- *
- * @param string $action
- * @param Request $request
+ *
* @return QueryBuilder
*/
protected function buildQueryEntities(string $action, Request $request)
@@ -127,8 +113,7 @@ class AbstractCRUDController extends AbstractController
$qb = $this->getDoctrine()->getManager()
->createQueryBuilder()
->select('e')
- ->from($this->getEntityClass(), 'e')
- ;
+ ->from($this->getEntityClass(), 'e');
$this->customizeQuery($action, $request, $qb);
@@ -138,55 +123,55 @@ class AbstractCRUDController extends AbstractController
protected function customizeQuery(string $action, Request $request, $query): void {}
/**
- * Get the result of the query
+ * Get the result of the query.
*/
- protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query)
+ protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query)
{
return $query->getQuery()->getResult();
}
protected function onPreIndex(string $action, Request $request, string $_format): ?Response
- {
- return null;
- }
-
- /**
- * method used by indexAction
- */
- protected function onPreIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator): ?Response
- {
+ {
return null;
}
/**
- * method used by indexAction
+ * Method used by indexAction.
+ */
+ protected function onPreIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator): ?Response
+ {
+ return null;
+ }
+
+ /**
+ * Method used by indexAction.
*/
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response
{
return null;
}
-
+
/**
- * method used by indexAction
+ * Method used by indexAction.
*/
protected function onPostIndexFetchQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $entities): ?Response
{
return null;
}
-
+
/**
- * Get the complete FQDN of the class
- *
- * @return string the complete fqdn of the class
+ * Get the FQDN of the class.
+ *
+ * @return string The FQDN of the class
*/
protected function getEntityClass(): string
{
return $this->crudConfig['class'];
}
-
+
/**
- * called on post fetch entity
+ * Called on post fetch entity.
*/
protected function onPostFetchEntity(string $action, Request $request, $entity, $_format): ?Response
{
@@ -194,7 +179,7 @@ class AbstractCRUDController extends AbstractController
}
/**
- * Called on post check ACL
+ * Called on post check ACL.
*/
protected function onPostCheckACL(string $action, Request $request, string $_format, $entity): ?Response
{
@@ -203,23 +188,23 @@ class AbstractCRUDController extends AbstractController
/**
* check the acl. Called by every action.
- *
- * By default, check the role given by `getRoleFor` for the value given in
+ *
+ * By default, check the role given by `getRoleFor` for the value given in
* $entity.
- *
+ *
* Throw an \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException
* if not accessible.
- *
+ *
* @throws \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException
*/
protected function checkACL(string $action, Request $request, string $_format, $entity = null)
{
+ // @TODO: Implements abstract getRoleFor method or do it in the interface.
$this->denyAccessUnlessGranted($this->getRoleFor($action, $request, $entity, $_format), $entity);
}
/**
- *
- * @return string the crud name
+ * @return string The crud name.
*/
protected function getCrudName(): string
{
@@ -230,7 +215,7 @@ class AbstractCRUDController extends AbstractController
{
return $this->crudConfig['actions'][$action];
}
-
+
/**
* Set the crud configuration
*
@@ -241,9 +226,6 @@ class AbstractCRUDController extends AbstractController
$this->crudConfig = $config;
}
- /**
- * @return PaginatorFactory
- */
protected function getPaginatorFactory(): PaginatorFactory
{
return $this->container->get('chill_main.paginator_factory');
@@ -254,9 +236,6 @@ class AbstractCRUDController extends AbstractController
return $this->get('validator');
}
- /**
- * @return array
- */
public static function getSubscribedServices(): array
{
return \array_merge(
diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
index 99bd17d8f..d3fb6980f 100644
--- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
@@ -1,7 +1,10 @@
passwordEncoder = $passwordEncoder;
$this->validator = $validator;
$this->logger = $logger;
-
-
+
$this->userRepository = $em->getRepository(User::class);
-
+
parent::__construct('chill:main:import-users');
}
-
-
protected function configure()
{
$this
@@ -126,25 +79,24 @@ class ChillImportUsersCommand extends Command
->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')
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do not commit the changes')
- ->addOption('csv-dump', null, InputOption::VALUE_REQUIRED, 'A path to dump a summary of the created file')
- ;
+ ->addOption('csv-dump', null, InputOption::VALUE_REQUIRED, 'A path to dump a summary of the created file');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->tempOutput = $output;
$this->tempInput = $input;
-
+
if ($input->getOption('dry-run')) {
$this->doChanges = false;
}
-
+
$this->prepareWriter();
-
+
if ($input->hasOption('grouping-centers')) {
$this->prepareGroupingCenters();
}
-
+
try {
$this->loadUsers();
}
@@ -152,19 +104,19 @@ class ChillImportUsersCommand extends Command
throw $e;
}
}
-
+
protected function prepareWriter()
{
$this->output = $output = Writer::createFromPath($this->tempInput
->getOption('csv-dump'), 'a+');
-
+
$output->insertOne([
'email',
'username',
'id'
]);
}
-
+
protected function appendUserToFile(User $user)
{
$this->output->insertOne( [
@@ -173,35 +125,35 @@ class ChillImportUsersCommand extends Command
$user->getId()
]);
}
-
+
protected function loadUsers()
{
$reader = Reader::createFromPath($this->tempInput->getArgument('csvfile'));
$reader->setHeaderOffset(0);
-
+
foreach ($reader->getRecords() as $line => $r) {
$this->logger->debug("starting handling new line", [
'line' => $line
]);
-
+
if ($this->doesUserExists($r)) {
$this->tempOutput->writeln(sprintf("User with username '%s' already "
. "exists, skipping", $r["username"]));
-
+
$this->logger->info("One user already exists, skipping creation", [
'username_in_file' => $r['username'],
'email_in_file' => $r['email'],
'line' => $line
]);
-
+
continue;
}
-
+
$user = $this->createUser($line, $r);
$this->appendUserToFile($user);
}
}
-
+
protected function doesUserExists($data)
{
if ($this->userRepository->countByUsernameOrEmail($data['username']) > 0) {
@@ -211,10 +163,10 @@ class ChillImportUsersCommand extends Command
if ($this->userRepository->countByUsernameOrEmail($data['email']) > 0) {
return true;
}
-
+
return false;
}
-
+
protected function createUser($offset, $data)
{
$user = new User();
@@ -222,41 +174,41 @@ class ChillImportUsersCommand extends Command
->setEmail(\trim($data['email']))
->setUsername(\trim($data['username']))
->setEnabled(true)
- ->setPassword($this->passwordEncoder->encodePassword($user,
+ ->setPassword($this->passwordEncoder->encodePassword($user,
\bin2hex(\random_bytes(32))))
;
-
+
$errors = $this->validator->validate($user);
-
+
if ($errors->count() > 0) {
$errorMessages = $this->concatenateViolations($errors);
-
+
$this->tempOutput->writeln(sprintf("%d errors found with user with username \"%s\" at line %d", $errors->count(), $data['username'], $offset));
$this->tempOutput->writeln($errorMessages);
throw new \RuntimeException("Found errors while creating an user. "
. "Watch messages in command output");
}
-
+
$pgs = $this->getPermissionGroup($data['permission group']);
$centers = $this->getCenters($data['center']);
-
+
foreach($pgs as $pg) {
foreach ($centers as $center) {
$groupcenter = $this->createOrGetGroupCenter($center, $pg);
-
+
if (FALSE === $user->getGroupCenters()->contains($groupcenter)) {
$user->addGroupCenter($groupcenter);
}
}
}
-
+
if ($this->doChanges) {
$this->em->persist($user);
$this->em->flush();
}
-
+
$this->logger->notice("Create user", [
'username' => $user->getUsername(),
'id' => $user->getId(),
@@ -265,65 +217,58 @@ class ChillImportUsersCommand extends Command
return $user;
}
-
+
protected function getPermissionGroup($alias)
{
if (\array_key_exists($alias, $this->permissionGroups)) {
return $this->permissionGroups[$alias];
}
-
+
$permissionGroupsByName = [];
-
+
foreach($this->em->getRepository(PermissionsGroup::class)
->findAll() as $permissionGroup) {
$permissionGroupsByName[$permissionGroup->getName()] = $permissionGroup;
}
-
+
if (count($permissionGroupsByName) === 0) {
throw new \RuntimeException("no permission groups found. Create them "
. "before importing users");
}
-
- $question = new ChoiceQuestion("To which permission groups associate with \"$alias\" ?",
+
+ $question = new ChoiceQuestion("To which permission groups associate with \"$alias\" ?",
\array_keys($permissionGroupsByName));
$question
->setMultiselect(true)
->setAutocompleterValues(\array_keys($permissionGroupsByName))
->setNormalizer(function($value) {
if (NULL === $value) { return ''; }
-
+
return \trim($value);
})
;
$helper = $this->getHelper('question');
-
+
$keys = $helper->ask($this->tempInput, $this->tempOutput, $question);
-
+
$this->tempOutput->writeln("You have chosen ".\implode(", ", $keys));
-
- if ($helper->ask($this->tempInput, $this->tempOutput,
+
+ if ($helper->ask($this->tempInput, $this->tempOutput,
new ConfirmationQuestion("Are you sure ?", true))) {
-
+
foreach ($keys as $key) {
$this->permissionGroups[$alias][] = $permissionGroupsByName[$key];
}
-
+
return $this->permissionGroups[$alias];
- } else {
- $this->logger->error("Error while responding to a a question");
-
- $this->tempOutput("Ok, I accept, but I do not know what to do. Please try again.");
-
- throw new \RuntimeException("Error while responding to a question");
}
+
+ $this->logger->error('Error while responding to a a question');
+ $this->tempOutput->writeln('Ok, I accept, but I do not know what to do. Please try again.');
+
+ throw new \RuntimeException('Error while responding to a question');
}
-
- /**
- *
- * @param Center $center
- * @param \Chill\MainBundle\Command\PermissionGroup $pg
- * @return GroupCenter
- */
+
protected function createOrGetGroupCenter(Center $center, PermissionsGroup $pg): GroupCenter
{
if (\array_key_exists($center->getId(), $this->groupCenters)) {
@@ -331,36 +276,36 @@ class ChillImportUsersCommand extends Command
return $this->groupCenters[$center->getId()][$pg->getId()];
}
}
-
+
$repository = $this->em->getRepository(GroupCenter::class);
-
+
$groupCenter = $repository->findOneBy(array(
'center' => $center,
'permissionsGroup' => $pg
));
-
+
if ($groupCenter === NULL) {
$groupCenter = new GroupCenter();
$groupCenter
->setCenter($center)
->setPermissionsGroup($pg)
;
-
+
$this->em->persist($groupCenter);
}
-
+
$this->groupCenters[$center->getId()][$pg->getId()] = $groupCenter;
-
+
return $groupCenter;
}
-
+
protected function prepareGroupingCenters()
{
$reader = Reader::createFromPath($this->tempInput->getOption('grouping-centers'));
$reader->setHeaderOffset(0);
-
+
foreach ($reader->getRecords() as $r) {
- $this->centers[$r['alias']] =
+ $this->centers[$r['alias']] =
\array_merge(
$this->centers[$r['alias']] ?? [],
$this->getCenters($r['center']
@@ -368,18 +313,18 @@ class ChillImportUsersCommand extends Command
);
}
}
-
+
/**
* return a list of centers matching the name of alias.
- *
+ *
* If the name match one center, this center is returned in an array.
- *
- * If the name match an alias, the centers corresponding to the alias are
+ *
+ * If the name match an alias, the centers corresponding to the alias are
* returned in an array.
- *
+ *
* If the center is not found or alias is not created, a new center is created
* and suggested to user
- *
+ *
* @param string $name the name of the center or the alias regrouping center
* @return Center[]
*/
@@ -387,62 +332,62 @@ class ChillImportUsersCommand extends Command
{
// sanitize
$name = \trim($name);
-
+
if (\array_key_exists($name, $this->centers)) {
return $this->centers[$name];
}
-
+
// search for a center with given name
$center = $this->em->getRepository(Center::class)
->findOneByName($name);
-
+
if ($center instanceof Center) {
$this->centers[$name] = [$center];
-
+
return $this->centers[$name];
}
-
+
// suggest and create
$center = (new Center())
->setName($name);
-
+
$this->tempOutput->writeln("Center with name \"$name\" not found.");
$qFormatter = $this->getHelper('question');
$question = new ConfirmationQuestion("Create a center with name \"$name\" ?", true);
-
+
if ($qFormatter->ask($this->tempInput, $this->tempOutput, $question)) {
$this->centers[$name] = [ $center ];
-
+
$errors = $this->validator->validate($center);
-
+
if ($errors->count() > 0) {
$errorMessages = $this->concatenateViolations($errors);
-
+
$this->tempOutput->writeln(sprintf("%d errors found with center with name \"%s\"", $errors->count(), $name));
$this->tempOutput->writeln($errorMessages);
-
+
throw new \RuntimeException("Found errors while creating one center. "
. "Watch messages in command output");
}
-
+
$this->em->persist($center);
-
+
return $this->centers[$name];
}
-
+
return null;
}
-
+
protected function concatenateViolations(ConstraintViolationListInterface $list)
{
$str = [];
-
+
foreach ($list as $e) {
/* @var $e \Symfony\Component\Validator\ConstraintViolationInterface */
$str[] = $e->getMessage();
}
-
+
return \implode(";", $str);
}
-
+
}
diff --git a/src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php b/src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
index 310a36c60..3be418698 100644
--- a/src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
+++ b/src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php
@@ -1,20 +1,12 @@
paginatorFactory = $paginator;
- }
+
}
diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php
index bb8203011..bd2ad89d7 100644
--- a/src/Bundle/ChillMainBundle/Controller/UserController.php
+++ b/src/Bundle/ChillMainBundle/Controller/UserController.php
@@ -136,20 +136,17 @@ class UserController extends CRUDController
]);
}
- /**
- *
- *
- * @param User $user
- * @return \Symfony\Component\Form\Form
- */
- private function createEditPasswordForm(User $user)
+ private function createEditPasswordForm(User $user): FormInterface
{
- return $this->createForm(UserPasswordType::class, null, array(
- 'user' => $user
- ))
+ return $this->createForm(
+ UserPasswordType::class,
+ null,
+ [
+ 'user' => $user
+ ]
+ )
->add('submit', SubmitType::class, array('label' => 'Change password'))
- ->remove('actual_password')
- ;
+ ->remove('actual_password');
}
/**
diff --git a/src/Bundle/ChillMainBundle/Entity/RoleScope.php b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
index 7842267a9..315e8f594 100644
--- a/src/Bundle/ChillMainBundle/Entity/RoleScope.php
+++ b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
@@ -1,23 +1,5 @@
- *
- * 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 .
- */
-
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -28,38 +10,30 @@ use Doctrine\Common\Collections\ArrayCollection;
* @ORM\Entity
* @ORM\Table(name="role_scopes")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
- *
- * @author Julien Fastré
*/
class RoleScope
{
/**
- * @var integer
- *
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private $id;
-
+ private int $id;
+
/**
- * @var string
- *
* @ORM\Column(type="string", length=255)
*/
- private $role;
-
+ private string $role;
+
/**
- * @var Scope
- *
* @ORM\ManyToOne(
* targetEntity="Chill\MainBundle\Entity\Scope",
* inversedBy="roleScopes")
* @ORM\JoinColumn(nullable=true, name="scope_id")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
- private $scope;
-
+ private Scope $scope;
+
/**
* @var Collection
*
@@ -68,16 +42,14 @@ class RoleScope
* mappedBy="roleScopes")
*/
private $permissionsGroups;
-
-
- /**
- * RoleScope constructor.
- */
+
+ private bool $new;
+
public function __construct() {
$this->new = true;
$this->permissionsGroups = new ArrayCollection();
}
-
+
/**
* @return int
*/
@@ -101,7 +73,7 @@ class RoleScope
{
return $this->scope;
}
-
+
/**
* @param type $role
* @return RoleScope
@@ -120,7 +92,7 @@ class RoleScope
public function setScope(Scope $scope = null)
{
$this->scope = $scope;
-
+
return $this;
}
}
diff --git a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
index 26add87fa..93c481a2e 100644
--- a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
+++ b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
@@ -1,50 +1,23 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
/**
- * PageGenerator associated with a Paginator
- *
- * @author Julien Fastré
- * @author Champs Libres
+ * PageGenerator associated with a Paginator.
*/
class PageGenerator implements \Iterator
{
- /**
- *
- * @var Paginator
- */
- protected $paginator;
-
- /**
- *
- * @var int
- */
- protected $current = 1;
-
- public function __construct(Paginator $paginator)
+ protected Paginator $paginator;
+
+ protected int $current = 1;
+
+ public function __construct(Paginator $paginator)
{
$this->paginator = $paginator;;
}
-
+
public function current()
{
return $this->paginator->getPage($current);
@@ -67,7 +40,7 @@ class PageGenerator implements \Iterator
public function valid()
{
- return $this->current > 0
+ return $this->current > 0
&& $this->current <= $this->paginator->countPages();
}
}
diff --git a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php
index 0bcee4c81..b1883c61d 100644
--- a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php
+++ b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php
@@ -1,5 +1,7 @@
all() as $routeKey => $route) {
if ($route->hasOption('menus')) {
-
+
if (array_key_exists($menuId, $route->getOption('menus'))) {
$route = $route->getOption('menus')[$menuId];
@@ -101,12 +88,12 @@ class MenuComposer
return $routes;
}
-
+
public function getMenuFor($menuId, array $parameters = array())
{
$routes = $this->getRoutesFor($menuId, $parameters);
$menu = $this->menuFactory->createItem($menuId);
-
+
// build menu from routes
foreach ($routes as $order => $route) {
$menu->addChild($this->translator->trans($route['label']), [
@@ -121,24 +108,24 @@ class MenuComposer
])
;
}
-
+
if ($this->hasLocalMenuBuilder($menuId)) {
foreach ($this->localMenuBuilders[$menuId] as $builder) {
/* @var $builder LocalMenuBuilderInterface */
$builder->buildMenu($menuId, $menu, $parameters['args']);
}
}
-
+
$this->reorderMenu($menu);
-
+
return $menu;
}
-
+
/**
* recursive function to resolve the order of a array of routes.
- * If the order chosen in routing.yml is already in used, find the
+ * If the order chosen in routing.yml is already in used, find the
* first next order available.
- *
+ *
* @param array $routes the routes previously added
* @param int $order
* @return int
@@ -151,41 +138,41 @@ class MenuComposer
return $order;
}
}
-
- private function reorderMenu(ItemInterface $menu)
+
+ private function reorderMenu(ItemInterface $menu)
{
$ordered = [];
$unordered = [];
-
+
foreach ($menu->getChildren() as $name => $item) {
$order = $item->getExtra('order');
-
+
if ($order !== null) {
$ordered[$this->resolveOrder($ordered, $order)] = $name;
} else {
$unordered = $name;
}
}
-
+
ksort($ordered);
-
+
$menus = \array_merge(\array_values($ordered), $unordered);
$menu->reorderChildren($menus);
}
-
-
- public function addLocalMenuBuilder(LocalMenuBuilderInterface $menuBuilder, $menuId)
+
+
+ public function addLocalMenuBuilder(LocalMenuBuilderInterface $menuBuilder, $menuId)
{
$this->localMenuBuilders[$menuId][] = $menuBuilder;
}
-
+
/**
* Return true if the menu has at least one builder.
- *
+ *
* This function is a helper to determine if the method `getMenuFor`
* should be used, or `getRouteFor`. The method `getMenuFor` should be used
* if the result is true (it **does** exists at least one menu builder.
- *
+ *
* @param string $menuId
* @return bool
*/
diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php
index bbc66877f..c44db3339 100644
--- a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php
+++ b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php
@@ -1,5 +1,7 @@
relevance = $relevance;
@@ -20,7 +24,7 @@ class SearchApiResult
$this->result = $result;
return $this;
- }
+ }
/**
* @Serializer\Groups({"read"})
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
index 9131a6501..fec4da627 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
@@ -1,34 +1,17 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\MainBundle\Security\Authorization;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
/**
* Voter for Chill software.
*
* This abstract Voter provide generic methods to handle object specific to Chill
- *
- *
- * @author Julien Fastré
*/
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
{
@@ -39,6 +22,8 @@ abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
. 'getSupportedAttributes and getSupportedClasses methods.',
E_USER_DEPRECATED);
+ // @TODO: getSupportedAttributes() should be created in here and made abstract or in ChillVoterInterface.
+ // @TODO: getSupportedClasses() should be created in here and made abstract or in ChillVoterInterface.
return \in_array($attribute, $this->getSupportedAttributes($attribute))
&& \in_array(\get_class($subject), $this->getSupportedClasses());
}
@@ -49,7 +34,7 @@ abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
. 'methods introduced by Symfony 3.0, and do not rely on '
. 'isGranted method', E_USER_DEPRECATED);
+ // @TODO: isGranted() should be created in here and made abstract or in ChillVoterInterface.
return $this->isGranted($attribute, $subject, $token->getUser());
}
-
}
diff --git a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
index 4e3d67755..389c723ce 100644
--- a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
@@ -1,87 +1,62 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
+use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Chill\MainBundle\Timeline\TimelineBuilder;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
-use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
-use Symfony\Component\Security\Core\Role\Role;
class TimelinePersonController extends AbstractController
{
-
protected EventDispatcherInterface $eventDispatcher;
-
+
protected TimelineBuilder $timelineBuilder;
-
+
protected PaginatorFactory $paginatorFactory;
-
- /**
- * TimelinePersonController constructor.
- *
- * @param EventDispatcherInterface $eventDispatcher
- */
+
public function __construct(
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder,
- PaginatorFactory $paginatorFactory,
- AuthorizationHelper $authorizationHelper
+ PaginatorFactory $paginatorFactory
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
- $this->authorizationHelper = $authorizationHelper;
}
-
-
+
public function personAction(Request $request, $person_id)
{
$person = $this->getDoctrine()
- ->getRepository('ChillPersonBundle:Person')
+ ->getRepository(Person::class)
->find($person_id);
if ($person === NULL) {
throw $this->createNotFoundException();
}
-
+
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
-
- $nbItems = $this->timelineBuilder->countItems('person',
+
+ $nbItems = $this->timelineBuilder->countItems('person',
[ 'person' => $person ]
);
-
+
$paginator = $this->paginatorFactory->create($nbItems);
-
+
$event = new PrivacyEvent($person, array('action' => 'timeline'));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
-
+
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
(
'timeline' => $this->timelineBuilder->getTimelineHTML(
- 'person',
+ 'person',
array('person' => $person),
$paginator->getCurrentPage()->getFirstItemNumber(),
$paginator->getItemsPerPage()
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
index 14420ed88..50bf94e58 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
@@ -1,5 +1,7 @@
editorFactory = $editorFactory;
@@ -149,14 +153,14 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
private function preparePersonIds()
{
+ // @TODO: Remove this and make this service stateless
$this->personIds = $this->em
->createQuery('SELECT p.id FROM '.Person::class.' p '.
'JOIN p.center c '.
'WHERE c.name = :center '
)
->setParameter('center', 'Center A')
- ->getScalarResult()
- ;
+ ->getScalarResult();
\shuffle($this->personIds);
}
@@ -169,9 +173,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
for ($i=0; $i < $nb; $i++) {
$personId = \array_pop($this->personIds)['id'];
- $persons[] = $this->em->getRepository(Person::class)
- ->find($personId)
- ;
+ $persons[] = $this->em->getRepository(Person::class)->find($personId);
}
return $persons;
diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
index 3fa8f5cda..704a6e47b 100644
--- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
@@ -1,28 +1,10 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\PersonBundle\Form;
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
-use Chill\MainBundle\Repository\CenterRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -30,12 +12,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
-use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickCenterType;
use Chill\PersonBundle\Form\Type\GenderType;
-use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Form\Type\PersonAltNameType;
@@ -43,27 +22,19 @@ final class CreationPersonType extends AbstractType
{
// TODO: This is only used in test.
// TODO: See if this is still valid and update accordingly.
- const NAME = 'chill_personbundle_person_creation';
+ public const NAME = 'chill_personbundle_person_creation';
- private CenterRepository $centerRepository;
-
- /**
- *
- * @var ConfigPersonAltNamesHelper
- */
- protected $configPersonAltNamesHelper;
+ private ConfigPersonAltNamesHelper $configPersonAltNamesHelper;
private EventDispatcherInterface $dispatcher;
private bool $askCenters;
public function __construct(
- CenterRepository $centerRepository,
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
EventDispatcherInterface $dispatcher,
ParameterBagInterface $parameterBag
) {
- $this->centerTransformer = $centerRepository;
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
$this->dispatcher = $dispatcher;
$this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
index 49e237d87..a0e77bbaa 100644
--- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
@@ -1,22 +1,6 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ReportBundle\Timeline;
@@ -38,38 +22,39 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
*/
class TimelineReportProvider implements TimelineProviderInterface
{
-
+
protected EntityManager $em;
-
+
protected AuthorizationHelper $helper;
-
+
protected CustomFieldsHelper $customFieldsHelper;
-
- protected $showEmptyValues;
-
+
+ protected bool $showEmptyValues;
+
+ private Security $security;
+
public function __construct(
EntityManager $em,
AuthorizationHelper $helper,
Security $security,
CustomFieldsHelper $customFieldsHelper,
$showEmptyValues
- )
- {
+ ) {
$this->em = $em;
$this->helper = $helper;
$this->security = $security;
$this->customFieldsHelper = $customFieldsHelper;
$this->showEmptyValues = $showEmptyValues;
}
-
+
/**
- *
+ *
* {@inheritDoc}
*/
public function fetchQuery($context, array $args)
{
$this->checkContext($context);
-
+
$report = $this->em->getClassMetadata(Report::class);
[$where, $parameters] = $this->getWhereClause($context, $args);
@@ -84,7 +69,7 @@ class TimelineReportProvider implements TimelineProviderInterface
'parameters' => $parameters
]);
}
-
+
private function getWhereClause(string $context, array $args): array
{
switch ($context) {
@@ -102,7 +87,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$report = $this->em->getClassMetadata(Report::class);
$person = $this->em->getClassMetadata(Person::class);
$role = new Role('CHILL_REPORT_SEE');
- $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(),
+ $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(),
$role);
$reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name'];
$reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name'];
@@ -123,13 +108,13 @@ class TimelineReportProvider implements TimelineProviderInterface
}
// add the center id to the parameters
- $parameters[] = $center->getId();
+ $parameters[] = $center->getId();
// loop over scopes
$scopeIds = [];
- foreach ($this->helper->getReachableScopes($this->security->getUser(),
+ foreach ($this->helper->getReachableScopes($this->security->getUser(),
$role, $center) as $scope) {
if (\in_array($scope->getId(), $scopeIds)) {
- continue;
+ continue;
}
$scopeIds[] = $scope->getId();
}
@@ -173,7 +158,7 @@ class TimelineReportProvider implements TimelineProviderInterface
// this is the final clause that we are going to fill
$clause = "{report}.{person_id} = ? AND {report}.{scopes_id} IN ({scopes_ids})";
// iterate over reachable scopes
- $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role,
+ $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role,
$args['person']->getCenter());
foreach ($scopes as $scope) {
@@ -194,16 +179,16 @@ class TimelineReportProvider implements TimelineProviderInterface
$clause,
[
'{report}' => $report->getTableName(),
- '{person_id}' => $reportPersonId,
+ '{person_id}' => $reportPersonId,
'{scopes_id}' => $reportScopeId,
- '{scopes_ids}' => \implode(', ',
+ '{scopes_ids}' => \implode(', ',
\array_fill(0, \count($parameters)-1, '?'))
]
),
$parameters
];
}
-
+
private function getFromClause(string $context): string
{
$report = $this->em->getClassMetadata(Report::class);
@@ -229,30 +214,30 @@ class TimelineReportProvider implements TimelineProviderInterface
}
/**
- *
+ *
* {@inheritDoc}
*/
public function getEntities(array $ids)
{
$reports = $this->em->getRepository('ChillReportBundle:Report')
->findBy(array('id' => $ids));
-
+
$result = array();
foreach($reports as $report) {
$result[$report->getId()] = $report;
}
-
+
return $result;
}
/**
- *
+ *
* {@inheritDoc}
*/
public function getEntityTemplate($entity, $context, array $args)
{
$this->checkContext($context);
-
+
return array(
'template' => 'ChillReportBundle:Timeline:report.html.twig',
'template_data' => array(
@@ -262,19 +247,19 @@ class TimelineReportProvider implements TimelineProviderInterface
)
);
}
-
+
protected function getFieldsToRender(Report $entity, $context, array $args = array())
{
//gather all custom fields which should appears in summary
$gatheredFields = array();
-
+
if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) {
// keep in memory title
$title = null;
$subtitle = null;
-
+
foreach ($entity->getCFGroup()->getCustomFields() as $customField) {
- if (in_array($customField->getSlug(),
+ if (in_array($customField->getSlug(),
$entity->getCFGroup()->getOptions()['summary_fields'])) {
// if we do not want to show empty values
if ($this->showEmptyValues === false) {
@@ -304,23 +289,23 @@ class TimelineReportProvider implements TimelineProviderInterface
}
}
}
-
+
return $gatheredFields;
-
+
}
/**
- *
+ *
* {@inheritDoc}
*/
public function supportsType($type)
{
return $type === 'report';
}
-
+
/**
* check if the context is supported
- *
+ *
* @param string $context
* @throws \LogicException if the context is not supported
*/
From 7f02130ff24f563c3eef05bd4de1746209ed0208 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Tue, 16 Nov 2021 20:58:28 +0100
Subject: [PATCH 173/227] fix: Return type of getAge().
Issue highlighted by c68bda5c9b894236860fe1bacca8c9467052eb07.
---
src/Bundle/ChillPersonBundle/Entity/Person.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index e17bd5ceb..fc6a7058f 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -839,16 +839,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* If the person has a deathdate, calculate the age at the deathdate.
*
- * @param string $at a valid string to create a DateTime
- * @return int|null
+ * @param string $at A valid string to create a DateTime.
*/
- public function getAge($at = 'now'): ?int
+ public function getAge(string $at = 'now'): ?int
{
if ($this->birthdate instanceof \DateTimeInterface) {
if ($this->deathdate instanceof \DateTimeInterface) {
- return date_diff($this->birthdate, $this->deathdate)->format("%y");
+ return (int) date_diff($this->birthdate, $this->deathdate)->format('%y');
}
- return date_diff($this->birthdate, date_create($at))->format("%y");
+
+ return (int) date_diff($this->birthdate, date_create($at))->format('%y');
}
return null;
From 5d74b3ab0ac37ac6f38ebf853248e86bdb38a608 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 17 Nov 2021 10:58:52 +0100
Subject: [PATCH 174/227] fix errors when clearing cache
---
.../ChillMainBundle/Command/ChillImportUsersCommand.php | 6 +++---
src/Bundle/ChillMainBundle/config/services/command.yaml | 1 +
.../ChillPersonBundle/config/services/controller.yaml | 1 -
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
index d3fb6980f..b9c0116d3 100644
--- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
+++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php
@@ -59,14 +59,14 @@ class ChillImportUsersCommand extends Command
EntityManagerInterface $em,
LoggerInterface $logger,
UserPasswordEncoderInterface $passwordEncoder,
- ValidatorInterface $validator
+ ValidatorInterface $validator,
+ UserRepository $userRepository
) {
$this->em = $em;
$this->passwordEncoder = $passwordEncoder;
$this->validator = $validator;
$this->logger = $logger;
-
- $this->userRepository = $em->getRepository(User::class);
+ $this->userRepository = $userRepository;
parent::__construct('chill:main:import-users');
}
diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml
index 5df80c2ad..a005f9944 100644
--- a/src/Bundle/ChillMainBundle/config/services/command.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/command.yaml
@@ -5,6 +5,7 @@ services:
$logger: '@Psr\Log\LoggerInterface'
$passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
+ $userRepository: '@Chill\MainBundle\Repository\UserRepository'
tags:
- { name: console.command }
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index b03ccf966..369fe63bb 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -8,7 +8,6 @@ services:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$paginatorFactory: '@chill_main.paginator_factory'
- $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingPeriodController:
From afa8d7cb728fac408397895d96c050be07995e38 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Wed, 17 Nov 2021 11:46:15 +0100
Subject: [PATCH 175/227] fix: Creation of entity in createEntity().
Issue introduced in 5432242376f17b894247b97d3ec39cf5ec1e8bf4.
---
.../CRUD/Controller/AbstractCRUDController.php | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
index 451ce8aab..ae19fb433 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
@@ -44,14 +44,9 @@ abstract class AbstractCRUDController extends AbstractController
return $e;
}
- /**
- * Create an entity.
- *
- * @return object
- */
protected function createEntity(string $action, Request $request): object
{
- return $this->getEntityClass();
+ return new ($this->getEntityClass());
}
/**
@@ -159,11 +154,10 @@ abstract class AbstractCRUDController extends AbstractController
return null;
}
-
/**
* Get the FQDN of the class.
*
- * @return string The FQDN of the class
+ * @return class-string The FQDN of the class
*/
protected function getEntityClass(): string
{
From 4f56bb24643345c0a2d7295ff9233bcae3493590 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Wed, 17 Nov 2021 11:58:15 +0100
Subject: [PATCH 176/227] fix: Creation of entity in createEntity().
Issue introduced in 5432242376f17b894247b97d3ec39cf5ec1e8bf4.
---
.../CRUD/Controller/AbstractCRUDController.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
index ae19fb433..f88982070 100644
--- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
+++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
@@ -46,7 +46,9 @@ abstract class AbstractCRUDController extends AbstractController
protected function createEntity(string $action, Request $request): object
{
- return new ($this->getEntityClass());
+ $class = $this->getEntityClass();
+
+ return new $class;
}
/**
From 1a049730728f2b7b03099ab03d039501e591bd9c Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 17 Nov 2021 12:18:34 +0100
Subject: [PATCH 177/227] visgraph: refresh after post/patch/delete request,
fix missing key in POST body parameter
---
.../Resources/public/vuejs/VisGraph/App.vue | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 60db92628..8696041f9 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -356,7 +356,7 @@ export default {
addRelationshipModal(edgeData) {
//console.log('==- addRelationshipModal', edgeData)
this.modal = {
- data: { from: edgeData.from, to: edgeData.to },
+ data: { from: edgeData.from, to: edgeData.to, reverse: false },
action: 'create',
showModal: true,
title: 'visgraph.add_relationship_link',
@@ -414,6 +414,7 @@ export default {
this.$store.commit('removeLink', this.modal.data.id)
this.modal.showModal = false
this.resetForm()
+ this.forceUpdateComponent()
},
submitRelationship() {
console.log('submitRelationship', this.modal.action)
@@ -426,6 +427,7 @@ export default {
this.$store.dispatch('addLinkFromRelationship', relationship)
this.modal.showModal = false
this.resetForm()
+ this.forceUpdateComponent()
resolve()
}))
.catch()
@@ -437,6 +439,7 @@ export default {
this.$store.commit('updateLink', relationship)
this.modal.showModal = false
this.resetForm()
+ this.forceUpdateComponent()
resolve()
}))
.catch()
From 0e98010d0ebcaa55067f0a21b99951c6326917c3 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 17 Nov 2021 16:05:30 +0100
Subject: [PATCH 178/227] #101 improve translations + hide title
---
.../Resources/public/vuejs/AccompanyingCourse/js/i18n.js | 2 +-
.../views/AccompanyingCourse/_join_household.html.twig | 2 +-
.../views/AccompanyingCourse/_warning_address.html.twig | 2 +-
.../Resources/views/AccompanyingCourse/index.html.twig | 5 ++---
.../list_recent_by_accompanying_period.html.twig | 7 -------
.../translations/messages+intl-icu.fr.yaml | 6 +++---
src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 +
7 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
index 10b656e4a..f5e38fefc 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
@@ -52,7 +52,7 @@ const appMessages = {
show_household_number: "Voir le ménage (n° {id})",
show_household: "Voir le ménage",
person_without_household_warning: "Certaines usagers n'appartiennent actuellement à aucun ménage. Renseignez leur appartenance dès que possible.",
- update_household: "Modifier l'appartenance",
+ update_household: "Renseigner l'appartenance",
participation_not_valid: "Sélectionnez ou créez au minimum 1 usager",
},
requestor: {
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig
index 7ef2de466..fda36da85 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_join_household.html.twig
@@ -6,7 +6,7 @@
- Corriger
+ {{ 'fix it'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig
index f04a8a376..2febc7967 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig
@@ -8,7 +8,7 @@
- Corriger
+ {{ 'fix it'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig
index 612c3a46b..1c9814a10 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig
@@ -83,7 +83,7 @@
-
{{ 'Last social actions'|trans }}
+ {{ 'Last social actions'|trans }}
{% include 'ChillPersonBundle:AccompanyingCourseWork:list_recent_by_accompanying_period.html.twig' with {'buttonText': false } %}
@@ -101,8 +101,7 @@
{% set accompanying_course_id = accompanyingCourse.id %}
{% endif %}
- {{ 'Last activities' |trans }}
-
+ {{ 'Last activities' |trans }}
{% include 'ChillActivityBundle:Activity:list_recent.html.twig' with { 'context': 'accompanyingCourse', 'no_action': true } %}
{% endblock %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
index 61f48aa76..979488ff3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
@@ -1,10 +1,3 @@
- {% if works|length == 0 %}
- {{ 'accompanying_course_work.Any work'|trans }}
- {# TODO link #}
-
- {% endif %}
-
{% for w in works | slice(0,5) %}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
index e815153c8..43f83059b 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
+++ b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
@@ -16,7 +16,7 @@ household:
Household: Ménage
Household number: Ménage {household_num}
Household members: Membres du ménage
- Household editor: Modifier l'appartenance
+ Household editor: Renseigner l'appartenance
Members at same time: Membres simultanés
Any simultaneous members: Aucun membre simultanément
Select people to move: Choisir les usagers
@@ -51,7 +51,7 @@ household:
is holder: Est titulaire
is not holder: N'est pas titulaire
holder: Titulaire
- Edit member household: Modifier l'appartenance au ménage
+ Edit member household: Renseigner l'appartenance au ménage
Edit his household: Modifier son appartenance au ménage
Current household members: Membres actuels
Household summary: Résumé du ménage
@@ -61,7 +61,7 @@ household:
Household relationships: Filiations dans le ménage
Current address: Adresse actuelle
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
- Edit household members: Modifier l'appartenance au ménage
+ Edit household members: Renseigner l'appartenance au ménage
and x other persons: >-
{x, plural,
one {et une autre personne}
diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
index 7f9527b91..09ca5bb81 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml
@@ -390,6 +390,7 @@ This course has a temporarily location: Localisation temporaire
Choose a person to locate by: Localiser auprès d'un usager concerné
Associate at least one member with an household, and set an address to this household: Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage.
Locate by: Localiser auprès de
+fix it: Compléter
# Household
Household: Ménage
From 2492a9281f0943b7ea14c42fa5513b251a49abb0 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 17 Nov 2021 16:06:55 +0100
Subject: [PATCH 179/227] improve household button in course participation
---
.../PersonsAssociated/ParticipationItem.vue | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
index fd3f59cef..a9138e0b3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
@@ -5,7 +5,7 @@
addId : false,
addEntity: false,
addLink: false,
- addHouseholdLink: true,
+ addHouseholdLink: false,
addAltNames: true,
addAge : true,
hLevel : 3,
@@ -20,14 +20,15 @@
v-if="hasCurrentHouseholdAddress"
v-bind:person="participation.person">
+
+
+
+
+
-
Date: Wed, 17 Nov 2021 20:23:37 +0100
Subject: [PATCH 180/227] fix: Enforce (and document) the type of property.
---
src/Bundle/ChillPersonBundle/Entity/Person.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index fc6a7058f..df2f8ac51 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -305,11 +305,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's center
- * @var Center
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
*/
- private $center;
+ private ?Center $center = null;
/**
* The person's accompanying periods (when the person was accompanied by the center)
From d7fbbbf92cfe5233130ed7d5c27aeb9364426436 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Wed, 17 Nov 2021 20:31:20 +0100
Subject: [PATCH 181/227] fix: `Autowire` and `autoconfigure` services in
`chill_main`.
---
.../ChillMainBundle/config/services.yaml | 7 ----
.../config/services/cache.yaml | 4 +++
.../config/services/command.yaml | 10 +++---
.../config/services/controller.yaml | 9 ++---
.../ChillMainBundle/config/services/crud.yaml | 4 +++
.../config/services/doctrine.yaml | 6 +++-
.../config/services/export.yaml | 15 ++++----
.../config/services/fixtures.yaml | 4 +++
.../ChillMainBundle/config/services/form.yaml | 34 ++-----------------
.../config/services/logger.yaml | 4 +++
.../ChillMainBundle/config/services/menu.yaml | 6 ++--
.../config/services/notification.yaml | 8 ++---
.../config/services/pagination.yaml | 6 ++--
.../config/services/phonenumber.yaml | 8 +++--
.../config/services/redis.yaml | 7 ++--
.../config/services/routing.yaml | 6 +++-
.../config/services/search.yaml | 10 +++---
.../config/services/security.yaml | 25 --------------
.../config/services/serializer.yaml | 4 ++-
.../config/services/templating.yaml | 16 +++------
.../config/services/timeline.yaml | 4 +++
.../config/services/validator.yaml | 6 +++-
.../config/services/widget.yaml | 4 +++
23 files changed, 92 insertions(+), 115 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index f5f10cf57..916257335 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -8,28 +8,21 @@ services:
Chill\MainBundle\Repository\:
resource: '../Repository/'
- autowire: true
- autoconfigure: true
Chill\MainBundle\Repository\UserACLAwareRepositoryInterface: '@Chill\MainBundle\Repository\UserACLAwareRepository'
Chill\MainBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer'
- autoconfigure: true
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 64 }
Chill\MainBundle\Form\Type\:
resource: '../Form/Type'
- autoconfigure: true
- autowire: true
tags:
- { name: form.type }
Chill\MainBundle\Doctrine\Event\:
resource: '../Doctrine/Event/'
- autowire: true
tags:
- { name: 'doctrine.event_subscriber' }
diff --git a/src/Bundle/ChillMainBundle/config/services/cache.yaml b/src/Bundle/ChillMainBundle/config/services/cache.yaml
index de362ea30..ce2bb3e08 100644
--- a/src/Bundle/ChillMainBundle/config/services/cache.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/cache.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.tag_aware_cache:
class: Symfony\Component\Cache\Adapter\TagAwareAdapter
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml
index a005f9944..87220bc1f 100644
--- a/src/Bundle/ChillMainBundle/config/services/command.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/command.yaml
@@ -1,11 +1,9 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Command\ChillImportUsersCommand:
- arguments:
- $em: '@Doctrine\ORM\EntityManagerInterface'
- $logger: '@Psr\Log\LoggerInterface'
- $passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $userRepository: '@Chill\MainBundle\Repository\UserRepository'
tags:
- { name: console.command }
diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml
index a74755ffd..28abc94e8 100644
--- a/src/Bundle/ChillMainBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml
@@ -1,12 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Controller\:
- autowire: true
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\PasswordController:
- autowire: true
arguments:
$chillLogger: '@monolog.logger.chill'
tags: ['controller.service_arguments']
@@ -28,10 +29,6 @@ services:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
- Chill\MainBundle\Controller\UserController:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Controller\NotificationController:
arguments:
$security: '@Symfony\Component\Security\Core\Security'
diff --git a/src/Bundle/ChillMainBundle/config/services/crud.yaml b/src/Bundle/ChillMainBundle/config/services/crud.yaml
index 5d1940a87..02533f433 100644
--- a/src/Bundle/ChillMainBundle/config/services/crud.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/crud.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader:
arguments:
$crudConfig: '%chill_main_crud_route_loader_config%'
diff --git a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
index 09b68f03b..e59088fc4 100644
--- a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
@@ -1,3 +1,7 @@
---
services:
- 'Chill\MainBundle\Doctrine\Migrations\VersionComparator': ~
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Chill\MainBundle\Doctrine\Migrations\VersionComparator: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml
index ac49199af..ce361677b 100644
--- a/src/Bundle/ChillMainBundle/config/services/export.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/export.yaml
@@ -1,9 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.export_element_validator:
class: Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraintValidator
tags:
- { name: validator.constraint_validator }
-
+
# deprecated in favor of spreadsheet_formatter
# chill.main.export.csv_formatter:
# class: Chill\MainBundle\Export\Formatter\CSVFormatter
@@ -11,7 +15,7 @@ services:
# - "@translator"
# tags:
# - { name: chill.export_formatter, alias: 'csv' }
-
+
chill.main.export.spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadSheetFormatter
arguments:
@@ -19,7 +23,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadsheet' }
-
+
chill.main.export.list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVListFormatter
arguments:
@@ -27,7 +31,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csvlist' }
-
+
chill.main.export.list_spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadsheetListFormatter
arguments:
@@ -35,7 +39,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadlist' }
-
+
chill.main.export.pivoted_list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVPivotedListFormatter
arguments:
@@ -43,4 +47,3 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csv_pivoted_list' }
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
index ccae65867..29aabb25f 100644
--- a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\DataFixtures\ORM\:
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml
index 27d018229..843e03cb0 100644
--- a/src/Bundle/ChillMainBundle/config/services/form.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/form.yaml
@@ -1,4 +1,7 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
chill.main.form.type.translatable.string:
class: Chill\MainBundle\Form\Type\TranslatableStringFormType
@@ -39,10 +42,6 @@ services:
tags:
- { name: form.type, alias: select2_chill_language }
- Chill\MainBundle\Form\Type\PickCenterType:
- autowire: true
- autoconfigure: true
-
chill.main.form.type.composed_role_scope:
class: Chill\MainBundle\Form\Type\ComposedRoleScopeType
arguments:
@@ -62,10 +61,6 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader:
- autowire: true
- autoconfigure: true
-
chill.main.form.type.export:
class: Chill\MainBundle\Form\Type\Export\ExportType
tags:
@@ -96,14 +91,8 @@ services:
arguments:
- '@Chill\MainBundle\Export\ExportManager'
- Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer:
- autowire: true
- autoconfigure: true
-
chill.main.form.advanced_search_type:
class: Chill\MainBundle\Form\AdvancedSearchType
- autowire: true
- autoconfigure: true
arguments:
- "@chill_main.search_provider"
tags:
@@ -116,10 +105,6 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\UserType:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Form\PermissionsGroupType:
tags:
- { name: form.type }
@@ -130,16 +115,3 @@ services:
- "@security.token_storage"
tags:
- { name: form.type }
-
-
- Chill\MainBundle\Form\Type\PickAddressType:
- autoconfigure: true
- autowire: true
-
- Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer:
- autoconfigure: true
- autowire: true
-
- Chill\MainBundle\Form\Type\LocationFormType:
- autowire: true
- autoconfigure: true
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/logger.yaml b/src/Bundle/ChillMainBundle/config/services/logger.yaml
index 2da5a4a4c..a8c8dce58 100644
--- a/src/Bundle/ChillMainBundle/config/services/logger.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/logger.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.logger:
# a logger to log events from the app (deletion, remove, etc.)
alias: monolog.logger.chill
diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml
index cf31dccf1..a41e90345 100644
--- a/src/Bundle/ChillMainBundle/config/services/menu.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml
@@ -1,9 +1,11 @@
services:
- Chill\MainBundle\Routing\MenuBuilder\:
- resource: '../../Routing/MenuBuilder'
+ _defaults:
autowire: true
autoconfigure: true
+ Chill\MainBundle\Routing\MenuBuilder\:
+ resource: '../../Routing/MenuBuilder'
+
Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder:
arguments:
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/notification.yaml b/src/Bundle/ChillMainBundle/config/services/notification.yaml
index c8d970c5d..93aa9b770 100644
--- a/src/Bundle/ChillMainBundle/config/services/notification.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/notification.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Notification\Mailer:
arguments:
$logger: '@Psr\Log\LoggerInterface'
@@ -8,7 +12,3 @@ services:
$router: '@Symfony\Component\Routing\RouterInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$routeParameters: '%chill_main.notifications%'
-
- Chill\MainBundle\Notification\NotificationRenderer:
- autoconfigure: true
- autowire: true
diff --git a/src/Bundle/ChillMainBundle/config/services/pagination.yaml b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
index cb0855a3d..f94bc31be 100644
--- a/src/Bundle/ChillMainBundle/config/services/pagination.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
@@ -1,9 +1,11 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.paginator_factory:
class: Chill\MainBundle\Pagination\PaginatorFactory
public: true
- autowire: true
- autoconfigure: true
arguments:
- "@request_stack"
- "@router"
diff --git a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
index f297c03e0..7c5d78e08 100644
--- a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
@@ -1,16 +1,20 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Phonenumber\PhonenumberHelper:
arguments:
$logger: '@Psr\Log\LoggerInterface'
$config: '%chill_main.phone_helper%'
$cachePool: '@cache.user_data'
-
+
Chill\MainBundle\Phonenumber\Templating:
arguments:
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: twig.extension }
-
+
Chill\MainBundle\Validation\Validator\ValidPhonenumber:
arguments:
$logger: '@Psr\Log\LoggerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/redis.yaml b/src/Bundle/ChillMainBundle/config/services/redis.yaml
index c8d5c2879..6ccbfee7f 100644
--- a/src/Bundle/ChillMainBundle/config/services/redis.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/redis.yaml
@@ -1,10 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Redis\RedisConnectionFactory:
arguments:
$parameters: "%chill_main.redis%"
tags:
- { name: kernel.event_subcriber }
-
+
Chill\MainBundle\Redis\ChillRedis:
factory: [ '@Chill\MainBundle\Redis\RedisConnectionFactory', 'create' ]
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/routing.yaml b/src/Bundle/ChillMainBundle/config/services/routing.yaml
index c935f1a4d..fa8a56696 100644
--- a/src/Bundle/ChillMainBundle/config/services/routing.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/routing.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.menu_composer:
class: Chill\MainBundle\Routing\MenuComposer
arguments:
@@ -6,7 +10,7 @@ services:
- '@Knp\Menu\FactoryInterface'
- '@Symfony\Component\Translation\TranslatorInterface'
Chill\MainBundle\Routing\MenuComposer: '@chill.main.menu_composer'
-
+
chill.main.routes_loader:
class: Chill\MainBundle\Routing\Loader\ChillRoutesLoader
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/search.yaml b/src/Bundle/ChillMainBundle/config/services/search.yaml
index 38e421eaf..c0954fffe 100644
--- a/src/Bundle/ChillMainBundle/config/services/search.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/search.yaml
@@ -1,14 +1,12 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.search_provider:
class: Chill\MainBundle\Search\SearchProvider
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
- Chill\MainBundle\Search\SearchApi:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Search\Entity\:
- autowire: true
- autoconfigure: true
resource: '../../Search/Entity'
diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml
index dc7949556..15e190a1e 100644
--- a/src/Bundle/ChillMainBundle/config/services/security.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/security.yaml
@@ -12,38 +12,13 @@ services:
arguments:
- !tagged_iterator chill_main.scope_resolver
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\DefaultCenterResolver:
- autoconfigure: true
- autowire: true
-
- Chill\MainBundle\Security\Resolver\DefaultScopeResolver:
- autoconfigure: true
- autowire: true
-
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\ResolverTwigExtension:
- autoconfigure: true
- autowire: true
-
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory:
- autowire: true
-
- # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
chill.main.security.authorization.helper:
class: Chill\MainBundle\Security\Authorization\AuthorizationHelper
- autowire: true
- autoconfigure: true
Chill\MainBundle\Security\Authorization\AuthorizationHelper: '@chill.main.security.authorization.helper'
Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface: '@chill.main.security.authorization.helper'
- Chill\MainBundle\Security\ParentRoleHelper:
- autowire: true
- autoconfigure: true
-
chill.main.role_provider:
class: Chill\MainBundle\Security\RoleProvider
Chill\MainBundle\Security\RoleProvider: '@chill.main.role_provider'
diff --git a/src/Bundle/ChillMainBundle/config/services/serializer.yaml b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
index efe98996e..4d8aa9954 100644
--- a/src/Bundle/ChillMainBundle/config/services/serializer.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
@@ -1,11 +1,13 @@
---
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
# note: the autowiring for serializers and normalizers is declared
# into ../services.yaml
Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer:
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 8 }
diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml
index 02d806db4..060b25588 100644
--- a/src/Bundle/ChillMainBundle/config/services/templating.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
# twig_intl:
# class: Twig_Extensions_Extension_Intl
# tags:
@@ -32,8 +36,6 @@ services:
- { name: twig.extension }
Chill\MainBundle\Templating\Entity\CommentRender:
- autoconfigure: true
- autowire: true
tags:
- { name: 'chill.render_entity' }
@@ -41,17 +43,7 @@ services:
tags:
- { name: twig.extension }
- Chill\MainBundle\Templating\Entity\AddressRender:
- autoconfigure: true
- autowire: true
-
- Chill\MainBundle\Templating\Entity\UserRender:
- autoconfigure: true
- autowire: true
-
Chill\MainBundle\Templating\Listing\:
resource: './../../Templating/Listing'
- autoconfigure: true
- autowire: true
Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface: '@Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory'
diff --git a/src/Bundle/ChillMainBundle/config/services/timeline.yaml b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
index fe830c7ab..7b7987f5a 100644
--- a/src/Bundle/ChillMainBundle/config/services/timeline.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.timeline_builder:
class: Chill\MainBundle\Timeline\TimelineBuilder
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/validator.yaml b/src/Bundle/ChillMainBundle/config/services/validator.yaml
index c15b2181e..b3b60b9d6 100644
--- a/src/Bundle/ChillMainBundle/config/services/validator.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/validator.yaml
@@ -1,11 +1,15 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.validator_user_circle_consistency:
class: Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistencyValidator
arguments:
- "@chill.main.security.authorization.helper"
tags:
- { name: "validator.constraint_validator" }
-
+
Chill\MainBundle\Validation\Validator\UserUniqueEmailAndUsername:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/widget.yaml b/src/Bundle/ChillMainBundle/config/services/widget.yaml
index 53f29da5b..1f4bca2e3 100644
--- a/src/Bundle/ChillMainBundle/config/services/widget.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/widget.yaml
@@ -1,2 +1,6 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Templating\UI\CountNotificationUser: ~
From d1e1f7faa40d950298d1816887932803f59c814c Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 08:34:17 +0100
Subject: [PATCH 182/227] Revert "fix: `Autowire` and `autoconfigure` services
in `chill_main`."
This reverts commit d7fbbbf92cfe5233130ed7d5c27aeb9364426436.
---
.../ChillMainBundle/config/services.yaml | 7 ++++
.../config/services/cache.yaml | 4 ---
.../config/services/command.yaml | 10 +++---
.../config/services/controller.yaml | 9 +++--
.../ChillMainBundle/config/services/crud.yaml | 4 ---
.../config/services/doctrine.yaml | 6 +---
.../config/services/export.yaml | 15 ++++----
.../config/services/fixtures.yaml | 4 ---
.../ChillMainBundle/config/services/form.yaml | 34 +++++++++++++++++--
.../config/services/logger.yaml | 4 ---
.../ChillMainBundle/config/services/menu.yaml | 6 ++--
.../config/services/notification.yaml | 8 ++---
.../config/services/pagination.yaml | 6 ++--
.../config/services/phonenumber.yaml | 8 ++---
.../config/services/redis.yaml | 7 ++--
.../config/services/routing.yaml | 6 +---
.../config/services/search.yaml | 10 +++---
.../config/services/security.yaml | 25 ++++++++++++++
.../config/services/serializer.yaml | 4 +--
.../config/services/templating.yaml | 16 ++++++---
.../config/services/timeline.yaml | 4 ---
.../config/services/validator.yaml | 6 +---
.../config/services/widget.yaml | 4 ---
23 files changed, 115 insertions(+), 92 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index 916257335..f5f10cf57 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -8,21 +8,28 @@ services:
Chill\MainBundle\Repository\:
resource: '../Repository/'
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Repository\UserACLAwareRepositoryInterface: '@Chill\MainBundle\Repository\UserACLAwareRepository'
Chill\MainBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer'
+ autoconfigure: true
+ autowire: true
tags:
- { name: 'serializer.normalizer', priority: 64 }
Chill\MainBundle\Form\Type\:
resource: '../Form/Type'
+ autoconfigure: true
+ autowire: true
tags:
- { name: form.type }
Chill\MainBundle\Doctrine\Event\:
resource: '../Doctrine/Event/'
+ autowire: true
tags:
- { name: 'doctrine.event_subscriber' }
diff --git a/src/Bundle/ChillMainBundle/config/services/cache.yaml b/src/Bundle/ChillMainBundle/config/services/cache.yaml
index ce2bb3e08..de362ea30 100644
--- a/src/Bundle/ChillMainBundle/config/services/cache.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/cache.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill_main.tag_aware_cache:
class: Symfony\Component\Cache\Adapter\TagAwareAdapter
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml
index 87220bc1f..a005f9944 100644
--- a/src/Bundle/ChillMainBundle/config/services/command.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/command.yaml
@@ -1,9 +1,11 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Command\ChillImportUsersCommand:
+ arguments:
+ $em: '@Doctrine\ORM\EntityManagerInterface'
+ $logger: '@Psr\Log\LoggerInterface'
+ $passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface'
+ $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
+ $userRepository: '@Chill\MainBundle\Repository\UserRepository'
tags:
- { name: console.command }
diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml
index 28abc94e8..a74755ffd 100644
--- a/src/Bundle/ChillMainBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml
@@ -1,13 +1,12 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
Chill\MainBundle\Controller\:
+ autowire: true
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\PasswordController:
+ autowire: true
arguments:
$chillLogger: '@monolog.logger.chill'
tags: ['controller.service_arguments']
@@ -29,6 +28,10 @@ services:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
+ Chill\MainBundle\Controller\UserController:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Controller\NotificationController:
arguments:
$security: '@Symfony\Component\Security\Core\Security'
diff --git a/src/Bundle/ChillMainBundle/config/services/crud.yaml b/src/Bundle/ChillMainBundle/config/services/crud.yaml
index 02533f433..5d1940a87 100644
--- a/src/Bundle/ChillMainBundle/config/services/crud.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/crud.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader:
arguments:
$crudConfig: '%chill_main_crud_route_loader_config%'
diff --git a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
index e59088fc4..09b68f03b 100644
--- a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
@@ -1,7 +1,3 @@
---
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
- Chill\MainBundle\Doctrine\Migrations\VersionComparator: ~
+ 'Chill\MainBundle\Doctrine\Migrations\VersionComparator': ~
diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml
index ce361677b..ac49199af 100644
--- a/src/Bundle/ChillMainBundle/config/services/export.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/export.yaml
@@ -1,13 +1,9 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill.main.export_element_validator:
class: Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraintValidator
tags:
- { name: validator.constraint_validator }
-
+
# deprecated in favor of spreadsheet_formatter
# chill.main.export.csv_formatter:
# class: Chill\MainBundle\Export\Formatter\CSVFormatter
@@ -15,7 +11,7 @@ services:
# - "@translator"
# tags:
# - { name: chill.export_formatter, alias: 'csv' }
-
+
chill.main.export.spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadSheetFormatter
arguments:
@@ -23,7 +19,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadsheet' }
-
+
chill.main.export.list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVListFormatter
arguments:
@@ -31,7 +27,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csvlist' }
-
+
chill.main.export.list_spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadsheetListFormatter
arguments:
@@ -39,7 +35,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadlist' }
-
+
chill.main.export.pivoted_list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVPivotedListFormatter
arguments:
@@ -47,3 +43,4 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csv_pivoted_list' }
+
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
index 29aabb25f..ccae65867 100644
--- a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\DataFixtures\ORM\:
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml
index 843e03cb0..27d018229 100644
--- a/src/Bundle/ChillMainBundle/config/services/form.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/form.yaml
@@ -1,7 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
chill.main.form.type.translatable.string:
class: Chill\MainBundle\Form\Type\TranslatableStringFormType
@@ -42,6 +39,10 @@ services:
tags:
- { name: form.type, alias: select2_chill_language }
+ Chill\MainBundle\Form\Type\PickCenterType:
+ autowire: true
+ autoconfigure: true
+
chill.main.form.type.composed_role_scope:
class: Chill\MainBundle\Form\Type\ComposedRoleScopeType
arguments:
@@ -61,6 +62,10 @@ services:
tags:
- { name: form.type }
+ Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader:
+ autowire: true
+ autoconfigure: true
+
chill.main.form.type.export:
class: Chill\MainBundle\Form\Type\Export\ExportType
tags:
@@ -91,8 +96,14 @@ services:
arguments:
- '@Chill\MainBundle\Export\ExportManager'
+ Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer:
+ autowire: true
+ autoconfigure: true
+
chill.main.form.advanced_search_type:
class: Chill\MainBundle\Form\AdvancedSearchType
+ autowire: true
+ autoconfigure: true
arguments:
- "@chill_main.search_provider"
tags:
@@ -105,6 +116,10 @@ services:
tags:
- { name: form.type }
+ Chill\MainBundle\Form\UserType:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Form\PermissionsGroupType:
tags:
- { name: form.type }
@@ -115,3 +130,16 @@ services:
- "@security.token_storage"
tags:
- { name: form.type }
+
+
+ Chill\MainBundle\Form\Type\PickAddressType:
+ autoconfigure: true
+ autowire: true
+
+ Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer:
+ autoconfigure: true
+ autowire: true
+
+ Chill\MainBundle\Form\Type\LocationFormType:
+ autowire: true
+ autoconfigure: true
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/logger.yaml b/src/Bundle/ChillMainBundle/config/services/logger.yaml
index a8c8dce58..2da5a4a4c 100644
--- a/src/Bundle/ChillMainBundle/config/services/logger.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/logger.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill.main.logger:
# a logger to log events from the app (deletion, remove, etc.)
alias: monolog.logger.chill
diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml
index a41e90345..cf31dccf1 100644
--- a/src/Bundle/ChillMainBundle/config/services/menu.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml
@@ -1,10 +1,8 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Routing\MenuBuilder\:
resource: '../../Routing/MenuBuilder'
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder:
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/notification.yaml b/src/Bundle/ChillMainBundle/config/services/notification.yaml
index 93aa9b770..c8d970c5d 100644
--- a/src/Bundle/ChillMainBundle/config/services/notification.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/notification.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Notification\Mailer:
arguments:
$logger: '@Psr\Log\LoggerInterface'
@@ -12,3 +8,7 @@ services:
$router: '@Symfony\Component\Routing\RouterInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$routeParameters: '%chill_main.notifications%'
+
+ Chill\MainBundle\Notification\NotificationRenderer:
+ autoconfigure: true
+ autowire: true
diff --git a/src/Bundle/ChillMainBundle/config/services/pagination.yaml b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
index f94bc31be..cb0855a3d 100644
--- a/src/Bundle/ChillMainBundle/config/services/pagination.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
@@ -1,11 +1,9 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill_main.paginator_factory:
class: Chill\MainBundle\Pagination\PaginatorFactory
public: true
+ autowire: true
+ autoconfigure: true
arguments:
- "@request_stack"
- "@router"
diff --git a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
index 7c5d78e08..f297c03e0 100644
--- a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
@@ -1,20 +1,16 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Phonenumber\PhonenumberHelper:
arguments:
$logger: '@Psr\Log\LoggerInterface'
$config: '%chill_main.phone_helper%'
$cachePool: '@cache.user_data'
-
+
Chill\MainBundle\Phonenumber\Templating:
arguments:
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: twig.extension }
-
+
Chill\MainBundle\Validation\Validator\ValidPhonenumber:
arguments:
$logger: '@Psr\Log\LoggerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/redis.yaml b/src/Bundle/ChillMainBundle/config/services/redis.yaml
index 6ccbfee7f..c8d5c2879 100644
--- a/src/Bundle/ChillMainBundle/config/services/redis.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/redis.yaml
@@ -1,13 +1,10 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Redis\RedisConnectionFactory:
arguments:
$parameters: "%chill_main.redis%"
tags:
- { name: kernel.event_subcriber }
-
+
Chill\MainBundle\Redis\ChillRedis:
factory: [ '@Chill\MainBundle\Redis\RedisConnectionFactory', 'create' ]
+
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/routing.yaml b/src/Bundle/ChillMainBundle/config/services/routing.yaml
index fa8a56696..c935f1a4d 100644
--- a/src/Bundle/ChillMainBundle/config/services/routing.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/routing.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill.main.menu_composer:
class: Chill\MainBundle\Routing\MenuComposer
arguments:
@@ -10,7 +6,7 @@ services:
- '@Knp\Menu\FactoryInterface'
- '@Symfony\Component\Translation\TranslatorInterface'
Chill\MainBundle\Routing\MenuComposer: '@chill.main.menu_composer'
-
+
chill.main.routes_loader:
class: Chill\MainBundle\Routing\Loader\ChillRoutesLoader
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/search.yaml b/src/Bundle/ChillMainBundle/config/services/search.yaml
index c0954fffe..38e421eaf 100644
--- a/src/Bundle/ChillMainBundle/config/services/search.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/search.yaml
@@ -1,12 +1,14 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill_main.search_provider:
class: Chill\MainBundle\Search\SearchProvider
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
+ Chill\MainBundle\Search\SearchApi:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Search\Entity\:
+ autowire: true
+ autoconfigure: true
resource: '../../Search/Entity'
diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml
index 15e190a1e..dc7949556 100644
--- a/src/Bundle/ChillMainBundle/config/services/security.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/security.yaml
@@ -12,13 +12,38 @@ services:
arguments:
- !tagged_iterator chill_main.scope_resolver
+ # do not autowire the directory Security/Resolver
+ Chill\MainBundle\Security\Resolver\DefaultCenterResolver:
+ autoconfigure: true
+ autowire: true
+
+ Chill\MainBundle\Security\Resolver\DefaultScopeResolver:
+ autoconfigure: true
+ autowire: true
+
+ # do not autowire the directory Security/Resolver
+ Chill\MainBundle\Security\Resolver\ResolverTwigExtension:
+ autoconfigure: true
+ autowire: true
+
+ # do not autowire the directory Security/Resolver
+ Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory:
+ autowire: true
+
+ # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
chill.main.security.authorization.helper:
class: Chill\MainBundle\Security\Authorization\AuthorizationHelper
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Security\Authorization\AuthorizationHelper: '@chill.main.security.authorization.helper'
Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface: '@chill.main.security.authorization.helper'
+ Chill\MainBundle\Security\ParentRoleHelper:
+ autowire: true
+ autoconfigure: true
+
chill.main.role_provider:
class: Chill\MainBundle\Security\RoleProvider
Chill\MainBundle\Security\RoleProvider: '@chill.main.role_provider'
diff --git a/src/Bundle/ChillMainBundle/config/services/serializer.yaml b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
index 4d8aa9954..efe98996e 100644
--- a/src/Bundle/ChillMainBundle/config/services/serializer.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
@@ -1,13 +1,11 @@
---
services:
- _defaults:
- autowire: true
- autoconfigure: true
# note: the autowiring for serializers and normalizers is declared
# into ../services.yaml
Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer:
+ autowire: true
tags:
- { name: 'serializer.normalizer', priority: 8 }
diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml
index 060b25588..02d806db4 100644
--- a/src/Bundle/ChillMainBundle/config/services/templating.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
# twig_intl:
# class: Twig_Extensions_Extension_Intl
# tags:
@@ -36,6 +32,8 @@ services:
- { name: twig.extension }
Chill\MainBundle\Templating\Entity\CommentRender:
+ autoconfigure: true
+ autowire: true
tags:
- { name: 'chill.render_entity' }
@@ -43,7 +41,17 @@ services:
tags:
- { name: twig.extension }
+ Chill\MainBundle\Templating\Entity\AddressRender:
+ autoconfigure: true
+ autowire: true
+
+ Chill\MainBundle\Templating\Entity\UserRender:
+ autoconfigure: true
+ autowire: true
+
Chill\MainBundle\Templating\Listing\:
resource: './../../Templating/Listing'
+ autoconfigure: true
+ autowire: true
Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface: '@Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory'
diff --git a/src/Bundle/ChillMainBundle/config/services/timeline.yaml b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
index 7b7987f5a..fe830c7ab 100644
--- a/src/Bundle/ChillMainBundle/config/services/timeline.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
@@ -1,8 +1,4 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill_main.timeline_builder:
class: Chill\MainBundle\Timeline\TimelineBuilder
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/validator.yaml b/src/Bundle/ChillMainBundle/config/services/validator.yaml
index b3b60b9d6..c15b2181e 100644
--- a/src/Bundle/ChillMainBundle/config/services/validator.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/validator.yaml
@@ -1,15 +1,11 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
chill_main.validator_user_circle_consistency:
class: Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistencyValidator
arguments:
- "@chill.main.security.authorization.helper"
tags:
- { name: "validator.constraint_validator" }
-
+
Chill\MainBundle\Validation\Validator\UserUniqueEmailAndUsername:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/widget.yaml b/src/Bundle/ChillMainBundle/config/services/widget.yaml
index 1f4bca2e3..53f29da5b 100644
--- a/src/Bundle/ChillMainBundle/config/services/widget.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/widget.yaml
@@ -1,6 +1,2 @@
services:
- _defaults:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Templating\UI\CountNotificationUser: ~
From 78615519f42e54eb591629a9445fbbfeda1f923e Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Thu, 18 Nov 2021 09:34:52 +0100
Subject: [PATCH 183/227] select2 field added to task form
---
CHANGELOG.md | 1 +
src/Bundle/ChillTaskBundle/Form/SingleTaskType.php | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6dc54473f..31c3e1b5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ and this project adheres to
* [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
+* [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)
## Test releases
diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
index 85fe632b7..9af1197c2 100644
--- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
+++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
@@ -52,7 +52,8 @@ class SingleTaskType extends AbstractType
'required' => false,
'center' => $center,
'role' => TaskVoter::SHOW,
- 'placeholder' => 'Not assigned'
+ 'placeholder' => 'Not assigned',
+ 'attr' => [ 'class' => ' select2 ']
])
->add('startDate', ChillDateType::class, [
'required' => false
From 9f06bc71265f0281dcf7506c008c1c447bd5da43 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 08:49:43 +0100
Subject: [PATCH 184/227] fix: `Autowire` and `autoconfigure` services in
`chill_main`.
This commit does not remove services that are not automatically PSR loaded.
---
.../ChillMainBundle/config/services.yaml | 7 ----
.../config/services/cache.yaml | 4 +++
.../config/services/command.yaml | 10 +++---
.../config/services/controller.yaml | 9 ++---
.../ChillMainBundle/config/services/crud.yaml | 4 +++
.../config/services/doctrine.yaml | 6 +++-
.../config/services/export.yaml | 15 ++++----
.../config/services/fixtures.yaml | 4 +++
.../ChillMainBundle/config/services/form.yaml | 34 ++++++-------------
.../config/services/logger.yaml | 4 +++
.../ChillMainBundle/config/services/menu.yaml | 6 ++--
.../config/services/notification.yaml | 8 +++--
.../config/services/pagination.yaml | 6 ++--
.../config/services/phonenumber.yaml | 10 +++---
.../config/services/redis.yaml | 7 ++--
.../config/services/routing.yaml | 6 +++-
.../config/services/search.yaml | 10 +++---
.../config/services/security.yaml | 28 +++------------
.../config/services/serializer.yaml | 4 ++-
.../config/services/templating.yaml | 16 ++++-----
.../config/services/timeline.yaml | 4 +++
.../config/services/validator.yaml | 6 +++-
.../config/services/widget.yaml | 4 +++
23 files changed, 108 insertions(+), 104 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index f5f10cf57..916257335 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -8,28 +8,21 @@ services:
Chill\MainBundle\Repository\:
resource: '../Repository/'
- autowire: true
- autoconfigure: true
Chill\MainBundle\Repository\UserACLAwareRepositoryInterface: '@Chill\MainBundle\Repository\UserACLAwareRepository'
Chill\MainBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer'
- autoconfigure: true
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 64 }
Chill\MainBundle\Form\Type\:
resource: '../Form/Type'
- autoconfigure: true
- autowire: true
tags:
- { name: form.type }
Chill\MainBundle\Doctrine\Event\:
resource: '../Doctrine/Event/'
- autowire: true
tags:
- { name: 'doctrine.event_subscriber' }
diff --git a/src/Bundle/ChillMainBundle/config/services/cache.yaml b/src/Bundle/ChillMainBundle/config/services/cache.yaml
index de362ea30..ce2bb3e08 100644
--- a/src/Bundle/ChillMainBundle/config/services/cache.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/cache.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.tag_aware_cache:
class: Symfony\Component\Cache\Adapter\TagAwareAdapter
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml
index a005f9944..87220bc1f 100644
--- a/src/Bundle/ChillMainBundle/config/services/command.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/command.yaml
@@ -1,11 +1,9 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Command\ChillImportUsersCommand:
- arguments:
- $em: '@Doctrine\ORM\EntityManagerInterface'
- $logger: '@Psr\Log\LoggerInterface'
- $passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $userRepository: '@Chill\MainBundle\Repository\UserRepository'
tags:
- { name: console.command }
diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml
index a74755ffd..28abc94e8 100644
--- a/src/Bundle/ChillMainBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml
@@ -1,12 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Controller\:
- autowire: true
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\PasswordController:
- autowire: true
arguments:
$chillLogger: '@monolog.logger.chill'
tags: ['controller.service_arguments']
@@ -28,10 +29,6 @@ services:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
- Chill\MainBundle\Controller\UserController:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Controller\NotificationController:
arguments:
$security: '@Symfony\Component\Security\Core\Security'
diff --git a/src/Bundle/ChillMainBundle/config/services/crud.yaml b/src/Bundle/ChillMainBundle/config/services/crud.yaml
index 5d1940a87..02533f433 100644
--- a/src/Bundle/ChillMainBundle/config/services/crud.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/crud.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader:
arguments:
$crudConfig: '%chill_main_crud_route_loader_config%'
diff --git a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
index 09b68f03b..e59088fc4 100644
--- a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
@@ -1,3 +1,7 @@
---
services:
- 'Chill\MainBundle\Doctrine\Migrations\VersionComparator': ~
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Chill\MainBundle\Doctrine\Migrations\VersionComparator: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml
index ac49199af..ce361677b 100644
--- a/src/Bundle/ChillMainBundle/config/services/export.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/export.yaml
@@ -1,9 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.export_element_validator:
class: Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraintValidator
tags:
- { name: validator.constraint_validator }
-
+
# deprecated in favor of spreadsheet_formatter
# chill.main.export.csv_formatter:
# class: Chill\MainBundle\Export\Formatter\CSVFormatter
@@ -11,7 +15,7 @@ services:
# - "@translator"
# tags:
# - { name: chill.export_formatter, alias: 'csv' }
-
+
chill.main.export.spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadSheetFormatter
arguments:
@@ -19,7 +23,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadsheet' }
-
+
chill.main.export.list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVListFormatter
arguments:
@@ -27,7 +31,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csvlist' }
-
+
chill.main.export.list_spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadsheetListFormatter
arguments:
@@ -35,7 +39,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadlist' }
-
+
chill.main.export.pivoted_list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVPivotedListFormatter
arguments:
@@ -43,4 +47,3 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csv_pivoted_list' }
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
index ccae65867..29aabb25f 100644
--- a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\DataFixtures\ORM\:
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml
index 27d018229..003fce783 100644
--- a/src/Bundle/ChillMainBundle/config/services/form.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/form.yaml
@@ -1,4 +1,7 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
chill.main.form.type.translatable.string:
class: Chill\MainBundle\Form\Type\TranslatableStringFormType
@@ -39,9 +42,7 @@ services:
tags:
- { name: form.type, alias: select2_chill_language }
- Chill\MainBundle\Form\Type\PickCenterType:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\Type\PickCenterType: ~
chill.main.form.type.composed_role_scope:
class: Chill\MainBundle\Form\Type\ComposedRoleScopeType
@@ -62,9 +63,7 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader: ~
chill.main.form.type.export:
class: Chill\MainBundle\Form\Type\Export\ExportType
@@ -96,14 +95,10 @@ services:
arguments:
- '@Chill\MainBundle\Export\ExportManager'
- Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer: ~
chill.main.form.advanced_search_type:
class: Chill\MainBundle\Form\AdvancedSearchType
- autowire: true
- autoconfigure: true
arguments:
- "@chill_main.search_provider"
tags:
@@ -116,9 +111,7 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\UserType:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\UserType: ~
Chill\MainBundle\Form\PermissionsGroupType:
tags:
@@ -131,15 +124,8 @@ services:
tags:
- { name: form.type }
+ Chill\MainBundle\Form\Type\PickAddressType: ~
- Chill\MainBundle\Form\Type\PickAddressType:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer: ~
- Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer:
- autoconfigure: true
- autowire: true
-
- Chill\MainBundle\Form\Type\LocationFormType:
- autowire: true
- autoconfigure: true
\ No newline at end of file
+ Chill\MainBundle\Form\Type\LocationFormType: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/logger.yaml b/src/Bundle/ChillMainBundle/config/services/logger.yaml
index 2da5a4a4c..a8c8dce58 100644
--- a/src/Bundle/ChillMainBundle/config/services/logger.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/logger.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.logger:
# a logger to log events from the app (deletion, remove, etc.)
alias: monolog.logger.chill
diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml
index cf31dccf1..a41e90345 100644
--- a/src/Bundle/ChillMainBundle/config/services/menu.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml
@@ -1,9 +1,11 @@
services:
- Chill\MainBundle\Routing\MenuBuilder\:
- resource: '../../Routing/MenuBuilder'
+ _defaults:
autowire: true
autoconfigure: true
+ Chill\MainBundle\Routing\MenuBuilder\:
+ resource: '../../Routing/MenuBuilder'
+
Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder:
arguments:
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/notification.yaml b/src/Bundle/ChillMainBundle/config/services/notification.yaml
index c8d970c5d..efb25c5b5 100644
--- a/src/Bundle/ChillMainBundle/config/services/notification.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/notification.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Notification\Mailer:
arguments:
$logger: '@Psr\Log\LoggerInterface'
@@ -9,6 +13,4 @@ services:
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$routeParameters: '%chill_main.notifications%'
- Chill\MainBundle\Notification\NotificationRenderer:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Notification\NotificationRenderer: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/pagination.yaml b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
index cb0855a3d..f94bc31be 100644
--- a/src/Bundle/ChillMainBundle/config/services/pagination.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
@@ -1,9 +1,11 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.paginator_factory:
class: Chill\MainBundle\Pagination\PaginatorFactory
public: true
- autowire: true
- autoconfigure: true
arguments:
- "@request_stack"
- "@router"
diff --git a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
index f297c03e0..46fa853ee 100644
--- a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
@@ -1,19 +1,21 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Phonenumber\PhonenumberHelper:
arguments:
- $logger: '@Psr\Log\LoggerInterface'
$config: '%chill_main.phone_helper%'
$cachePool: '@cache.user_data'
-
+
Chill\MainBundle\Phonenumber\Templating:
arguments:
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: twig.extension }
-
+
Chill\MainBundle\Validation\Validator\ValidPhonenumber:
arguments:
- $logger: '@Psr\Log\LoggerInterface'
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: validator.constraint_validator }
diff --git a/src/Bundle/ChillMainBundle/config/services/redis.yaml b/src/Bundle/ChillMainBundle/config/services/redis.yaml
index c8d5c2879..6ccbfee7f 100644
--- a/src/Bundle/ChillMainBundle/config/services/redis.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/redis.yaml
@@ -1,10 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Redis\RedisConnectionFactory:
arguments:
$parameters: "%chill_main.redis%"
tags:
- { name: kernel.event_subcriber }
-
+
Chill\MainBundle\Redis\ChillRedis:
factory: [ '@Chill\MainBundle\Redis\RedisConnectionFactory', 'create' ]
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/routing.yaml b/src/Bundle/ChillMainBundle/config/services/routing.yaml
index c935f1a4d..fa8a56696 100644
--- a/src/Bundle/ChillMainBundle/config/services/routing.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/routing.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.menu_composer:
class: Chill\MainBundle\Routing\MenuComposer
arguments:
@@ -6,7 +10,7 @@ services:
- '@Knp\Menu\FactoryInterface'
- '@Symfony\Component\Translation\TranslatorInterface'
Chill\MainBundle\Routing\MenuComposer: '@chill.main.menu_composer'
-
+
chill.main.routes_loader:
class: Chill\MainBundle\Routing\Loader\ChillRoutesLoader
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/search.yaml b/src/Bundle/ChillMainBundle/config/services/search.yaml
index 38e421eaf..377b0655a 100644
--- a/src/Bundle/ChillMainBundle/config/services/search.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/search.yaml
@@ -1,14 +1,14 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.search_provider:
class: Chill\MainBundle\Search\SearchProvider
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
- Chill\MainBundle\Search\SearchApi:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Search\SearchApi: ~
Chill\MainBundle\Search\Entity\:
- autowire: true
- autoconfigure: true
resource: '../../Search/Entity'
diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml
index dc7949556..8dcd15f5d 100644
--- a/src/Bundle/ChillMainBundle/config/services/security.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/security.yaml
@@ -12,37 +12,23 @@ services:
arguments:
- !tagged_iterator chill_main.scope_resolver
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\DefaultCenterResolver:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\DefaultCenterResolver: ~
- Chill\MainBundle\Security\Resolver\DefaultScopeResolver:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\DefaultScopeResolver: ~
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\ResolverTwigExtension:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\ResolverTwigExtension: ~
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory:
- autowire: true
+ Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory: ~
# do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
chill.main.security.authorization.helper:
class: Chill\MainBundle\Security\Authorization\AuthorizationHelper
- autowire: true
- autoconfigure: true
Chill\MainBundle\Security\Authorization\AuthorizationHelper: '@chill.main.security.authorization.helper'
Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface: '@chill.main.security.authorization.helper'
- Chill\MainBundle\Security\ParentRoleHelper:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Security\ParentRoleHelper: ~
chill.main.role_provider:
class: Chill\MainBundle\Security\RoleProvider
@@ -62,12 +48,10 @@ services:
Chill\MainBundle\Security\PasswordRecover\TokenManager:
arguments:
$secret: '%kernel.secret%'
- $logger: '@Psr\Log\LoggerInterface'
Chill\MainBundle\Security\PasswordRecover\RecoverPasswordHelper:
arguments:
$tokenManager: '@Chill\MainBundle\Security\PasswordRecover\TokenManager'
- $urlGenerator: '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
$mailer: '@Chill\MainBundle\Notification\Mailer'
$routeParameters: "%chill_main.notifications%"
@@ -80,11 +64,9 @@ services:
Chill\MainBundle\Security\PasswordRecover\PasswordRecoverLocker:
arguments:
$chillRedis: '@Chill\MainBundle\Redis\ChillRedis'
- $logger: '@Psr\Log\LoggerInterface'
Chill\MainBundle\Security\PasswordRecover\PasswordRecoverVoter:
arguments:
$locker: '@Chill\MainBundle\Security\PasswordRecover\PasswordRecoverLocker'
- $requestStack: '@Symfony\Component\HttpFoundation\RequestStack'
tags:
- { name: security.voter }
diff --git a/src/Bundle/ChillMainBundle/config/services/serializer.yaml b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
index efe98996e..4d8aa9954 100644
--- a/src/Bundle/ChillMainBundle/config/services/serializer.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
@@ -1,11 +1,13 @@
---
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
# note: the autowiring for serializers and normalizers is declared
# into ../services.yaml
Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer:
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 8 }
diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml
index 02d806db4..ade26b946 100644
--- a/src/Bundle/ChillMainBundle/config/services/templating.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
# twig_intl:
# class: Twig_Extensions_Extension_Intl
# tags:
@@ -32,8 +36,6 @@ services:
- { name: twig.extension }
Chill\MainBundle\Templating\Entity\CommentRender:
- autoconfigure: true
- autowire: true
tags:
- { name: 'chill.render_entity' }
@@ -41,17 +43,11 @@ services:
tags:
- { name: twig.extension }
- Chill\MainBundle\Templating\Entity\AddressRender:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Templating\Entity\AddressRender: ~
- Chill\MainBundle\Templating\Entity\UserRender:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Templating\Entity\UserRender: ~
Chill\MainBundle\Templating\Listing\:
resource: './../../Templating/Listing'
- autoconfigure: true
- autowire: true
Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface: '@Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory'
diff --git a/src/Bundle/ChillMainBundle/config/services/timeline.yaml b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
index fe830c7ab..7b7987f5a 100644
--- a/src/Bundle/ChillMainBundle/config/services/timeline.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.timeline_builder:
class: Chill\MainBundle\Timeline\TimelineBuilder
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/validator.yaml b/src/Bundle/ChillMainBundle/config/services/validator.yaml
index c15b2181e..b3b60b9d6 100644
--- a/src/Bundle/ChillMainBundle/config/services/validator.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/validator.yaml
@@ -1,11 +1,15 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.validator_user_circle_consistency:
class: Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistencyValidator
arguments:
- "@chill.main.security.authorization.helper"
tags:
- { name: "validator.constraint_validator" }
-
+
Chill\MainBundle\Validation\Validator\UserUniqueEmailAndUsername:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/widget.yaml b/src/Bundle/ChillMainBundle/config/services/widget.yaml
index 53f29da5b..1f4bca2e3 100644
--- a/src/Bundle/ChillMainBundle/config/services/widget.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/widget.yaml
@@ -1,2 +1,6 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Templating\UI\CountNotificationUser: ~
From cc9ce4167f64536bce26c21f57710d9c39df00db Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 09:10:13 +0100
Subject: [PATCH 185/227] fix: Upgrade `TranslatableStringHelper` service and
create its interface.
---
.../Templating/TranslatableStringHelper.php | 110 ++++++------------
.../TranslatableStringHelperInterface.php | 17 +++
.../ChillMainBundle/config/services.yaml | 4 +-
3 files changed, 55 insertions(+), 76 deletions(-)
create mode 100644 src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php
diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php
index 673b87dbe..cbeb9514e 100644
--- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php
+++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php
@@ -1,92 +1,56 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
namespace Chill\MainBundle\Templating;
use Symfony\Component\HttpFoundation\RequestStack;
-use Symfony\Component\Translation\Translator;
+use Symfony\Contracts\Translation\TranslatorInterface;
-/**
- *
- * This helper helps to find the string in current locale from translatable_strings
- *
- * @author Julien Fastré
- *
- */
-class TranslatableStringHelper
+final class TranslatableStringHelper implements TranslatableStringHelperInterface
{
- /**
- *
- * @var RequestStack
- */
- private $requestStack;
-
- private $fallbackLocales;
-
- public function __construct(RequestStack $requestStack, Translator $translator)
+ private RequestStack $requestStack;
+
+ private TranslatorInterface $translator;
+
+ public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
{
$this->requestStack = $requestStack;
- $this->fallbackLocales = $translator->getFallbackLocales();
+ $this->translator = $translator;
}
-
- /**
- * return the string in current locale if it exists.
- *
- * If it does not exists; return the name in the first language available.
- *
- * Return a blank string if any strings are available.
- * Return NULL if $translatableString is NULL
- *
- * @param array $translatableStrings
- * @return string
- */
- public function localize(array $translatableStrings)
- {
- if (NULL === $translatableStrings) {
- return NULL;
- }
-
- $language = $this->requestStack->getCurrentRequest()->getLocale();
-
- if (isset($translatableStrings[$language])) {
-
- return $translatableStrings[$language];
- } else {
- foreach ($this->fallbackLocales as $locale) {
- if (array_key_exists($locale, $translatableStrings)) {
-
- return $translatableStrings[$locale];
- }
- }
-
+ public function localize(array $translatableStrings): ?string
+ {
+ if ([] === $translatableStrings) {
+ return null;
}
-
+
+ $request = $this->requestStack->getCurrentRequest();
+
+ if (null === $request) {
+ return null;
+ }
+
+ $language = $request->getLocale();
+
+ if (array_key_exists($language, $translatableStrings)) {
+ return $translatableStrings[$language];
+ }
+
+ foreach ($this->translator->getFallbackLocales() as $locale) {
+ if (array_key_exists($locale, $translatableStrings)) {
+ return $translatableStrings[$locale];
+ }
+ }
+
// no fallback translation... trying the first available
$langs = array_keys($translatableStrings);
-
- if (count($langs) === 0) {
+
+ if ([] === $langs) {
return '';
}
-
- return $translatableStrings[$langs[0]];
+ return $translatableStrings[$langs[0]];
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php
new file mode 100644
index 000000000..72e9397f8
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php
@@ -0,0 +1,17 @@
+
Date: Thu, 18 Nov 2021 10:13:13 +0100
Subject: [PATCH 186/227] fix: Use `TranslatableStringHelperInterface`.
---
.../ChillBudgetBundle/Form/ChargeType.php | 62 ++++++---------
.../ChillBudgetBundle/Form/ResourceType.php | 75 +++++++------------
.../Form/SocialWork/SocialIssueType.php | 56 +++-----------
3 files changed, 62 insertions(+), 131 deletions(-)
diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php
index da219abb9..6d0b9c7b6 100644
--- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php
+++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php
@@ -1,42 +1,34 @@
configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
-
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
@@ -45,24 +37,23 @@ class ChargeType extends AbstractType
'placeholder' => 'Choose a charge type'
])
->add('amount', MoneyType::class)
- ->add('comment', TextAreaType::class, [
+ ->add('comment', TextareaType::class, [
'required' => false
- ])
- ;
-
+ ]);
+
if ($options['show_start_date']) {
$builder->add('startDate', ChillDateType::class, [
'label' => 'Start of validity period'
]);
}
-
+
if ($options['show_end_date']) {
$builder->add('endDate', ChillDateType::class, [
'required' => false,
'label' => 'End of validity period'
]);
}
-
+
if ($options['show_help']) {
$builder->add('help', ChoiceType::class, [
'choices' => [
@@ -77,48 +68,39 @@ class ChargeType extends AbstractType
]);
}
}
-
+
private function getTypes()
{
$charges = $this->configRepository
->getChargesLabels();
-
+
// rewrite labels to filter in language
foreach ($charges as $key => $labels) {
$charges[$key] = $this->translatableStringHelper->localize($labels);
}
-
+
\asort($charges);
-
+
return \array_flip($charges);
}
-
- /**
- * {@inheritdoc}
- */
+
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
- 'data_class' => 'Chill\AMLI\BudgetBundle\Entity\Charge',
+ 'data_class' => Charge::class,
'show_start_date' => true,
'show_end_date' => true,
'show_help' => true
));
-
+
$resolver
->setAllowedTypes('show_start_date', 'boolean')
->setAllowedTypes('show_end_date', 'boolean')
- ->setAllowedTypes('show_help', 'boolean')
- ;
+ ->setAllowedTypes('show_help', 'boolean');
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix()
{
return 'chill_amli_budgetbundle_charge';
}
-
-
}
diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php
index abf7191ab..2df9ee6d7 100644
--- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php
+++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php
@@ -1,7 +1,10 @@
configRepository = $configRepository;
$this->translatableStringHelper = $translatableStringHelper;
}
-
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
@@ -45,17 +38,16 @@ class ResourceType extends AbstractType
'label' => 'Resource element type'
])
->add('amount', MoneyType::class)
- ->add('comment', TextAreaType::class, [
+ ->add('comment', TextareaType::class, [
'required' => false
- ])
- ;
-
+ ]);
+
if ($options['show_start_date']) {
$builder->add('startDate', ChillDateType::class, [
'label' => 'Start of validity period'
]);
}
-
+
if ($options['show_end_date']) {
$builder->add('endDate', ChillDateType::class, [
'required' => false,
@@ -63,25 +55,7 @@ class ResourceType extends AbstractType
]);
}
}
-
- private function getTypes()
- {
- $resources = $this->configRepository
- ->getResourcesLabels();
-
- // rewrite labels to filter in language
- foreach ($resources as $key => $labels) {
- $resources[$key] = $this->translatableStringHelper->localize($labels);
- }
-
- asort($resources);
-
- return \array_flip($resources);
- }
-
- /**
- * {@inheritdoc}
- */
+
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
@@ -89,20 +63,29 @@ class ResourceType extends AbstractType
'show_start_date' => true,
'show_end_date' => true
));
-
+
$resolver
->setAllowedTypes('show_start_date', 'boolean')
- ->setAllowedTypes('show_end_date', 'boolean')
- ;
+ ->setAllowedTypes('show_end_date', 'boolean');
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix()
{
return 'chill_amli_budgetbundle_resource';
}
+ private function getTypes()
+ {
+ $resources = $this->configRepository
+ ->getResourcesLabels();
+ // rewrite labels to filter in language
+ foreach ($resources as $key => $labels) {
+ $resources[$key] = $this->translatableStringHelper->localize($labels);
+ }
+
+ asort($resources);
+
+ return \array_flip($resources);
+ }
}
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
index 1f21defd9..f41d843c2 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
@@ -1,83 +1,49 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\PersonBundle\Form\SocialWork;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
-/**
- * Class SocialIssueType
- *
- * @package Chill\PersonBundle\Form
- */
class SocialIssueType extends AbstractType
{
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
+ protected TranslatableStringHelperInterface $translatableStringHelper;
- public function __construct(TranslatableStringHelper $translatableStringHelper) {
+ public function __construct(
+ TranslatableStringHelperInterface $translatableStringHelper
+ ) {
$this->translatableStringHelper = $translatableStringHelper;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TranslatableStringFormType::class, [
'label' => 'Nom'
])
-
->add('parent', EntityType::class, [
'class' => SocialIssue::class,
'required' => false,
- 'choice_label' => function (SocialIssue $issue) {
- return $this->translatableStringHelper->localize($issue->getTitle());
- }
+ 'choice_label' => static fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle())
])
-
->add('desactivationDate', DateType::class, [
'attr' => ['class' => 'datepicker'],
'widget'=> 'single_text',
'format' => 'dd-MM-yyyy',
'required' => false,
]);
-}
+ }
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver)
{
- $resolver
- ->setDefault('class', SocialIssue::class)
- ;
+ $resolver->setDefault('class', SocialIssue::class);
}
}
From 97ab71b63d9503cffbf47053d45df895f32be83c Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 10:14:40 +0100
Subject: [PATCH 187/227] fix: Add missing repositories, fix typing
information, autoload `Repository` directory.
---
.../ActivityReasonCategoryRepository.php | 23 +++++++
.../Repository/ActivityReasonRepository.php | 23 +++++++
.../Repository/ActivityRepository.php | 60 ++++---------------
.../Repository/ActivityTypeRepository.php | 23 +++++++
.../ChillActivityBundle/config/services.yaml | 12 ++--
.../config/services/repositories.yaml | 28 ++-------
6 files changed, 94 insertions(+), 75 deletions(-)
create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php
create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php
create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php
diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php
new file mode 100644
index 000000000..3026105b0
--- /dev/null
+++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonCategoryRepository.php
@@ -0,0 +1,23 @@
+,
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Repository;
@@ -29,10 +11,10 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
- * @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null)
- * @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null)
- * @method AccompanyingPeriodParticipation[] findAll()
- * @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ * @method Activity|null find($id, $lockMode = null, $lockVersion = null)
+ * @method Activity|null findOneBy(array $criteria, array $orderBy = null)
+ * @method Activity[] findAll()
+ * @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ActivityRepository extends ServiceEntityRepository
{
@@ -42,12 +24,7 @@ class ActivityRepository extends ServiceEntityRepository
}
/**
- * @param $person
- * @param array $scopes
- * @param string[] $orderBy
- * @param int $limit
- * @param int $offset
- * @return array|Activity[]
+ * @return Activity[]
*/
public function findByPersonImplied(Person $person, array $scopes, ?array $orderBy = [ 'date' => 'DESC'], ?int $limit = 100, ?int $offset = 0): array
{
@@ -63,8 +40,7 @@ class ActivityRepository extends ServiceEntityRepository
':person MEMBER OF a.persons'
)
)
- ->setParameter('person', $person)
- ;
+ ->setParameter('person', $person);
foreach ($orderBy as $k => $dir) {
$qb->addOrderBy('a.'.$k, $dir);
@@ -72,17 +48,11 @@ class ActivityRepository extends ServiceEntityRepository
$qb->setMaxResults($limit)->setFirstResult($offset);
- return $qb->getQuery()
- ->getResult();
+ return $qb->getQuery()->getResult();
}
/**
- * @param AccompanyingPeriod $period
- * @param array $scopes
- * @param int|null $limit
- * @param int|null $offset
- * @param array|string[] $orderBy
- * @return array|Activity[]
+ * @return Activity[]
*/
public function findByAccompanyingPeriod(AccompanyingPeriod $period, array $scopes, ?bool $allowNullScope = false, ?int $limit = 100, ?int $offset = 0, array $orderBy = ['date' => 'desc']): array
{
@@ -92,8 +62,7 @@ class ActivityRepository extends ServiceEntityRepository
if (!$allowNullScope) {
$qb
->where($qb->expr()->in('a.scope', ':scopes'))
- ->setParameter('scopes', $scopes)
- ;
+ ->setParameter('scopes', $scopes);
} else {
$qb
->where(
@@ -102,16 +71,14 @@ class ActivityRepository extends ServiceEntityRepository
$qb->expr()->isNull('a.scope')
)
)
- ->setParameter('scopes', $scopes)
- ;
+ ->setParameter('scopes', $scopes);
}
$qb
->andWhere(
$qb->expr()->eq('a.accompanyingPeriod', ':period')
)
- ->setParameter('period', $period)
- ;
+ ->setParameter('period', $period);
foreach ($orderBy as $k => $dir) {
$qb->addOrderBy('a.'.$k, $dir);
@@ -119,7 +86,6 @@ class ActivityRepository extends ServiceEntityRepository
$qb->setMaxResults($limit)->setFirstResult($offset);
- return $qb->getQuery()
- ->getResult();
+ return $qb->getQuery()->getResult();
}
}
diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php
new file mode 100644
index 000000000..5e4076ce5
--- /dev/null
+++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php
@@ -0,0 +1,23 @@
+
Date: Thu, 18 Nov 2021 10:15:27 +0100
Subject: [PATCH 188/227] fix: Inject newly created repository instead of
having to deal with the container definitions.
---
.../PersonHavingActivityBetweenDateFilter.php | 183 +++++++-----------
.../Form/Type/TranslatableActivityType.php | 58 ++----
2 files changed, 89 insertions(+), 152 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
index cf444bd0a..8773c95a0 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
@@ -1,25 +1,14 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
+use Chill\ActivityBundle\Repository\ActivityReasonRepository;
use Chill\MainBundle\Export\FilterInterface;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
+use Doctrine\ORM\QueryBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\DateType;
@@ -29,78 +18,58 @@ use Doctrine\ORM\Query\Expr;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Chill\ActivityBundle\Entity\ActivityReason;
-use Doctrine\ORM\EntityRepository;
-use Doctrine\ORM\EntityManager;
use Chill\PersonBundle\Export\Declarations;
+use Symfony\Component\Form\FormInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
-/**
- *
- *
- * @author Julien Fastré
- */
-class PersonHavingActivityBetweenDateFilter implements FilterInterface,
- ExportElementValidatedInterface
+class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportElementValidatedInterface
{
-
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
-
- /**
- *
- * @var EntityRepository
- */
- protected $activityReasonRepository;
-
- /**
- *
- * @var TranslatorInterface
- */
- protected $translator;
-
+ protected TranslatableStringHelperInterface $translatableStringHelper;
+
+ protected ActivityReasonRepository $activityReasonRepository;
+
+ protected TranslatorInterface $translator;
+
public function __construct(
TranslatableStringHelper $translatableStringHelper,
- EntityRepository $activityReasonRepository,
+ ActivityReasonRepository $activityReasonRepository,
TranslatorInterface $translator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->activityReasonRepository = $activityReasonRepository;
- $this->translator = $translator;
+ $this->translator = $translator;
}
-
public function addRole()
{
return null;
}
- public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
+ public function alterQuery(QueryBuilder $qb, $data)
{
// create a query for activity
$sqb = $qb->getEntityManager()->createQueryBuilder();
- $sqb->select("person_person_having_activity.id")
- ->from("ChillActivityBundle:Activity", "activity_person_having_activity")
- ->join("activity_person_having_activity.person", "person_person_having_activity")
- ;
+ $sqb->select('person_person_having_activity.id')
+ ->from('ChillActivityBundle:Activity', 'activity_person_having_activity')
+ ->join('activity_person_having_activity.person', 'person_person_having_activity');
+
// add clause between date
- $sqb->where("activity_person_having_activity.date BETWEEN "
- . ":person_having_activity_between_date_from"
- . " AND "
- . ":person_having_activity_between_date_to");
+ $sqb->where('activity_person_having_activity.date BETWEEN '
+ . ':person_having_activity_between_date_from'
+ . ' AND '
+ . ':person_having_activity_between_date_to');
+
// add clause activity reason
- $sqb->join('activity_person_having_activity.reasons',
- 'reasons_person_having_activity');
+ $sqb->join('activity_person_having_activity.reasons', 'reasons_person_having_activity');
+
$sqb->andWhere(
- $sqb->expr()->in(
- 'reasons_person_having_activity',
- ":person_having_activity_reasons")
- );
-
+ $sqb->expr()->in(
+ 'reasons_person_having_activity', ':person_having_activity_reasons'
+ )
+ );
+
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('person.id', $sqb->getDQL());
@@ -109,11 +78,11 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface,
} else {
$where = $qb->expr()->andX($clause);
}
-
+
$qb->add('where', $where);
- $qb->setParameter('person_having_activity_between_date_from',
+ $qb->setParameter('person_having_activity_between_date_from',
$data['date_from']);
- $qb->setParameter('person_having_activity_between_date_to',
+ $qb->setParameter('person_having_activity_between_date_to',
$data['date_to']);
$qb->setParameter('person_having_activity_reasons', $data['reasons']);
}
@@ -123,51 +92,45 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface,
return Declarations::PERSON_IMPLIED_IN;
}
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
+ public function buildForm(FormBuilderInterface $builder)
{
- $builder->add('date_from', DateType::class, array(
- 'label' => "Implied in an activity after this date",
+ $builder->add('date_from', DateType::class, [
+ 'label' => 'Implied in an activity after this date',
'data' => new \DateTime(),
- 'attr' => array('class' => 'datepicker'),
+ 'attr' => ['class' => 'datepicker'],
'widget'=> 'single_text',
'format' => 'dd-MM-yyyy',
- ));
-
- $builder->add('date_to', DateType::class, array(
- 'label' => "Implied in an activity before this date",
+ ]);
+
+ $builder->add('date_to', DateType::class, [
+ 'label' => 'Implied in an activity before this date',
'data' => new \DateTime(),
- 'attr' => array('class' => 'datepicker'),
+ 'attr' => ['class' => 'datepicker'],
'widget'=> 'single_text',
'format' => 'dd-MM-yyyy',
- ));
-
- $builder->add('reasons', EntityType::class, array(
- 'class' => 'ChillActivityBundle:ActivityReason',
- 'choice_label' => function (ActivityReason $reason) {
- return $this->translatableStringHelper
- ->localize($reason->getName());
- },
- 'group_by' => function(ActivityReason $reason) {
- return $this->translatableStringHelper
- ->localize($reason->getCategory()->getName());
- },
+ ]);
+
+ $builder->add('reasons', EntityType::class, [
+ 'class' => ActivityReason::class,
+ 'choice_label' => static fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()),
+ 'group_by' => static fn(ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
'data' => $this->activityReasonRepository->findAll(),
'multiple' => true,
'expanded' => false,
- 'label' => "Activity reasons for those activities"
- ));
-
+ 'label' => 'Activity reasons for those activities'
+ ]);
+
$builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
- /* @var $filterForm \Symfony\Component\Form\FormInterface */
+ /* @var FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
-
+
if ($enabled === true) {
// if the filter is enabled, add some validation
$form = $event->getForm();
$date_from = $form->get('date_from')->getData();
$date_to = $form->get('date_to')->getData();
-
+
// check that fields are not empty
if ($date_from === null) {
$form->get('date_from')->addError(new FormError(
@@ -178,8 +141,8 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface,
$form->get('date_to')->addError(new FormError(
$this->translator->trans('This field '
. 'should not be empty')));
- }
-
+ }
+
// check that date_from is before date_to
if (
($date_from !== null && $date_to !== null)
@@ -194,30 +157,32 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface,
}
});
}
-
+
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['reasons'] === null || count($data['reasons']) === 0) {
- $context->buildViolation("At least one reason must be choosen")
+ $context->buildViolation('At least one reason must be chosen')
->addViolation();
}
}
public function describeAction($data, $format = 'string')
{
- return array(
- "Filtered by person having an activity between %date_from% and "
- . "%date_to% with reasons %reasons_name%",
- array(
- "%date_from%" => $data['date_from']->format('d-m-Y'),
+ return [
+ 'Filtered by person having an activity between %date_from% and '
+ . '%date_to% with reasons %reasons_name%',
+ [
+ '%date_from%' => $data['date_from']->format('d-m-Y'),
'%date_to%' => $data['date_to']->format('d-m-Y'),
- "%reasons_name%" => implode(", ", array_map(
- function (ActivityReason $r) {
- return '"'.$this->translatableStringHelper->
- localize($r->getName()).'"';
- },
- $data['reasons']))
- ));
+ '%reasons_name%' => implode(
+ ", ",
+ array_map(
+ static fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
+ $data['reasons']
+ )
+ )
+ ]
+ ];
}
public function getTitle()
diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php
index fa4b23212..f930d3c1a 100644
--- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php
+++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php
@@ -1,56 +1,29 @@
,
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
+use Chill\ActivityBundle\Repository\ActivityTypeRepository;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
+use Doctrine\DBAL\Types\Types;
+use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
-use Doctrine\ORM\EntityRepository;
use Chill\ActivityBundle\Entity\ActivityType;
-/**
- * Description of TranslatableActivityType
- *
- * @author Champs-Libres Coop
- */
class TranslatableActivityType extends AbstractType
{
+ protected TranslatableStringHelperInterface $translatableStringHelper;
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
-
- protected $activityTypeRepository;
+ protected ActivityTypeRepository $activityTypeRepository;
public function __construct(
- TranslatableStringHelper $helper,
- EntityRepository $activityTypeRepository
- )
- {
+ TranslatableStringHelperInterface $helper,
+ ActivityTypeRepository $activityTypeRepository
+ ) {
$this->translatableStringHelper = $helper;
$this->activityTypeRepository = $activityTypeRepository;
}
@@ -65,22 +38,21 @@ class TranslatableActivityType extends AbstractType
return EntityType::class;
}
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) {
- /* @var $qb \Doctrine\ORM\QueryBuilder */
+ public function buildForm(FormBuilderInterface $builder, array $options) {
+ /* @var QueryBuilder $qb */
$qb = $options['query_builder'];
if ($options['active_only'] === true) {
$qb->where($qb->expr()->eq('at.active', ':active'));
- $qb->setParameter('active', true, \Doctrine\DBAL\Types\Types::BOOLEAN);
+ $qb->setParameter('active', true, Types::BOOLEAN);
}
}
public function configureOptions(OptionsResolver $resolver)
{
-
$resolver->setDefaults(
array(
- 'class' => 'ChillActivityBundle:ActivityType',
+ 'class' => ActivityType::class,
'active_only' => true,
'query_builder' => $this->activityTypeRepository
->createQueryBuilder('at'),
From d9b862925f11d9c530fe4c77ccecc69daaab1c89 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 10:28:22 +0100
Subject: [PATCH 189/227] fix: Let Symfony inject dependencies automatically.
---
.../Aggregator/ActivityReasonAggregator.php | 143 +++++++-----------
.../Aggregator/ActivityTypeAggregator.php | 60 ++------
.../Aggregator/ActivityUserAggregator.php | 68 +++------
.../Export/Export/CountActivity.php | 96 ++++--------
.../Export/Export/ListActivity.php | 139 ++++++-----------
.../Export/Export/StatActivityDuration.php | 22 +--
.../Export/Filter/ActivityReasonFilter.php | 116 +++++---------
.../Export/Filter/ActivityTypeFilter.php | 114 ++++++--------
.../config/services/export.yaml | 50 ++----
9 files changed, 282 insertions(+), 526 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php
index 6614caace..3e5cab378 100644
--- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php
+++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php
@@ -1,70 +1,39 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
+use Chill\ActivityBundle\Repository\ActivityReasonCategoryRepository;
+use Chill\ActivityBundle\Repository\ActivityReasonRepository;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Export\AggregatorInterface;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr\Join;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-/**
- *
- *
- * @author Julien Fastré
- */
-class ActivityReasonAggregator implements AggregatorInterface,
- ExportElementValidatedInterface
+class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface
{
- /**
- *
- * @var EntityRepository
- */
- protected $categoryRepository;
+ protected ActivityReasonCategoryRepository $activityReasonCategoryRepository;
- /**
- *
- * @var EntityRepository
- */
- protected $reasonRepository;
+ protected ActivityReasonRepository $activityReasonRepository;
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $stringHelper;
+ protected TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
- EntityRepository $categoryRepository,
- EntityRepository $reasonRepository,
- TranslatableStringHelper $stringHelper
+ ActivityReasonCategoryRepository $activityReasonCategoryRepository,
+ ActivityReasonRepository $activityReasonRepository,
+ TranslatableStringHelper $translatableStringHelper
) {
- $this->categoryRepository = $categoryRepository;
- $this->reasonRepository = $reasonRepository;
- $this->stringHelper = $stringHelper;
+ $this->activityReasonCategoryRepository = $activityReasonCategoryRepository;
+ $this->activityReasonRepository = $activityReasonRepository;
+ $this->translatableStringHelper = $translatableStringHelper;
}
public function alterQuery(QueryBuilder $qb, $data)
@@ -77,7 +46,7 @@ class ActivityReasonAggregator implements AggregatorInterface,
$elem = 'category.id';
$alias = 'activity_categories_id';
} else {
- throw new \RuntimeException('the data provided are not recognized');
+ throw new \RuntimeException('The data provided are not recognized.');
}
$qb->addSelect($elem.' as '.$alias);
@@ -93,11 +62,12 @@ class ActivityReasonAggregator implements AggregatorInterface,
(! array_key_exists('activity', $join))
) {
$qb->add(
- 'join',
- array('activity' =>
- new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')
- ),
- true);
+ 'join',
+ [
+ 'activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')
+ ],
+ true
+ );
}
// join category if necessary
@@ -143,28 +113,33 @@ class ActivityReasonAggregator implements AggregatorInterface,
public function buildForm(FormBuilderInterface $builder)
{
- $builder->add('level', ChoiceType::class, array(
- 'choices' => array(
- 'By reason' => 'reasons',
- 'By category of reason' => 'categories'
- ),
- 'multiple' => false,
- 'expanded' => true,
- 'label' => 'Reason\'s level'
- ));
+ $builder->add(
+ 'level',
+ ChoiceType::class,
+ [
+ 'choices' => [
+ 'By reason' => 'reasons',
+ 'By category of reason' => 'categories'
+ ],
+ 'multiple' => false,
+ 'expanded' => true,
+ 'label' => "Reason's level"
+ ]
+ );
}
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['level'] === null) {
- $context->buildViolation("The reasons's level should not be empty")
+ $context
+ ->buildViolation("The reasons's level should not be empty.")
->addViolation();
}
}
- public function getTitle()
+ public function getTitle()
{
- return "Aggregate by activity reason";
+ return 'Aggregate by activity reason';
}
public function addRole()
@@ -177,41 +152,33 @@ class ActivityReasonAggregator implements AggregatorInterface,
// for performance reason, we load data from db only once
switch ($data['level']) {
case 'reasons':
- $this->reasonRepository->findBy(array('id' => $values));
+ $this->activityReasonRepository->findBy(['id' => $values]);
break;
case 'categories':
- $this->categoryRepository->findBy(array('id' => $values));
+ $this->activityReasonCategoryRepository->findBy(['id' => $values]);
break;
default:
- throw new \RuntimeException(sprintf("the level data '%s' is invalid",
- $data['level']));
+ throw new \RuntimeException(sprintf("The level data '%s' is invalid.", $data['level']));
}
return function($value) use ($data) {
if ($value === '_header') {
- return $data['level'] === 'reasons' ?
- 'Group by reasons'
- :
- 'Group by categories of reason'
- ;
+ return $data['level'] === 'reasons' ? 'Group by reasons' : 'Group by categories of reason';
}
switch ($data['level']) {
case 'reasons':
- /* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
- $r = $this->reasonRepository->find($value);
+ $r = $this->activityReasonRepository->find($value);
- return $this->stringHelper->localize($r->getCategory()->getName())
- ." > "
- . $this->stringHelper->localize($r->getName());
- ;
- break;
+ return sprintf(
+ "%s > %s",
+ $this->translatableStringHelper->localize($r->getCategory()->getName()),
+ $this->translatableStringHelper->localize($r->getName())
+ );
case 'categories':
- $c = $this->categoryRepository->find($value);
+ $c = $this->activityReasonCategoryRepository->find($value);
- return $this->stringHelper->localize($c->getName());
- break;
- // no need for a default : the default was already set above
+ return $this->translatableStringHelper->localize($c->getName());
}
};
@@ -222,12 +189,14 @@ class ActivityReasonAggregator implements AggregatorInterface,
// add select element
if ($data['level'] === 'reasons') {
return array('activity_reasons_id');
- } elseif ($data['level'] === 'categories') {
- return array ('activity_categories_id');
- } else {
- throw new \RuntimeException('the data provided are not recognised');
}
+ if ($data['level'] === 'categories') {
+ return array ('activity_categories_id');
+ }
+
+ throw new \RuntimeException('The data provided are not recognised.');
+
}
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php
index a0e6d3966..bd90e8eb6 100644
--- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php
+++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php
@@ -1,61 +1,32 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
+use Chill\ActivityBundle\Repository\ActivityTypeRepository;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Export\AggregatorInterface;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityRepository;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr\Join;
-/**
- *
- *
- * @author Julien Fastré
- */
class ActivityTypeAggregator implements AggregatorInterface
{
+ protected ActivityTypeRepository $activityTypeRepository;
- /**
- *
- * @var EntityRepository
- */
- protected $typeRepository;
+ protected TranslatableStringHelperInterface $translatableStringHelper;
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $stringHelper;
-
- const KEY = 'activity_type_aggregator';
+ public const KEY = 'activity_type_aggregator';
public function __construct(
- EntityRepository $typeRepository,
- TranslatableStringHelper $stringHelper
+ ActivityTypeRepository $activityTypeRepository,
+ TranslatableStringHelperInterface $translatableStringHelper
) {
- $this->typeRepository = $typeRepository;
- $this->stringHelper = $stringHelper;
+ $this->activityTypeRepository = $activityTypeRepository;
+ $this->translatableStringHelper = $translatableStringHelper;
}
public function alterQuery(QueryBuilder $qb, $data)
@@ -64,7 +35,7 @@ class ActivityTypeAggregator implements AggregatorInterface
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY));
// add the "group by" part
- $groupBy = $qb->addGroupBy(self::KEY);
+ $qb->addGroupBy(self::KEY);
}
/**
@@ -97,7 +68,7 @@ class ActivityTypeAggregator implements AggregatorInterface
public function getTitle()
{
- return "Aggregate by activity type";
+ return 'Aggregate by activity type';
}
public function addRole()
@@ -108,17 +79,16 @@ class ActivityTypeAggregator implements AggregatorInterface
public function getLabels($key, array $values, $data): \Closure
{
// for performance reason, we load data from db only once
- $this->typeRepository->findBy(array('id' => $values));
+ $this->activityTypeRepository->findBy(['id' => $values]);
return function($value): string {
if ($value === '_header') {
return 'Activity type';
}
- /* @var $r \Chill\ActivityBundle\Entity\ActivityType */
- $t = $this->typeRepository->find($value);
+ $t = $this->activityTypeRepository->find($value);
- return $this->stringHelper->localize($t->getName());
+ return $this->translatableStringHelper->localize($t->getName());
};
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php
index ca01e0ae5..8e4635ef2 100644
--- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php
+++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php
@@ -1,51 +1,26 @@
- *
- * 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 .
- */
+
namespace Chill\ActivityBundle\Export\Aggregator;
+use Chill\MainBundle\Repository\UserRepository;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\QueryBuilder;
use Chill\MainBundle\Export\AggregatorInterface;
use Symfony\Component\Security\Core\Role\Role;
-use Doctrine\ORM\Query\Expr\Join;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityManagerInterface;
-use Chill\MainBundle\Entity\User;
-/**
- *
- *
- * @author Julien Fastré
- */
class ActivityUserAggregator implements AggregatorInterface
{
- /**
- *
- * @var EntityManagerInterface
- */
- protected $em;
-
- const KEY = 'activity_user_id';
-
- function __construct(EntityManagerInterface $em)
- {
- $this->em = $em;
+ public const KEY = 'activity_user_id';
+
+ private UserRepository $userRepository;
+
+ public function __construct(
+ UserRepository $userRepository
+ ) {
+ $this->userRepository = $userRepository;
}
-
+
public function addRole()
{
return new Role(ActivityStatsVoter::STATS);
@@ -53,9 +28,9 @@ class ActivityUserAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
- // add select element
+ // add select element
$qb->addSelect(sprintf('IDENTITY(activity.user) AS %s', self::KEY));
-
+
// add the "group by" part
$qb->addGroupBy(self::KEY);
}
@@ -73,17 +48,14 @@ class ActivityUserAggregator implements AggregatorInterface
public function getLabels($key, $values, $data): \Closure
{
// preload users at once
- $this->em->getRepository(User::class)
- ->findBy(['id' => $values]);
-
+ $this->userRepository->findBy(['id' => $values]);
+
return function($value) {
- switch ($value) {
- case '_header':
- return 'activity user';
- default:
- return $this->em->getRepository(User::class)->find($value)
- ->getUsername();
+ if ($value === '_header') {
+ return 'activity user';
}
+
+ return $this->userRepository->find($value)->getUsername();
};
}
@@ -94,6 +66,6 @@ class ActivityUserAggregator implements AggregatorInterface
public function getTitle(): string
{
- return "Aggregate by activity user";
+ return 'Aggregate by activity user';
}
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php
index 3498d7a13..3d5d798f8 100644
--- a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php
+++ b/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php
@@ -1,64 +1,40 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
+use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Export\ExportInterface;
-use Doctrine\ORM\QueryBuilder;
+use Chill\MainBundle\Export\FormatterInterface;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Doctrine\ORM\Query;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityManagerInterface;
-/**
- *
- *
- * @author Julien Fastré
- */
class CountActivity implements ExportInterface
{
- /**
- *
- * @var EntityManagerInterface
- */
- protected $entityManager;
-
+ protected ActivityRepository $activityRepository;
+
public function __construct(
- EntityManagerInterface $em
- )
- {
- $this->entityManager = $em;
+ ActivityRepository $activityRepository
+ ) {
+ $this->activityRepository = $activityRepository;
}
-
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
+
+ public function buildForm(FormBuilderInterface $builder)
{
-
+
}
public function getDescription()
{
- return "Count activities by various parameters.";
+ return 'Count activities by various parameters.';
}
public function getTitle()
{
- return "Count activities";
+ return 'Count activities';
}
public function getType()
@@ -68,26 +44,26 @@ class CountActivity implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
{
- $qb = $this->entityManager->createQueryBuilder();
- $centers = array_map(function($el) { return $el['center']; }, $acl);
-
- $qb->select('COUNT(activity.id) as export_count_activity')
- ->from('ChillActivityBundle:Activity', 'activity')
- ->join('activity.person', 'person')
- ;
-
- $qb->where($qb->expr()->in('person.center', ':centers'))
- ->setParameter('centers', $centers)
- ;
-
+ $centers = array_map(static fn($el) => $el['center'], $acl);
+
+ $qb = $this
+ ->activityRepository
+ ->createQueryBuilder('activity')
+ ->select('COUNT(activity.id) as export_count_activity')
+ ->join('activity.person', 'person');
+
+ $qb
+ ->where($qb->expr()->in('person.center', ':centers'))
+ ->setParameter('centers', $centers);
+
return $qb;
}
-
+
public function supportsModifiers()
{
- return array('person', 'activity');
+ return ['person', 'activity'];
}
-
+
public function requiredRole()
{
return new Role(ActivityStatsVoter::STATS);
@@ -95,7 +71,7 @@ class CountActivity implements ExportInterface
public function getAllowedFormattersTypes()
{
- return array(\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR);
+ return [FormatterInterface::TYPE_TABULAR];
}
public function getLabels($key, array $values, $data)
@@ -103,19 +79,13 @@ class CountActivity implements ExportInterface
if ($key !== 'export_count_activity') {
throw new \LogicException("the key $key is not used by this export");
}
-
- return function($value) {
- return $value === '_header' ?
- 'Number of activities'
- :
- $value
- ;
- };
+
+ return static fn($value) => $value === '_header' ? 'Number of activities' : $value;
}
public function getQueryKeys($data)
{
- return array('export_count_activity');
+ return ['export_count_activity'];
}
public function getResult($qb, $data)
diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php
index 6e5d7b0b8..12338e225 100644
--- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php
+++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php
@@ -1,31 +1,14 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
+use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Export\ListInterface;
use Chill\ActivityBundle\Entity\ActivityReason;
-use Chill\MainBundle\Entity\User;
-use Chill\MainBundle\Entity\Scope;
-use Chill\ActivityBundle\Entity\ActivityType;
-use Doctrine\ORM\Query\Expr;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
+use Doctrine\DBAL\Exception\InvalidArgumentException;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Symfony\Component\Form\FormBuilderInterface;
@@ -37,33 +20,17 @@ use Chill\MainBundle\Export\FormatterInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
-/**
- * Create a list for all activities
- *
- * @author Julien Fastré
- */
class ListActivity implements ListInterface
{
+ private ActivityRepository $activityRepository;
- /**
- *
- * @var EntityManagerInterface
- */
- protected $entityManager;
+ protected EntityManagerInterface $entityManager;
- /**
- *
- * @var TranslatorInterface
- */
- protected $translator;
+ protected TranslatorInterface $translator;
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
+ protected TranslatableStringHelperInterface $translatableStringHelper;
- protected $fields = array(
+ protected array $fields = [
'id',
'date',
'durationTime',
@@ -75,32 +42,28 @@ class ListActivity implements ListInterface
'person_firstname',
'person_lastname',
'person_id'
- );
+ ];
public function __construct(
- EntityManagerInterface $em,
- TranslatorInterface $translator,
- TranslatableStringHelper $translatableStringHelper
- )
- {
+ EntityManagerInterface $em,
+ TranslatorInterface $translator,
+ TranslatableStringHelperInterface $translatableStringHelper,
+ ActivityRepository $activityRepository
+ ) {
$this->entityManager = $em;
$this->translator = $translator;
$this->translatableStringHelper = $translatableStringHelper;
+ $this->activityRepository = $activityRepository;
}
- /**
- * {@inheritDoc}
- *
- * @param FormBuilderInterface $builder
- */
public function buildForm(FormBuilderInterface $builder)
{
- $builder->add('fields', ChoiceType::class, array(
+ $builder->add('fields', ChoiceType::class, [
'multiple' => true,
'expanded' => true,
'choices' => array_combine($this->fields, $this->fields),
'label' => 'Fields to include in export',
- 'constraints' => [new Callback(array(
+ 'constraints' => [new Callback([
'callback' => function($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
@@ -108,19 +71,14 @@ class ListActivity implements ListInterface
->addViolation();
}
}
- ))]
- ));
+ ])]
+ ]);
}
- /**
- * {@inheritDoc}
- *
- * @return type
- */
public function getAllowedFormattersTypes()
{
- return array(FormatterInterface::TYPE_LIST);
+ return [FormatterInterface::TYPE_LIST];
}
public function getDescription()
@@ -133,29 +91,32 @@ class ListActivity implements ListInterface
switch ($key)
{
case 'date' :
- return function($value) {
- if ($value === '_header') return 'date';
+ return static function($value) {
+ if ($value === '_header') {
+ return 'date';
+ }
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
return $date->format('d-m-Y');
};
case 'attendee':
- return function($value) {
- if ($value === '_header') return 'attendee';
+ return static function($value) {
+ if ($value === '_header') {
+ return 'attendee';
+ }
return $value ? 1 : 0;
};
case 'list_reasons' :
- /* @var $activityReasonsRepository EntityRepository */
- $activityRepository = $this->entityManager
- ->getRepository('ChillActivityBundle:Activity');
+ $activityRepository = $this->activityRepository;
- return function($value) use ($activityRepository) {
- if ($value === '_header') return 'activity reasons';
+ return function($value) use ($activityRepository): string {
+ if ($value === '_header') {
+ return 'activity reasons';
+ }
- $activity = $activityRepository
- ->find($value);
+ $activity = $activityRepository->find($value);
return implode(", ", array_map(function(ActivityReason $r) {
@@ -168,21 +129,25 @@ class ListActivity implements ListInterface
};
case 'circle_name' :
return function($value) {
- if ($value === '_header') return 'circle';
+ if ($value === '_header') {
+ return 'circle';
+ }
- return $this->translatableStringHelper
- ->localize(json_decode($value, true));
+ return $this->translatableStringHelper->localize(json_decode($value, true));
};
case 'type_name' :
return function($value) {
- if ($value === '_header') return 'activity type';
+ if ($value === '_header') {
+ return 'activity type';
+ }
- return $this->translatableStringHelper
- ->localize(json_decode($value, true));
+ return $this->translatableStringHelper->localize(json_decode($value, true));
};
default:
- return function($value) use ($key) {
- if ($value === '_header') return $key;
+ return static function($value) use ($key) {
+ if ($value === '_header') {
+ return $key;
+ }
return $value;
};
@@ -209,14 +174,13 @@ class ListActivity implements ListInterface
return 'activity';
}
- public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
+ public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function($el) { return $el['center']; }, $acl);
// throw an error if any fields are present
if (!\array_key_exists('fields', $data)) {
- throw new \Doctrine\DBAL\Exception\InvalidArgumentException("any fields "
- . "have been checked");
+ throw new InvalidArgumentException('Any fields have been checked.');
}
$qb = $this->entityManager->createQueryBuilder();
@@ -227,7 +191,6 @@ class ListActivity implements ListInterface
->join('person.center', 'center')
->andWhere('center IN (:authorized_centers)')
->setParameter('authorized_centers', $centers);
- ;
foreach ($this->fields as $f) {
if (in_array($f, $data['fields'])) {
@@ -269,8 +232,6 @@ class ListActivity implements ListInterface
}
}
-
-
return $qb;
}
@@ -281,7 +242,7 @@ class ListActivity implements ListInterface
public function supportsModifiers()
{
- return array('activity', 'person');
+ return ['activity', 'person'];
}
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
index 0d48130b6..f22623d9f 100644
--- a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
+++ b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php
@@ -4,12 +4,13 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
+use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Export\ExportInterface;
-use Doctrine\ORM\QueryBuilder;
+use Chill\MainBundle\Export\FormatterInterface;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Doctrine\ORM\Query;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityManagerInterface;
/**
* This export allow to compute stats on activity duration.
@@ -18,7 +19,7 @@ use Doctrine\ORM\EntityManagerInterface;
*/
class StatActivityDuration implements ExportInterface
{
- protected EntityManagerInterface $entityManager;
+ private ActivityRepository $activityRepository;
public const SUM = 'sum';
@@ -30,13 +31,15 @@ class StatActivityDuration implements ExportInterface
/**
* @param string $action the stat to perform
*/
- public function __construct(EntityManagerInterface $em, string $action = 'sum')
- {
- $this->entityManager = $em;
+ public function __construct(
+ ActivityRepository $activityRepository,
+ string $action = 'sum'
+ ) {
$this->action = $action;
+ $this->activityRepository = $activityRepository;
}
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
+ public function buildForm(FormBuilderInterface $builder)
{
}
@@ -68,7 +71,7 @@ class StatActivityDuration implements ExportInterface
$acl
);
- $qb = $this->entityManager->createQueryBuilder();
+ $qb = $this->activityRepository->createQueryBuilder('activity');
$select = null;
@@ -77,7 +80,6 @@ class StatActivityDuration implements ExportInterface
}
return $qb->select($select)
- ->from('ChillActivityBundle:Activity', 'activity')
->join('activity.person', 'person')
->join('person.center', 'center')
->where($qb->expr()->in('center', ':centers'))
@@ -96,7 +98,7 @@ class StatActivityDuration implements ExportInterface
public function getAllowedFormattersTypes()
{
- return array(\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR);
+ return [FormatterInterface::TYPE_TABULAR];
}
public function getLabels($key, array $values, $data)
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
index 37157af60..f63178077 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
@@ -1,25 +1,12 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
+use Chill\ActivityBundle\Repository\ActivityReasonRepository;
use Chill\MainBundle\Export\FilterInterface;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -28,41 +15,24 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
-/**
- *
- *
- * @author Julien Fastré
- */
-class ActivityReasonFilter implements FilterInterface,
- ExportElementValidatedInterface
+class ActivityReasonFilter implements FilterInterface, ExportElementValidatedInterface
{
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
-
- /**
- * The repository for activity reasons
- *
- * @var EntityRepository
- */
- protected $reasonRepository;
-
+ protected TranslatableStringHelperInterface $translatableStringHelper;
+
+ protected ActivityReasonRepository $activityReasonRepository;
+
public function __construct(
- TranslatableStringHelper $helper,
- EntityRepository $reasonRepository
+ TranslatableStringHelper $helper,
+ ActivityReasonRepository $activityReasonRepository
) {
$this->translatableStringHelper = $helper;
- $this->reasonRepository = $reasonRepository;
+ $this->activityReasonRepository = $activityReasonRepository;
}
-
-
+
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
@@ -75,12 +45,12 @@ class ActivityReasonFilter implements FilterInterface,
&&
!$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
- OR
+ ||
(! array_key_exists('activity', $join))
) {
$qb->add(
- 'join',
- array('activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')),
+ 'join',
+ array('activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')),
true
);
}
@@ -90,25 +60,25 @@ class ActivityReasonFilter implements FilterInterface,
} else {
$where = $qb->expr()->andX($clause);
}
-
+
$qb->add('where', $where);
$qb->setParameter('selected_activity_reasons', $data['reasons']);
}
-
+
/**
* Check if a join between Activity and Reason is already defined
- *
+ *
* @param Join[] $joins
* @return boolean
*/
- private function checkJoinAlreadyDefined(array $joins, $alias)
+ private function checkJoinAlreadyDefined(array $joins, $alias): bool
{
foreach ($joins as $join) {
if ($join->getAlias() === $alias) {
return true;
}
}
-
+
return false;
}
@@ -119,51 +89,47 @@ class ActivityReasonFilter implements FilterInterface,
public function buildForm(FormBuilderInterface $builder)
{
- //create a local copy of translatableStringHelper
- $helper = $this->translatableStringHelper;
-
- $builder->add('reasons', EntityType::class, array(
- 'class' => 'ChillActivityBundle:ActivityReason',
- 'choice_label' => function (ActivityReason $reason) use ($helper) {
- return $helper->localize($reason->getName());
- },
- 'group_by' => function(ActivityReason $reason) use ($helper) {
- return $helper->localize($reason->getCategory()->getName());
- },
+ $builder->add('reasons', EntityType::class, [
+ 'class' => ActivityReason::class,
+ 'choice_label' => static fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getName()),
+ 'group_by' => static fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
'multiple' => true,
'expanded' => false
- ));
+ ]);
}
-
+
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['reasons'] === null || count($data['reasons']) === 0) {
- $context->buildViolation("At least one reason must be choosen")
+ $context
+ ->buildViolation('At least one reason must be chosen')
->addViolation();
}
}
- public function getTitle()
+ public function getTitle()
{
return 'Filter by reason';
}
-
+
public function addRole()
{
return new Role(ActivityStatsVoter::STATS);
}
-
+
public function describeAction($data, $format = 'string')
{
// collect all the reasons'name used in this filter in one array
$reasonsNames = array_map(
- function(ActivityReason $r) {
- return "\"".$this->translatableStringHelper->localize($r->getName())."\"";
- },
- $this->reasonRepository->findBy(array('id' => $data['reasons']->toArray()))
- );
-
- return array("Filtered by reasons: only %list%",
- ["%list%" => implode(", ", $reasonsNames)]);
+ static fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
+ $this->activityReasonRepository->findBy(array('id' => $data['reasons']->toArray()))
+ );
+
+ return [
+ 'Filtered by reasons: only %list%',
+ [
+ '%list%' => implode(", ", $reasonsNames),
+ ]
+ ];
}
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
index b3616da10..2d45d32c1 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
@@ -1,67 +1,37 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
+use Chill\ActivityBundle\Repository\ActivityTypeRepository;
use Chill\MainBundle\Export\FilterInterface;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
-use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Chill\ActivityBundle\Entity\ActivityType;
-/**
- *
- *
- */
-class ActivityTypeFilter implements FilterInterface,
- ExportElementValidatedInterface
+class ActivityTypeFilter implements FilterInterface, ExportElementValidatedInterface
{
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
-
- /**
- * The repository for activity reasons
- *
- * @var EntityRepository
- */
- protected $typeRepository;
-
+ protected TranslatableStringHelperInterface $translatableStringHelper;
+
+ protected ActivityTypeRepository $activityTypeRepository;
+
public function __construct(
- TranslatableStringHelper $helper,
- EntityRepository $typeRepository
+ TranslatableStringHelperInterface $translatableStringHelper,
+ ActivityTypeRepository $activityTypeRepository
) {
- $this->translatableStringHelper = $helper;
- $this->typeRepository = $typeRepository;
+ $this->translatableStringHelper = $translatableStringHelper;
+ $this->activityTypeRepository = $activityTypeRepository;
}
-
-
+
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
@@ -72,14 +42,14 @@ class ActivityTypeFilter implements FilterInterface,
} else {
$where = $qb->expr()->andX($clause);
}
-
+
$qb->add('where', $where);
$qb->setParameter('selected_activity_types', $data['types']);
}
-
+
/**
* Check if a join between Activity and Reason is already defined
- *
+ *
* @param Join[] $joins
* @return boolean
*/
@@ -90,7 +60,7 @@ class ActivityTypeFilter implements FilterInterface,
return true;
}
}
-
+
return false;
}
@@ -101,48 +71,50 @@ class ActivityTypeFilter implements FilterInterface,
public function buildForm(FormBuilderInterface $builder)
{
- //create a local copy of translatableStringHelper
- $helper = $this->translatableStringHelper;
-
- $builder->add('types', EntityType::class, array(
- 'class' => ActivityType::class,
- 'choice_label' => function (ActivityType $type) use ($helper) {
- return $helper->localize($type->getName());
- },
- 'multiple' => true,
- 'expanded' => false
- ));
+ $builder->add(
+ 'types',
+ EntityType::class,
+ [
+ 'class' => ActivityType::class,
+ 'choice_label' => static fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()),
+ 'multiple' => true,
+ 'expanded' => false
+ ]
+ );
}
-
+
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['types'] === null || count($data['types']) === 0) {
- $context->buildViolation("At least one type must be choosen")
+ $context
+ ->buildViolation('At least one type must be chosen')
->addViolation();
}
}
- public function getTitle()
+ public function getTitle()
{
return 'Filter by activity type';
}
-
+
public function addRole()
{
return new Role(ActivityStatsVoter::STATS);
}
-
+
public function describeAction($data, $format = 'string')
{
// collect all the reasons'name used in this filter in one array
$reasonsNames = array_map(
- function(ActivityType $t) {
- return "\"".$this->translatableStringHelper->localize($t->getName())."\"";
- },
- $this->typeRepository->findBy(array('id' => $data['types']->toArray()))
- );
-
- return array("Filtered by activity type: only %list%",
- ["%list%" => implode(", ", $reasonsNames)]);
+ static fn(ActivityType $t): string => '"' . $this->translatableStringHelper->localize($t->getName()) . '"',
+ $this->activityTypeRepository->findBy(['id' => $data['types']->toArray()])
+ );
+
+ return [
+ 'Filtered by activity type: only %list%',
+ [
+ '%list%' => implode(", ", $reasonsNames),
+ ]
+ ];
}
}
diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml
index 222e8b5e0..d8aa13098 100644
--- a/src/Bundle/ChillActivityBundle/config/services/export.yaml
+++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml
@@ -1,82 +1,56 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.activity.export.count_activity:
class: Chill\ActivityBundle\Export\Export\CountActivity
- arguments:
- - "@doctrine.orm.entity_manager"
tags:
- { name: chill.export, alias: 'count_activity' }
-
+
chill.activity.export.sum_activity_duration:
class: Chill\ActivityBundle\Export\Export\StatActivityDuration
- arguments:
- - "@doctrine.orm.entity_manager"
- - "sum"
tags:
- { name: chill.export, alias: 'sum_activity_duration' }
-
+
chill.activity.export.list_activity:
class: Chill\ActivityBundle\Export\Export\ListActivity
- arguments:
- - "@doctrine.orm.entity_manager"
- - "@translator"
- - "@chill.main.helper.translatable_string"
tags:
- { name: chill.export, alias: 'list_activity' }
-
+
chill.activity.export.reason_filter:
class: Chill\ActivityBundle\Export\Filter\ActivityReasonFilter
- arguments:
- - "@chill.main.helper.translatable_string"
- - "@chill_activity.repository.reason"
tags:
- { name: chill.export_filter, alias: 'activity_reason_filter' }
-
+
chill.activity.export.type_filter:
class: Chill\ActivityBundle\Export\Filter\ActivityTypeFilter
- arguments:
- - "@chill.main.helper.translatable_string"
- - "@chill_activity.repository.activity_type"
tags:
- { name: chill.export_filter, alias: 'activity_type_filter' }
-
+
chill.activity.export.date_filter:
class: Chill\ActivityBundle\Export\Filter\ActivityDateFilter
- arguments:
- - "@translator"
tags:
- { name: chill.export_filter, alias: 'activity_date_filter' }
chill.activity.export.person_having_an_activity_between_date_filter:
class: Chill\ActivityBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
- arguments:
- - "@chill.main.helper.translatable_string"
- - "@chill_activity.repository.reason"
- - "@translator"
tags:
- #0 register as a filter
name: chill.export_filter
alias: 'activity_person_having_ac_bw_date_filter'
-
+
chill.activity.export.reason_aggregator:
class: Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
- arguments:
- - "@chill_activity.repository.reason_category"
- - "@chill_activity.repository.reason"
- - "@chill.main.helper.translatable_string"
tags:
- { name: chill.export_aggregator, alias: activity_reason_aggregator }
-
+
chill.activity.export.type_aggregator:
class: Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator
- arguments:
- - "@chill_activity.repository.activity_type"
- - "@chill.main.helper.translatable_string"
tags:
- { name: chill.export_aggregator, alias: activity_type_aggregator }
-
+
chill.activity.export.user_aggregator:
class: Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
- arguments:
- $em: "@doctrine.orm.entity_manager"
tags:
- { name: chill.export_aggregator, alias: activity_user_aggregator }
From 6ccc8d4cb8027e1ff5a48abaf856e6dde97f09e7 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 11:46:30 +0100
Subject: [PATCH 190/227] fix: Let Symfony inject dependencies automatically.
---
.../Export/Filter/ActivityDateFilter.php | 104 ++++++++----------
.../PersonHavingActivityBetweenDateFilter.php | 8 +-
2 files changed, 49 insertions(+), 63 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php
index dca4cec30..2e0149a38 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php
@@ -1,25 +1,12 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
+use Doctrine\ORM\QueryBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\DateType;
@@ -28,34 +15,24 @@ use Chill\MainBundle\Form\Type\Export\FilterType;
use Doctrine\ORM\Query\Expr;
use Symfony\Component\Translation\TranslatorInterface;
-/**
- *
- *
- * @author Julien Fastré
- */
class ActivityDateFilter implements FilterInterface
{
- /**
- *
- * @var TranslatorInterface
- */
- protected $translator;
-
+ protected TranslatorInterface $translator;
+
function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
-
public function addRole()
{
return null;
}
- public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
+ public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
- $clause = $qb->expr()->between('activity.date', ':date_from',
+ $clause = $qb->expr()->between('activity.date', ':date_from',
':date_to');
if ($where instanceof Expr\Andx) {
@@ -63,7 +40,7 @@ class ActivityDateFilter implements FilterInterface
} else {
$where = $qb->expr()->andX($clause);
}
-
+
$qb->add('where', $where);
$qb->setParameter('date_from', $data['date_from']);
$qb->setParameter('date_to', $data['date_to']);
@@ -74,35 +51,43 @@ class ActivityDateFilter implements FilterInterface
return 'activity';
}
- public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
+ public function buildForm(FormBuilderInterface $builder)
{
- $builder->add('date_from', DateType::class, array(
- 'label' => "Activities after this date",
- 'data' => new \DateTime(),
- 'attr' => array('class' => 'datepicker'),
- 'widget'=> 'single_text',
- 'format' => 'dd-MM-yyyy',
- ));
-
- $builder->add('date_to', DateType::class, array(
- 'label' => "Activities before this date",
- 'data' => new \DateTime(),
- 'attr' => array('class' => 'datepicker'),
- 'widget'=> 'single_text',
- 'format' => 'dd-MM-yyyy',
- ));
-
+ $builder->add(
+ 'date_from',
+ DateType::class,
+ [
+ 'label' => 'Activities after this date',
+ 'data' => new \DateTime(),
+ 'attr' => ['class' => 'datepicker'],
+ 'widget'=> 'single_text',
+ 'format' => 'dd-MM-yyyy',
+ ]
+ );
+
+ $builder->add(
+ 'date_to',
+ DateType::class,
+ [
+ 'label' => 'Activities before this date',
+ 'data' => new \DateTime(),
+ 'attr' => ['class' => 'datepicker'],
+ 'widget'=> 'single_text',
+ 'format' => 'dd-MM-yyyy',
+ ]
+ );
+
$builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
/* @var $filterForm \Symfony\Component\Form\FormInterface */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
-
+
if ($enabled === true) {
// if the filter is enabled, add some validation
$form = $event->getForm();
$date_from = $form->get('date_from')->getData();
$date_to = $form->get('date_to')->getData();
-
+
// check that fields are not empty
if ($date_from === null) {
$form->get('date_from')->addError(new FormError(
@@ -113,8 +98,8 @@ class ActivityDateFilter implements FilterInterface
$form->get('date_to')->addError(new FormError(
$this->translator->trans('This field '
. 'should not be empty')));
- }
-
+ }
+
// check that date_from is before date_to
if (
($date_from !== null && $date_to !== null)
@@ -132,17 +117,18 @@ class ActivityDateFilter implements FilterInterface
public function describeAction($data, $format = 'string')
{
- return array(
- "Filtered by date of activity: only between %date_from% and %date_to%",
- array(
- "%date_from%" => $data['date_from']->format('d-m-Y'),
- '%date_to%' => $data['date_to']->format('d-m-Y')
- ));
+ return [
+ 'Filtered by date of activity: only between %date_from% and %date_to%',
+ [
+ '%date_from%' => $data['date_from']->format('d-m-Y'),
+ '%date_to%' => $data['date_to']->format('d-m-Y')
+ ]
+ ];
}
public function getTitle()
{
- return "Filtered by date activity";
+ return 'Filtered by date activity';
}
}
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
index 8773c95a0..e197e1220 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
@@ -33,9 +33,9 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportEl
protected TranslatorInterface $translator;
public function __construct(
- TranslatableStringHelper $translatableStringHelper,
- ActivityReasonRepository $activityReasonRepository,
- TranslatorInterface $translator
+ TranslatableStringHelper $translatableStringHelper,
+ ActivityReasonRepository $activityReasonRepository,
+ TranslatorInterface $translator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->activityReasonRepository = $activityReasonRepository;
@@ -187,7 +187,7 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportEl
public function getTitle()
{
- return "Filtered by person having an activity in a period";
+ return 'Filtered by person having an activity in a period';
}
}
From a32692c37a25347119f214ccea74725ab5dd411b Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 11:48:35 +0100
Subject: [PATCH 191/227] fix: `RoleScope` might or might not have a `Scope`.
---
src/Bundle/ChillMainBundle/Entity/RoleScope.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillMainBundle/Entity/RoleScope.php b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
index 315e8f594..824c211cd 100644
--- a/src/Bundle/ChillMainBundle/Entity/RoleScope.php
+++ b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
@@ -32,7 +32,7 @@ class RoleScope
* @ORM\JoinColumn(nullable=true, name="scope_id")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
- private Scope $scope;
+ private ?Scope $scope;
/**
* @var Collection
From f9d36cc8a9bf5955d97217bf39aa95bf6fc1688a Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 12:03:49 +0100
Subject: [PATCH 192/227] fix: Fix bug reported by the tests.
---
.../ChillActivityBundle/Timeline/TimelineActivityProvider.php | 3 +--
src/Bundle/ChillPersonBundle/Entity/Person.php | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
index fb0a5c45c..041978421 100644
--- a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
+++ b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php
@@ -79,8 +79,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
$metadataActivity = $this->em->getClassMetadata(Activity::class);
$associationMapping = $metadataActivity->getAssociationMapping('person');
$role = new Role('CHILL_ACTIVITY_SEE');
- $reachableScopes = $this->helper->getReachableScopes($this->user,
- $role, $person->getCenter());
+ $reachableScopes = $this->helper->getReachableScopes($this->user, $role->getRole(), $person->getCenter());
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
$scopes_ids = [];
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index df2f8ac51..1c2842b6a 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -63,7 +63,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private int $id;
+ private ?int $id = null;
/**
* The person's first name
From c1a4454a08ac3f1e54ab12965deed11eef688926 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 12:10:54 +0100
Subject: [PATCH 193/227] fix: Fix bug reported by the tests.
---
src/Bundle/ChillPersonBundle/Entity/Person.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 1c2842b6a..4e8e1d0e2 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -712,7 +712,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return false;
}
- public function getId(): int
+ public function getId(): ?int
{
return $this->id;
}
From 11ad94ee096c8d31461a08758b0f8c4ba8294758 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 12:17:04 +0100
Subject: [PATCH 194/227] fix: Fix bug reported by the tests.
---
.../Timeline/TimelineReportProvider.php | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
index a0e77bbaa..448232e4f 100644
--- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
@@ -87,8 +87,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$report = $this->em->getClassMetadata(Report::class);
$person = $this->em->getClassMetadata(Person::class);
$role = new Role('CHILL_REPORT_SEE');
- $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(),
- $role);
+ $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(), $role->getRole());
$reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name'];
$reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name'];
$personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name'];
@@ -111,8 +110,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$parameters[] = $center->getId();
// loop over scopes
$scopeIds = [];
- foreach ($this->helper->getReachableScopes($this->security->getUser(),
- $role, $center) as $scope) {
+ foreach ($this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $center) as $scope) {
if (\in_array($scope->getId(), $scopeIds)) {
continue;
}
@@ -158,8 +156,7 @@ class TimelineReportProvider implements TimelineProviderInterface
// this is the final clause that we are going to fill
$clause = "{report}.{person_id} = ? AND {report}.{scopes_id} IN ({scopes_ids})";
// iterate over reachable scopes
- $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role,
- $args['person']->getCenter());
+ $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $args['person']->getCenter());
foreach ($scopes as $scope) {
if (\in_array($scope->getId(), $parameters)) {
From 1e05bd31d89e4722016fc23024e774aae12047c3 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 12:18:16 +0100
Subject: [PATCH 195/227] fix: Fix bug reported by the tests.
---
.../src/Entity/AsideActivityCategory.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
index 143e430f7..6c00274ad 100644
--- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
+++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php
@@ -44,7 +44,7 @@ class AsideActivityCategory
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
* @ORM\JoinColumn(nullable=true)
*/
- private AsideActivityCategory $parent;
+ private ?AsideActivityCategory $parent = null;
/**
* @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent")
From 370a24d3f5180baff9b32f724ad40b18dd85cbd4 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 12:36:50 +0100
Subject: [PATCH 196/227] fix: Fix PHPStan issues.
---
phpstan-critical.neon | 4 ++++
.../Export/Filter/ActivityReasonFilter.php | 6 +++---
.../Export/Filter/ActivityTypeFilter.php | 4 ++--
.../Export/Filter/PersonHavingActivityBetweenDateFilter.php | 6 +++---
.../Controller/FamilyMemberController.php | 3 +--
.../ChillPersonBundle/Form/SocialWork/SocialIssueType.php | 2 +-
6 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index 2e2f778d8..9e7bf51d2 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -130,3 +130,7 @@ parameters:
count: 1
path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
+ -
+ message: "#^Undefined variable\\: \\$id$#"
+ count: 1
+ path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
index f63178077..dbdceaaab 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php
@@ -91,8 +91,8 @@ class ActivityReasonFilter implements FilterInterface, ExportElementValidatedInt
{
$builder->add('reasons', EntityType::class, [
'class' => ActivityReason::class,
- 'choice_label' => static fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getName()),
- 'group_by' => static fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
+ 'choice_label' => fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getName()),
+ 'group_by' => fn(ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
'multiple' => true,
'expanded' => false
]);
@@ -121,7 +121,7 @@ class ActivityReasonFilter implements FilterInterface, ExportElementValidatedInt
{
// collect all the reasons'name used in this filter in one array
$reasonsNames = array_map(
- static fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
+ fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
$this->activityReasonRepository->findBy(array('id' => $data['reasons']->toArray()))
);
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
index 2d45d32c1..7bf1e7210 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php
@@ -76,7 +76,7 @@ class ActivityTypeFilter implements FilterInterface, ExportElementValidatedInter
EntityType::class,
[
'class' => ActivityType::class,
- 'choice_label' => static fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()),
+ 'choice_label' => fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()),
'multiple' => true,
'expanded' => false
]
@@ -106,7 +106,7 @@ class ActivityTypeFilter implements FilterInterface, ExportElementValidatedInter
{
// collect all the reasons'name used in this filter in one array
$reasonsNames = array_map(
- static fn(ActivityType $t): string => '"' . $this->translatableStringHelper->localize($t->getName()) . '"',
+ fn(ActivityType $t): string => '"' . $this->translatableStringHelper->localize($t->getName()) . '"',
$this->activityTypeRepository->findBy(['id' => $data['types']->toArray()])
);
diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
index e197e1220..d150c68e6 100644
--- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
+++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php
@@ -112,8 +112,8 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportEl
$builder->add('reasons', EntityType::class, [
'class' => ActivityReason::class,
- 'choice_label' => static fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()),
- 'group_by' => static fn(ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
+ 'choice_label' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()),
+ 'group_by' => fn(ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()),
'data' => $this->activityReasonRepository->findAll(),
'multiple' => true,
'expanded' => false,
@@ -177,7 +177,7 @@ class PersonHavingActivityBetweenDateFilter implements FilterInterface, ExportEl
'%reasons_name%' => implode(
", ",
array_map(
- static fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
+ fn(ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
$data['reasons']
)
)
diff --git a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
index 3ee9d4dd5..a6378fa5c 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
@@ -62,8 +62,7 @@ class FamilyMemberController extends Controller
public function newAction(Person $person, Request $request)
{
$familyMember = (new FamilyMember())
- ->setPerson($person)
- ;
+ ->setPerson($person);
$this->denyAccessUnlessGranted(FamilyMemberVoter::CREATE, $familyMember);
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
index f41d843c2..430514d21 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
@@ -32,7 +32,7 @@ class SocialIssueType extends AbstractType
->add('parent', EntityType::class, [
'class' => SocialIssue::class,
'required' => false,
- 'choice_label' => static fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle())
+ 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle())
])
->add('desactivationDate', DateType::class, [
'attr' => ['class' => 'datepicker'],
From 674bf614dd250a0da187ab6bc1dba717d6a43215 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:15:51 +0100
Subject: [PATCH 197/227] fix: Add a deprecation and the new service that goes
with it as replacement.
---
.../Resolver/CenterResolverDispatcher.php | 29 ++++++++++++-----
.../Resolver/CenterResolverManager.php | 31 +++++++++++++++++++
.../CenterResolverManagerInterface.php | 15 +++++++++
3 files changed, 68 insertions(+), 7 deletions(-)
create mode 100644 src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
create mode 100644 src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
index 1e2f9c02b..1042f3931 100644
--- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
@@ -1,27 +1,42 @@
resolvers = $resolvers;
}
/**
- * @param mixed $entity
- * @param array|null $options
* @return null|Center|Center[]
*/
public function resolveCenter($entity, ?array $options = [])
{
- foreach($this->resolvers as $priority => $resolver) {
+ trigger_deprecation(
+ 'ChillMainBundle',
+ 'dev-master',
+ '
+ Use the service CenterResolverManager through the interface CenterResolverManagerInterface.
+ The new method "CenterResolverManagerInterface::resolveCenters(): array" is available and the typing
+ has been improved in order to avoid mixing types.
+ '
+ );
+
+ foreach($this->resolvers as $resolver) {
if ($resolver->supports($entity, $options)) {
return $resolver->resolveCenter($entity, $options);
}
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
new file mode 100644
index 000000000..9f09398a5
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
@@ -0,0 +1,31 @@
+resolvers = $resolvers;
+ }
+
+ public function resolveCenters($entity, ?array $options = []): array
+ {
+ foreach($this->resolvers as $resolver) {
+ if ($resolver->supports($entity, $options)) {
+ return (array) $resolver->resolveCenter($entity, $options);
+ }
+ }
+
+ return [];
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
new file mode 100644
index 000000000..deaaff182
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
@@ -0,0 +1,15 @@
+
Date: Thu, 18 Nov 2021 14:16:02 +0100
Subject: [PATCH 198/227] fix: Replace tabs with spaces.
---
phpstan-critical.neon | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index 9e7bf51d2..b92189776 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -130,7 +130,7 @@ parameters:
count: 1
path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
- -
- message: "#^Undefined variable\\: \\$id$#"
- count: 1
- path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
+ -
+ message: "#^Undefined variable\\: \\$id$#"
+ count: 1
+ path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
From 162db60f592954a26263af12c273f192b00be226 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:28:51 +0100
Subject: [PATCH 199/227] fix: Fix FamilyMemberController and Repository.
---
.../Controller/FamilyMemberController.php | 97 +++++++++----------
.../Repository/FamilyMemberRepository.php | 25 ++++-
2 files changed, 66 insertions(+), 56 deletions(-)
diff --git a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
index a6378fa5c..1e25915ac 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
@@ -1,38 +1,46 @@
em = $em;
+ $this->em = $entityManager;
$this->translator = $translator;
$this->chillMainLogger = $chillMainLogger;
+ $this->familyMemberRepository = $familyMemberRepository;
}
-
/**
* @Route(
* "{_locale}/family-members/family-members/by-person/{id}",
@@ -43,14 +51,12 @@ class FamilyMemberController extends Controller
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::SHOW, $person);
- $familyMembers = $this->em
- ->getRepository(FamilyMember::class)
- ->findByPerson($person);
+ $familyMembers = $this->familyMemberRepository->findByPerson($person);
- return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:index.html.twig', array(
+ return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:index.html.twig', [
'person' => $person,
'familyMembers' => $familyMembers
- ));
+ ]);
}
/**
@@ -61,8 +67,7 @@ class FamilyMemberController extends Controller
*/
public function newAction(Person $person, Request $request)
{
- $familyMember = (new FamilyMember())
- ->setPerson($person);
+ $familyMember = (new FamilyMember())->setPerson($person);
$this->denyAccessUnlessGranted(FamilyMemberVoter::CREATE, $familyMember);
@@ -71,10 +76,9 @@ class FamilyMemberController extends Controller
$form->handleRequest($request);
- if ($form->isSubmitted() and $form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->persist($familyMember);
- $em->flush();
+ if ($form->isSubmitted() && $form->isValid()) {
+ $this->em->persist($familyMember);
+ $this->em->flush();
$this->addFlash('success', $this->translator->trans('Family member created'));
@@ -83,10 +87,10 @@ class FamilyMemberController extends Controller
]);
}
- return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:new.html.twig', array(
+ return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:new.html.twig', [
'form' => $form->createView(),
'person' => $person
- ));
+ ]);
}
/**
@@ -104,9 +108,8 @@ class FamilyMemberController extends Controller
$form->handleRequest($request);
- if ($form->isSubmitted() and $form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->flush();
+ if ($form->isSubmitted() && $form->isValid()) {
+ $this->em->flush();
$this->addFlash('success', $this->translator->trans('Family member updated'));
@@ -115,11 +118,11 @@ class FamilyMemberController extends Controller
]);
}
- return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:edit.html.twig', array(
+ return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:edit.html.twig', [
'familyMember' => $familyMember,
'form' => $form->createView(),
'person' => $familyMember->getPerson()
- ));
+ ]);
}
/**
@@ -128,47 +131,42 @@ class FamilyMemberController extends Controller
* "{_locale}/family-members/family-members/{id}/delete",
* name="chill_family_members_family_members_delete"
* )
- *
- * @param FamilyMember $familyMember
- * @param Request $request
- * @return \Symfony\Component\BrowserKit\Response
*/
- public function deleteAction(FamilyMember $familyMember, Request $request)
+ public function deleteAction(FamilyMember $familyMember, Request $request): Response
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::DELETE, $familyMember, 'You are not '
. 'allowed to delete this family membership');
- $form = $this->createDeleteForm($id);
+ $form = $this->createDeleteForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
- $this->chillMainLogger->notice("A family member has been removed", array(
+ $this->chillMainLogger->notice("A family member has been removed", [
'by_user' => $this->getUser()->getUsername(),
'family_member_id' => $familyMember->getId(),
'name' => $familyMember->getFirstname()." ".$familyMember->getLastname(),
'link' => $familyMember->getLink()
- ));
+ ]);
- $em = $this->getDoctrine()->getManager();
- $em->remove($familyMember);
- $em->flush();
+ $this->em->remove($familyMember);
+ $this->em->flush();
$this->addFlash('success', $this->translator
->trans("The family member has been successfully removed."));
- return $this->redirectToRoute('chill_family_members_family_members_index', array(
+ return $this->redirectToRoute('chill_family_members_family_members_index', [
'id' => $familyMember->getPerson()->getId()
- ));
+ ]);
}
}
- return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:confirm_delete.html.twig', array(
+ return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:confirm_delete.html.twig', [
'familyMember' => $familyMember,
'delete_form' => $form->createView()
- ));
+ ]);
}
/**
@@ -181,23 +179,20 @@ class FamilyMemberController extends Controller
{
$this->denyAccessUnlessGranted(FamilyMemberVoter::SHOW, $familyMember);
- return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:view.html.twig', array(
+ return $this->render('ChillAMLIFamilyMembersBundle:FamilyMember:view.html.twig', [
'familyMember' => $familyMember
- ));
+ ]);
}
/**
* Creates a form to delete a help request entity by id.
- *
- * @param mixed $id The entity id
- *
- * @return \Symfony\Component\Form\Form The form
*/
- private function createDeleteForm($id)
+ private function createDeleteForm(): FormInterface
{
- return $this->createFormBuilder()
+ return $this
+ ->createFormBuilder()
->setMethod(Request::METHOD_DELETE)
- ->add('submit', SubmitType::class, array('label' => 'Delete'))
+ ->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm()
;
}
diff --git a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
index 618128c96..a6754981b 100644
--- a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
+++ b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php
@@ -1,17 +1,32 @@
findBy([ 'person' => $person ]);
+ parent::__construct($registry, FamilyMember::class);
+ }
+
+ /**
+ * @return FamilyMember[]
+ */
+ public function findByPerson(Person $person): array
+ {
+ return $this->findBy(['person' => $person]);
}
}
From ae79ebc2992ced02de46009189aaf8c634a1cced Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:29:11 +0100
Subject: [PATCH 200/227] fix: Strict type RoleScope.
---
.../ChillMainBundle/Entity/RoleScope.php | 38 +++++--------------
1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Entity/RoleScope.php b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
index 824c211cd..a92184917 100644
--- a/src/Bundle/ChillMainBundle/Entity/RoleScope.php
+++ b/src/Bundle/ChillMainBundle/Entity/RoleScope.php
@@ -1,5 +1,7 @@
new = true;
$this->permissionsGroups = new ArrayCollection();
}
- /**
- * @return int
- */
- public function getId()
+ public function getId(): ?int
{
return $this->id;
}
- /**
- * @return string
- */
- public function getRole()
+ public function getRole(): ?string
{
return $this->role;
}
- /**
- * @return Scope
- */
- public function getScope()
+ public function getScope(): ?Scope
{
return $this->scope;
}
- /**
- * @param type $role
- * @return RoleScope
- */
- public function setRole($role)
+ public function setRole(?string $role = null): self
{
$this->role = $role;
return $this;
}
- /**
- * @param Scope $scope
- * @return RoleScope
- */
- public function setScope(Scope $scope = null)
+ public function setScope(?Scope $scope = null): self
{
$this->scope = $scope;
From 7fd45d57358ce7ceca95832c4caf2b1a616e043d Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:33:06 +0100
Subject: [PATCH 201/227] fix: Remove deprecations.
---
.../Timeline/TimelineReportProvider.php | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
index 448232e4f..04f4ba346 100644
--- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
+++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php
@@ -22,7 +22,6 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
*/
class TimelineReportProvider implements TimelineProviderInterface
{
-
protected EntityManager $em;
protected AuthorizationHelper $helper;
@@ -84,10 +83,12 @@ class TimelineReportProvider implements TimelineProviderInterface
private function getWhereClauseForCenter(string $context, array $args): array
{
+ $role = 'CHILL_REPORT_SEE';
+
$report = $this->em->getClassMetadata(Report::class);
$person = $this->em->getClassMetadata(Person::class);
- $role = new Role('CHILL_REPORT_SEE');
- $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(), $role->getRole());
+
+ $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(), $role);
$reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name'];
$reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name'];
$personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name'];
@@ -110,7 +111,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$parameters[] = $center->getId();
// loop over scopes
$scopeIds = [];
- foreach ($this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $center) as $scope) {
+ foreach ($this->helper->getReachableScopes($this->security->getUser(), $role, $center) as $scope) {
if (\in_array($scope->getId(), $scopeIds)) {
continue;
}
@@ -144,9 +145,9 @@ class TimelineReportProvider implements TimelineProviderInterface
private function getWhereClauseForPerson(string $context, array $args): array
{
+ $role = 'CHILL_REPORT_SEE';
$report = $this->em->getClassMetadata(Report::class);
$person = $this->em->getClassMetadata(Person::class);
- $role = new Role('CHILL_REPORT_SEE');
$reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name'];
$reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name'];
$personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name'];
@@ -156,7 +157,7 @@ class TimelineReportProvider implements TimelineProviderInterface
// this is the final clause that we are going to fill
$clause = "{report}.{person_id} = ? AND {report}.{scopes_id} IN ({scopes_ids})";
// iterate over reachable scopes
- $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $args['person']->getCenter());
+ $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role, $args['person']->getCenter());
foreach ($scopes as $scope) {
if (\in_array($scope->getId(), $parameters)) {
From 1509fcc2e911436f41614a93448f46ae2463c8fa Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:33:14 +0100
Subject: [PATCH 202/227] fix: Fix tests.
---
.../Person/PersonHasCenterValidatorTest.php | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php
index 8cd0e6b83..a237b3571 100644
--- a/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php
+++ b/src/Bundle/ChillPersonBundle/Tests/Validator/Person/PersonHasCenterValidatorTest.php
@@ -1,14 +1,18 @@
[
'center_required' => true
]
- ])
- ;
+ ]);
- return new PersonHasCenterValidator($parameterBag);
+ $centerResolverDispatcher = $this->createMock(CenterResolverDispatcher::class);
+
+ return new PersonHasCenterValidator($parameterBag, $centerResolverDispatcher);
}
}
From 7a07b8bef70dd550f4244711ef62959c144f083f Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:45:32 +0100
Subject: [PATCH 203/227] fix: Autowire and autoconfigure the new service.
---
.../Authorization/ChillExportVoter.php | 49 +++++--------------
.../config/services/security.yaml | 9 ++--
2 files changed, 16 insertions(+), 42 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php
index 39af35706..f4dd9ba7c 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php
@@ -1,48 +1,24 @@
- *
- * 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 .
- */
+
+declare(strict_types=1);
+
namespace Chill\MainBundle\Security\Authorization;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Entity\User;
-use Symfony\Component\Security\Core\Role\Role;
-/**
- *
- *
- * @author Julien Fastré
- */
class ChillExportVoter extends Voter
{
- const EXPORT = 'chill_export';
-
- /**
- *
- * @var AuthorizationHelper
- */
- protected $authorizationHelper;
-
- public function __construct(AuthorizationHelper $authorizationHelper)
+ public const EXPORT = 'chill_export';
+
+ protected AuthorizationHelperInterface $authorizationHelper;
+
+ public function __construct(AuthorizationHelperInterface $authorizationHelper)
{
$this->authorizationHelper = $authorizationHelper;
}
-
+
protected function supports($attribute, $subject): bool
{
return $attribute === self::EXPORT;
@@ -53,10 +29,7 @@ class ChillExportVoter extends Voter
if (!$token->getUser() instanceof User) {
return false;
}
-
- $centers = $this->authorizationHelper
- ->getReachableCenters($token->getUser(), new Role($attribute));
-
- return count($centers) > 0;
+
+ return [] !== $this->authorizationHelper->getReachableCenters($token->getUser(), $attribute);
}
}
diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml
index 8dcd15f5d..163b86d8e 100644
--- a/src/Bundle/ChillMainBundle/config/services/security.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/security.yaml
@@ -3,11 +3,15 @@ services:
autowire: true
autoconfigure: true
- # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Resolver\CenterResolverDispatcher:
arguments:
- !tagged_iterator chill_main.center_resolver
+ Chill\MainBundle\Security\Resolver\CenterResolverManager:
+ arguments:
+ - !tagged_iterator chill_main.center_resolver
+ Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverManager'
+
Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher:
arguments:
- !tagged_iterator chill_main.scope_resolver
@@ -20,7 +24,6 @@ services:
Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory: ~
- # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
chill.main.security.authorization.helper:
@@ -40,8 +43,6 @@ services:
Symfony\Component\Security\Core\User\UserProviderInterface: "@chill.main.user_provider"
Chill\MainBundle\Security\Authorization\ChillExportVoter:
- arguments:
- $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
tags:
- { name: security.voter }
From 56b15f26b2777767b8fe418d722f27fe176e3858 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:47:58 +0100
Subject: [PATCH 204/227] fix: Get rid of a single PHPStan critical issue.
---
phpstan-critical.neon | 5 -----
1 file changed, 5 deletions(-)
diff --git a/phpstan-critical.neon b/phpstan-critical.neon
index b92189776..6147f2022 100644
--- a/phpstan-critical.neon
+++ b/phpstan-critical.neon
@@ -129,8 +129,3 @@ parameters:
message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
count: 1
path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
-
- -
- message: "#^Undefined variable\\: \\$id$#"
- count: 1
- path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php
From 597a12b0850aa4b1e0ff58c383053c3d419a8b32 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 14:50:16 +0100
Subject: [PATCH 205/227] fix: Get rid of obsolete import.
---
.../ChillMainBundle/Security/Resolver/CenterResolverManager.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
index 9f09398a5..2dc947c8b 100644
--- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php
@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace Chill\MainBundle\Security\Resolver;
-use Chill\MainBundle\Entity\Center;
-
final class CenterResolverManager implements CenterResolverManagerInterface
{
/**
From 17ef96392494bdb997048ccab185d3f0e4298214 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 15:14:00 +0100
Subject: [PATCH 206/227] fix: Fix wrong entity class and a few other fixes.
---
.../Controller/ActivityController.php | 99 +++++++++++--------
1 file changed, 57 insertions(+), 42 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
index 543aa1f6b..47ebebd09 100644
--- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
+++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
@@ -5,18 +5,20 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason;
-use Chill\ActivityBundle\Entity\ActivityTypeCategory;
use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
+use Chill\ActivityBundle\Repository\ActivityRepository;
+use Chill\ActivityBundle\Repository\ActivityTypeRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
-use Chill\MainBundle\Entity\Location;
-use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
+use Chill\MainBundle\Repository\LocationRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
-use Chill\ThirdPartyBundle\Entity\ThirdParty;
+use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
+use Chill\PersonBundle\Repository\PersonRepository;
+use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
+use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -30,26 +32,50 @@ use Symfony\Component\Serializer\SerializerInterface;
final class ActivityController extends AbstractController
{
- protected EventDispatcherInterface $eventDispatcher;
+ private EventDispatcherInterface $eventDispatcher;
- protected AuthorizationHelper $authorizationHelper;
+ private LoggerInterface $logger;
- protected LoggerInterface $logger;
+ private SerializerInterface $serializer;
- protected SerializerInterface $serializer;
+ private ActivityACLAwareRepositoryInterface $activityACLAwareRepository;
- protected ActivityACLAwareRepositoryInterface $activityACLAwareRepository;
+ private ActivityTypeRepository $activityTypeRepository;
+
+ private ThirdPartyRepository $thirdPartyRepository;
+
+ private PersonRepository $personRepository;
+
+ private LocationRepository $locationRepository;
+
+ private EntityManagerInterface $entityManager;
+
+ private ActivityRepository $activityRepository;
+
+ private AccompanyingPeriodRepository $accompanyingPeriodRepository;
public function __construct(
ActivityACLAwareRepositoryInterface $activityACLAwareRepository,
+ ActivityTypeRepository $activityTypeRepository,
+ PersonRepository $personRepository,
+ ThirdPartyRepository $thirdPartyRepository,
+ LocationRepository $locationRepository,
+ ActivityRepository $activityRepository,
+ AccompanyingPeriodRepository $accompanyingPeriodRepository,
+ EntityManagerInterface $entityManager,
EventDispatcherInterface $eventDispatcher,
- AuthorizationHelper $authorizationHelper,
LoggerInterface $logger,
SerializerInterface $serializer
) {
$this->activityACLAwareRepository = $activityACLAwareRepository;
+ $this->activityTypeRepository = $activityTypeRepository;
+ $this->personRepository = $personRepository;
+ $this->thirdPartyRepository = $thirdPartyRepository;
+ $this->locationRepository = $locationRepository;
+ $this->activityRepository = $activityRepository;
+ $this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
+ $this->entityManager = $entityManager;
$this->eventDispatcher = $eventDispatcher;
- $this->authorizationHelper = $authorizationHelper;
$this->logger = $logger;
$this->serializer = $serializer;
}
@@ -98,7 +124,6 @@ final class ActivityController extends AbstractController
public function selectTypeAction(Request $request): Response
{
- $em = $this->getDoctrine()->getManager();
$view = null;
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -111,12 +136,10 @@ final class ActivityController extends AbstractController
$data = [];
- $activityTypeCategories = $em->getRepository(ActivityTypeCategory::class)
- ->findBy(['active' => true], ['ordering' => 'ASC']);
+ $activityTypeCategories = $this->activityTypeRepository->findBy(['active' => true], ['ordering' => 'ASC']);
foreach ($activityTypeCategories as $activityTypeCategory) {
- $activityTypes = $em->getRepository(ActivityType::class)
- ->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
+ $activityTypes = $this->activityTypeRepository->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
$data[] = [
'activityTypeCategory' => $activityTypeCategory,
@@ -139,7 +162,6 @@ final class ActivityController extends AbstractController
public function newAction(Request $request): Response
{
$view = null;
- $em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -150,8 +172,7 @@ final class ActivityController extends AbstractController
}
$activityType_id = $request->get('activityType_id', 0);
- $activityType = $em->getRepository(ActivityType::class)
- ->find($activityType_id);
+ $activityType = $this->activityTypeRepository->find($activityType_id);
if (isset($activityType) && !$activityType->isActive()) {
throw new \InvalidArgumentException('Activity type must be active');
@@ -209,20 +230,20 @@ final class ActivityController extends AbstractController
if (array_key_exists('personsId', $activityData)) {
foreach($activityData['personsId'] as $personId){
- $concernedPerson = $em->getRepository(Person::class)->find($personId);
+ $concernedPerson = $this->personRepository->find($personId);
$entity->addPerson($concernedPerson);
}
}
if (array_key_exists('professionalsId', $activityData)) {
foreach($activityData['professionalsId'] as $professionalsId){
- $professional = $em->getRepository(ThirdParty::class)->find($professionalsId);
+ $professional = $this->thirdPartyRepository->find($professionalsId);
$entity->addThirdParty($professional);
}
}
if (array_key_exists('location', $activityData)) {
- $location = $em->getRepository(Location::class)->find($activityData['location']);
+ $location = $this->locationRepository->find($activityData['location']);
$entity->setLocation($location);
}
@@ -247,8 +268,8 @@ final class ActivityController extends AbstractController
])->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
- $em->persist($entity);
- $em->flush();
+ $this->entityManager->persist($entity);
+ $this->entityManager->flush();
$this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
@@ -277,7 +298,6 @@ final class ActivityController extends AbstractController
public function showAction(Request $request, $id): Response
{
$view = null;
- $em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -287,8 +307,7 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:showPerson.html.twig';
}
- /** @var Activity $entity */
- $entity = $em->getRepository(Activity::class)->find($id);
+ $entity = $this->activityRepository->find($id);
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
@@ -333,7 +352,6 @@ final class ActivityController extends AbstractController
public function editAction($id, Request $request): Response
{
$view = null;
- $em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -343,8 +361,7 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
- /** @var Activity $entity */
- $entity = $em->getRepository(Activity::class)->find($id);
+ $entity = $this->activityRepository->find($id);
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
@@ -361,8 +378,8 @@ final class ActivityController extends AbstractController
])->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
- $em->persist($entity);
- $em->flush();
+ $this->entityManager->persist($entity);
+ $this->entityManager->flush();
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
@@ -406,7 +423,6 @@ final class ActivityController extends AbstractController
public function deleteAction(Request $request, $id)
{
$view = null;
- $em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
@@ -416,8 +432,7 @@ final class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
- /* @var Activity $activity */
- $activity = $em->getRepository(Activity::class)->find($id);
+ $activity = $this->activityRepository->find($id);
if (!$activity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
@@ -449,8 +464,8 @@ final class ActivityController extends AbstractController
'attendee' => $activity->getAttendee()
]);
- $em->remove($activity);
- $em->flush();
+ $this->entityManager->remove($activity);
+ $this->entityManager->flush();
$this->addFlash('success', $this->get('translator')
->trans("The activity has been successfully removed."));
@@ -490,12 +505,11 @@ final class ActivityController extends AbstractController
private function getEntity(Request $request): array
{
- $em = $this->getDoctrine()->getManager();
$person = $accompanyingPeriod = null;
if ($request->query->has('person_id')) {
$person_id = $request->get('person_id');
- $person = $em->getRepository(Person::class)->find($person_id);
+ $person = $this->personRepository->find($person_id);
if ($person === null) {
throw $this->createNotFoundException('Person not found');
@@ -504,7 +518,7 @@ final class ActivityController extends AbstractController
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
} elseif ($request->query->has('accompanying_period_id')) {
$accompanying_period_id = $request->get('accompanying_period_id');
- $accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id);
+ $accompanyingPeriod = $this->accompanyingPeriodRepository->find($accompanying_period_id);
if ($accompanyingPeriod === null) {
throw $this->createNotFoundException('Accompanying Period not found');
@@ -522,7 +536,8 @@ final class ActivityController extends AbstractController
];
}
- private function buildParamsToUrl(?Person $person, ?AccompanyingPeriod $accompanyingPeriod): array {
+ private function buildParamsToUrl(?Person $person, ?AccompanyingPeriod $accompanyingPeriod): array
+ {
$params = [];
if (null !== $person) {
From d1935f96e71dafe1f722841e25918124714757dc Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Thu, 18 Nov 2021 15:23:44 +0100
Subject: [PATCH 207/227] fix: Add more typing informations.
---
.../Security/Resolver/CenterResolverDispatcher.php | 1 +
.../Security/Resolver/CenterResolverInterface.php | 8 +++++---
.../Security/Resolver/CenterResolverManagerInterface.php | 1 +
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
index 1042f3931..e6cdd8b0c 100644
--- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php
@@ -22,6 +22,7 @@ final class CenterResolverDispatcher
}
/**
+ * @param object $entity
* @return null|Center|Center[]
*/
public function resolveCenter($entity, ?array $options = [])
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverInterface.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverInterface.php
index db49874b7..f3bf44b5a 100644
--- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverInterface.php
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverInterface.php
@@ -6,12 +6,14 @@ use Chill\MainBundle\Entity\Center;
interface CenterResolverInterface
{
+ /**
+ * @param object $entity
+ */
public function supports($entity, ?array $options = []): bool;
/**
- * @param $entity
- * @param array|null $options
- * @return Center|array|Center[]
+ * @param object $entity
+ * @return Center|Center[]
*/
public function resolveCenter($entity, ?array $options = []);
diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
index deaaff182..1ca145b99 100644
--- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
+++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManagerInterface.php
@@ -9,6 +9,7 @@ use Chill\MainBundle\Entity\Center;
interface CenterResolverManagerInterface
{
/**
+ * @param object $entity
* @return Center[]
*/
public function resolveCenters($entity, ?array $options = []): array;
From c7ffb7062a20ea5b237045307de7fca4b08a73c6 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 18 Nov 2021 11:26:26 +0100
Subject: [PATCH 208/227] improve resume course styles
---
.../Activity/activity-badge-title.html.twig | 10 ++++----
.../Resources/public/chill/chillmain.scss | 8 +++++++
.../Resources/public/chill/scss/badge.scss | 10 ++++++++
.../Resources/public/chill/scss/mixins.scss | 2 +-
.../AccompanyingCourse/components/Banner.vue | 2 +-
...st_recent_by_accompanying_period.html.twig | 23 ++++++++++++++-----
6 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/activity-badge-title.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/activity-badge-title.html.twig
index 1e1d65d91..f4a3d4d29 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/activity-badge-title.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/activity-badge-title.html.twig
@@ -27,14 +27,16 @@
{{ activity.type.name | localize_translatable_string }}
+ {% if activity.location and t.locationVisible %}
- {{ 'location'|trans ~ ': ' }}
- {# TODO {% if activity.location %}{{ activity.location }}{% endif %} #}
- Domicile de l'usager
+ {{ 'location'|trans ~ ': ' }}
+ {{ activity.location.locationType.title|localize_translatable_string }}
+ {{ activity.location.name }}
+ {% endif %}
{% if activity.user and t.userVisible %}
- {{ 'Referrer'|trans ~ ': ' }}
+ {{ 'Referrer'|trans ~ ': ' }}
{{ activity.user.usernameCanonical }}
{% endif %}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss
index 593cd49b4..53a9d200b 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss
+++ b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss
@@ -402,3 +402,11 @@ input.belgian_national_number {
&.daily_counter {}
&.control_digit {}
}
+
+// replace abbr
+span.item-key {
+ font-variant: all-small-caps;
+ font-size: 90%;
+ background-color: #0000000a;
+ //text-decoration: dotted underline;
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
index 7e9f13149..7dcddf65d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
+++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
@@ -60,6 +60,16 @@ h2.badge-title {
h3 {
margin-bottom: 0.5rem;
}
+
+ //position: relative;
+ span {
+ display: none;
+ //position: absolute;
+ //top: 0;
+ //left: 0;
+ //transform: rotate(270deg);
+ //transform-origin: 0 0;
+ }
}
span.title_action {
flex-grow: 1;
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
index e995f97eb..878ff82e1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
+++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
@@ -4,7 +4,7 @@
///
@mixin chill_badge($color) {
- text-transform: capitalize !important;
+ //text-transform: capitalize !important;
font-weight: 500 !important;
border-left: 20px groove $color;
&:before {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
index 84e7fb2c6..801e83068 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
@@ -22,7 +22,7 @@
{{ $t('course.open_at') }}{{ $d(accompanyingCourse.openingDate.datetime, 'text') }}
- {{ $t('course.referrer') }}: {{ accompanyingCourse.user.username }}
+ {{ $t('course.referrer') }}: {{ accompanyingCourse.user.username }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
index 979488ff3..ec782615a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig
@@ -3,20 +3,31 @@
- {{ 'accompanying_course_work.action'|trans }}
- {{ w.socialAction|chill_entity_render_string }}
+
+ {{ 'accompanying_course_work.action'|trans }}
+
+
+ {{ w.socialAction|chill_entity_render_string }}
- {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}
- {{ w.startDate|format_date('short') }}
+ {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}
+ {{ w.startDate|format_date('short') }}
+ {% if w.endDate %}
- {{ 'Last updated by'|trans ~ ' : ' }}
- {{ w.updatedBy|chill_entity_render_box }}, {{ w.updatedAt|format_datetime('short', 'short') }}
+ {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}
+ {{ w.endDate|format_date('short') }}
+ {% endif %}
+
+ {{ 'Last updated by'|trans }}
+ {{ w.updatedBy|chill_entity_render_box }} :
+ {{ w.updatedAt|format_datetime('short', 'short') }}
+
+
{% endfor %}
From 193d0fb94a3fb1796c8a12dc108d10df8b3545a9 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 18 Nov 2021 16:02:40 +0100
Subject: [PATCH 209/227] vue_activity: style for suggestions, add and remove
items
---
.../public/vuejs/Activity/components/ConcernedGroups.vue | 7 +++++--
.../Activity/components/ConcernedGroups/PersonBadge.vue | 2 +-
.../Resources/views/Activity/show.html.twig | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue
index 108e1e493..e31376446 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue
@@ -11,9 +11,12 @@
-
+
- {{ p.text }}
+
+
+ {{ p.text }}
+
diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonBadge.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonBadge.vue
index bef11159c..0b2dd6613 100644
--- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonBadge.vue
+++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonBadge.vue
@@ -4,7 +4,7 @@
{{ textCutted }}
-
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
index e11ab863b..a30034257 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
@@ -55,7 +55,7 @@
{% endif %}
{{ 'Concerned groups'|trans }}
-{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc' } %}
+{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc', 'badge_person': 'true' } %}
{{ 'Activity data'|trans }}
From a6001961519d2b3660969f79836eeef82a2842fc Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 18 Nov 2021 16:25:36 +0100
Subject: [PATCH 210/227] vue_accourse referrer: style for suggestions, add and
remove items
---
.../AccompanyingCourse/components/Referrer.vue | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
index c39e043c6..b67bbc038 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
@@ -19,16 +19,16 @@
@select="updateReferrer">
-
-
-
-
From aba47600ff2501b54aa8a0bbf30784a334b5db27 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 18 Nov 2021 17:56:46 +0100
Subject: [PATCH 211/227] hop
---
.../Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
index 5bb52358b..b3ddffbd7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
@@ -119,9 +119,9 @@
{{ $t('persons_involved') }}
-
+
From 5a6a15a35126e7f7008bd61cd5e0bab3ba063606 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Fri, 19 Nov 2021 12:31:48 +0100
Subject: [PATCH 212/227] fix: Add missing repository.
---
.../ActivityTypeCategoryRepository.php | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php
diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php
new file mode 100644
index 000000000..62a6a9a0d
--- /dev/null
+++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeCategoryRepository.php
@@ -0,0 +1,23 @@
+
Date: Fri, 19 Nov 2021 12:32:05 +0100
Subject: [PATCH 213/227] fix: Fix wrong repository.
---
.../Controller/ActivityController.php | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
index 47ebebd09..5e7e0de21 100644
--- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
+++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
@@ -7,6 +7,7 @@ namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
use Chill\ActivityBundle\Repository\ActivityRepository;
+use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository;
use Chill\ActivityBundle\Repository\ActivityTypeRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\Repository\LocationRepository;
@@ -54,9 +55,12 @@ final class ActivityController extends AbstractController
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
+ private ActivityTypeCategoryRepository $activityTypeCategoryRepository;
+
public function __construct(
ActivityACLAwareRepositoryInterface $activityACLAwareRepository,
ActivityTypeRepository $activityTypeRepository,
+ ActivityTypeCategoryRepository $activityTypeCategoryRepository,
PersonRepository $personRepository,
ThirdPartyRepository $thirdPartyRepository,
LocationRepository $locationRepository,
@@ -69,6 +73,7 @@ final class ActivityController extends AbstractController
) {
$this->activityACLAwareRepository = $activityACLAwareRepository;
$this->activityTypeRepository = $activityTypeRepository;
+ $this->activityTypeCategoryRepository = $activityTypeCategoryRepository;
$this->personRepository = $personRepository;
$this->thirdPartyRepository = $thirdPartyRepository;
$this->locationRepository = $locationRepository;
@@ -136,10 +141,17 @@ final class ActivityController extends AbstractController
$data = [];
- $activityTypeCategories = $this->activityTypeRepository->findBy(['active' => true], ['ordering' => 'ASC']);
+ $activityTypeCategories = $this
+ ->activityTypeCategoryRepository
+ ->findBy(['active' => true], ['ordering' => 'ASC']);
foreach ($activityTypeCategories as $activityTypeCategory) {
- $activityTypes = $this->activityTypeRepository->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
+ $activityTypes = $this
+ ->activityTypeRepository
+ ->findBy(
+ ['active' => true, 'category' => $activityTypeCategory],
+ ['ordering' => 'ASC']
+ );
$data[] = [
'activityTypeCategory' => $activityTypeCategory,
From 0a522b465fbb28eec9c3fa9c162a24930c945b9e Mon Sep 17 00:00:00 2001
From: Pol Dellaiera
Date: Fri, 19 Nov 2021 12:32:21 +0100
Subject: [PATCH 214/227] fix: Update typing information.
---
.../Entity/ActivityTypeCategory.php | 28 ++-----------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
index a95424312..4b06ca9b5 100644
--- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
+++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
@@ -1,31 +1,12 @@
- *
- * 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 .
- */
+declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
- * Class ActivityTypeCateogry
- *
- * @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Table(name="activitytypecategory")
* @ORM\HasLifecycleCallbacks()
@@ -37,7 +18,7 @@ class ActivityTypeCategory
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private ?int $id;
+ private ?int $id = null;
/**
* @ORM\Column(type="json")
@@ -54,10 +35,7 @@ class ActivityTypeCategory
*/
private float $ordering = 0.0;
- /**
- * Get id
- */
- public function getId(): int
+ public function getId(): ?int
{
return $this->id;
}
From f1113ee44841949ff4ce55fb431aad19b7e222e2 Mon Sep 17 00:00:00 2001
From: nobohan
Date: Fri, 19 Nov 2021 14:48:31 +0100
Subject: [PATCH 215/227] accompanying course: add client-side validation if no
origin
---
.../vuejs/AccompanyingCourse/components/Confirm.vue | 9 +++++++--
.../AccompanyingCourse/components/OriginDemand.vue | 10 ++++++++--
.../public/vuejs/AccompanyingCourse/js/i18n.js | 2 ++
.../public/vuejs/AccompanyingCourse/store/index.js | 4 ++++
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
index f23a7c9e5..4142b4f50 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
@@ -10,7 +10,7 @@
{{ $t('confirm.alert_validation') }}
-
+
{{ $t(notValidMessages[k].msg) }}
@@ -83,7 +83,11 @@ export default {
},
location: {
msg: 'confirm.location_not_valid',
- anchor: '#section-20' //
+ anchor: '#section-20'
+ },
+ origin: {
+ msg: 'confirm.origin_not_valid',
+ anchor: '#section-30'
},
socialIssue: {
msg: 'confirm.socialIssue_not_valid',
@@ -103,6 +107,7 @@ export default {
...mapGetters([
'isParticipationValid',
'isSocialIssueValid',
+ 'isOriginValid',
'isLocationValid',
'validationKeys',
'isValidToBeConfirmed'
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
index 30ad6afe0..b88bf0747 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
@@ -19,15 +19,18 @@
:options="options"
@select="updateOrigin">
-
+
+
+ {{ $t('origin.not_valid') }}
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig
index e55b39f64..2f1e75a7f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig
@@ -23,11 +23,28 @@