Compare commits

..

139 Commits

Author SHA1 Message Date
Pol Dellaiera
ee4e0b86fd ci: Autofix code style. 2021-05-07 22:39:37 +02:00
Pol Dellaiera
ce4cbe3b8d Fix syntax errors. 2021-05-07 21:59:49 +02:00
Pol Dellaiera
c5b8b6345d Upgrade drupol/php-conventions to v5. 2021-05-07 21:59:49 +02:00
8b51bfbaf5 force type for connection parameter 2021-05-07 21:59:49 +02:00
Pol Dellaiera
f6cf0dba2f chore: Add/update static files. 2021-05-07 21:59:49 +02:00
Pol Dellaiera
0625afecdd chore: Update composer.json 2021-05-07 19:43:46 +02:00
a63c38b6aa Merge branch '37_modal_add-persons' 2021-05-07 15:46:38 +02:00
8915c42008 endpoint DELETE participation works ! 2021-05-07 15:44:08 +02:00
503293a359 Merge branch 'master' into '37_modal_add-persons'
# Conflicts:
#   src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
#   src/Bundle/ChillPersonBundle/chill.webpack.config.js
2021-05-07 13:35:48 +00:00
7bdf71315a move Modal component in ChillMainAssets 2021-05-07 15:28:50 +02:00
6f5d457122 renaming store state dict name 2021-05-07 15:16:27 +02:00
b4274264a7 create addPersons store module, move state/getters/mutations/actions in module 2021-05-07 15:04:36 +02:00
8002725c87 fix doc for api 2021-05-07 12:42:49 +02:00
2c9edf3741 Set Collection normalization to fit into specs from https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/136 2021-05-07 12:13:24 +02:00
3f562449e1 Merge branch 'issue23_addresses' into 'master'
Issue23 addresses

See merge request Chill-Projet/chill-bundles!12
2021-05-07 09:27:56 +00:00
1cce39bcb5 Merge branch 'bootstrap-api' into 'master'
Bootstrap api

See merge request Chill-Projet/chill-bundles!35
2021-05-07 09:14:11 +00:00
ad690db886 display reset link + minor changes 2021-05-07 10:36:50 +02:00
nobohan
1b8462b40d update validto field in chill_main_address for legacy 2021-05-07 10:27:11 +02:00
Pol Dellaiera
8c98f2cf6e Update .gitignore file. 2021-05-07 09:04:29 +02:00
f3260f57a4 fix display elements order
selectAndSuggested method in store getter, is callable in all components,
and make union of two arrays: suggested and selected

* we need to have selected in last position (required for isChecked method to work well)
* but we want to display selected in first position (for better ux)

then, we use double inversion to obtain good behaviour
2021-05-06 19:23:28 +02:00
b4ad0128e4 manage selected and suggested arrays: fix duplicate 2021-05-06 19:15:25 +02:00
e1c8278f71 Merge branch 'fix-return-type' into 'master'
Fix return type of Person::getAddresses().

See merge request Chill-Projet/chill-bundles!39
2021-05-06 15:05:35 +00:00
Pol Dellaiera
ed3f46ce7f Fix return type. 2021-05-06 17:01:11 +02:00
33457d3cbc Merge branch 'fix-accompanying-period-opening' into bootstrap-api 2021-05-06 16:02:13 +02:00
e919b4322e fix accompanying period/remove person 2021-05-06 15:49:38 +02:00
7503c845df Merge branch 'dev-undefined-index' into 'master'
fix undefined index in person edit form

See merge request Chill-Projet/chill-bundles!26
2021-05-06 13:47:13 +00:00
3686a294d3 fix return type for person::getAddresses 2021-05-06 13:57:44 +02:00
b6131379f9 Merge remote-tracking branch 'origin/master' into bootstrap-api 2021-05-06 13:20:12 +02:00
e1fcc41ace avoiding duplicates between selected and suggested (wip)
see comments in store/index.js
2021-05-06 13:16:26 +02:00
f2a04cebe6 configure origin route into chillMainExtension 2021-05-06 13:12:18 +02:00
c693002ddb documentation for api - prepend config 2021-05-06 13:11:59 +02:00
ee77c8540a fix typos 2021-05-06 13:00:59 +02:00
a536d2780e fix state mutation for closeParticipation 2021-05-06 12:57:53 +02:00
f880598052 documentation for api 2021-05-06 12:56:19 +02:00
e7985ea52f customize controller for origin 2021-05-06 12:55:40 +02:00
f56dc65021 fix argument order 2021-05-06 12:55:12 +02:00
nobohan
4770758aee add migrations for addresse on household + add linkedtothirdparty on address 2021-05-06 12:36:58 +02:00
90fe484d81 fix api for rendering a single item 2021-05-06 12:18:47 +02:00
2b8bbe019d first impl for index action 2021-05-06 12:08:45 +02:00
9e1c151402 réinitialize suggested, avoiding double with selected (wip) 2021-05-06 10:57:04 +02:00
088e522292 Merge branch 'master' into _31_interface_creation_parcours 2021-05-06 10:55:22 +02:00
b8e6e98a74 fix payload error with add participation 2021-05-06 10:44:15 +02:00
2db847ada2 Merge branch 'drupol-fix-person-addresses' into 'master'
Fix person addresses

See merge request Chill-Projet/chill-bundles!33
2021-05-06 07:14:54 +00:00
07e0692783 bootstrap api and apply on accompanying period 2021-05-06 00:14:36 +02:00
e78d53064b closeParticipation fetch DELETE request 2021-05-05 21:48:00 +02:00
e6fcb5ff22 Merge branch '_test_closePerson' into _31_interface_creation_parcours 2021-05-05 20:47:39 +02:00
f02e33fda7 first impl for api 2021-05-05 20:33:34 +02:00
1bbec9efae improve addpersons store cycle: init query, selections and suggestions 2021-05-05 19:25:28 +02:00
3b53c4451c fix modal ux counter position 2021-05-05 18:45:51 +02:00
30f490959b for each selected, loop for post participation, then get response and commit state 2021-05-05 18:44:26 +02:00
nobohan
0a894b0db1 add new fields on Address and Household 2021-05-05 18:24:58 +02:00
c20e9507d5 prepare close participation button (wip) 2021-05-05 15:03:58 +02:00
f89c690f1b add scratch fontawesome 'remove' button 2021-05-05 13:36:45 +02:00
Pol Dellaiera
7819c1204c Merge branch '4-remove-unused-main-test-route' into 'master'
Issue #4: Remove obsolete route.

Closes #4

See merge request Chill-Projet/chill-bundles!31
2021-05-05 10:30:03 +00:00
nobohan
f61af9d02a add household and householdmembers entities + migration 2021-05-05 11:44:55 +02:00
Pol Dellaiera
e470a6a97e Merge remote-tracking branch 'tmp/fix-person-last-address' into drupol-fix-person-addresses 2021-05-05 11:24:18 +02:00
Pol Dellaiera
cd8c47449b Issue #4: Remove obsolete route. 2021-05-05 11:11:25 +02:00
120e7cade5 simplify store suggested array 2021-05-05 11:11:13 +02:00
ac550e05e8 improve addPersons modal ux 2021-05-05 09:29:57 +02:00
d6e7fadb4f Merge branch 'issue_43_admin_prosoc' into 'master'
URGENT : Fix namespace pbm

See merge request Chill-Projet/chill-bundles!30
2021-05-05 07:00:05 +00:00
Marc Ducobu
2be1c08c44 Fix namespace pbm 2021-05-04 19:14:50 +02:00
nobohan
86c177bbbb remove vuejs address component 2021-05-04 17:26:47 +02:00
Pol Dellaiera
d426d28ba0 Merge branch 'add-readme' into 'master'
docs: Add root README file.

See merge request Chill-Projet/chill-bundles!29
2021-05-04 13:14:14 +00:00
Pol Dellaiera
72e69fc0b3 docs: Add root README file. 2021-05-04 14:49:36 +02:00
cc8de353d4 moving selected counter + cleaning code 2021-05-04 10:48:58 +02:00
4495a5d33b Union suggested and selected results 2021-05-03 23:15:38 +02:00
9dffe30aad Merge branch '_31_interface_creation_parcours' of gitlab.com:Chill-Projet/chill-bundles into _31_interface_creation_parcours 2021-05-03 22:53:47 +02:00
d393e74896 save checkboxes state in store 2021-05-03 22:44:28 +02:00
daf083dc88 save checkboxes state in store 2021-05-03 21:02:15 +02:00
nobohan
ce859697b5 Use json endpoint for showing address with Vuejs Components (WIP) 2021-05-03 17:16:45 +02:00
nobohan
1587c762f8 better fixture for AddressReference 2021-05-03 14:34:23 +02:00
nobohan
17c01d9b46 fix fixture for address reference 2021-05-03 12:18:21 +02:00
a1bb9ea352 modal addPerson design, search field: focus and position fixed 2021-05-03 11:52:06 +02:00
nobohan
a1895ec65f fixture for addressReference - WIP 2021-05-03 11:18:31 +02:00
nobohan
c5faa0b99d update the address fixture by adding some points 2021-05-03 09:28:05 +02:00
nobohan
e9d142f3e8 define legacy functions for Address 2021-05-03 09:28:05 +02:00
nobohan
91860afd80 check if point value is null for 2 methods in PointType 2021-05-03 09:28:05 +02:00
nobohan
bec0700d39 Point model: better handling of exception 2021-05-03 09:28:05 +02:00
nobohan
05d3d7f5c7 update twig template and AddressType following the changes in Address entity 2021-05-03 09:28:05 +02:00
nobohan
ebff36d257 add unit test for class Point 2021-05-03 09:28:05 +02:00
nobohan
a709b3afb6 add addressReference in Chill Main + migration 2021-05-03 09:28:05 +02:00
nobohan
69a3c6a9b2 refine the migration comment 2021-05-03 09:28:05 +02:00
juminet
8c33d876e8 code formatting in PointType 2021-05-03 09:28:05 +02:00
nobohan
1ec2fbcc16 translated exception messages in English 2021-05-03 09:28:05 +02:00
juminet
bc4e29141b syntax (null -> NULL and == -> ===) 2021-05-03 09:28:05 +02:00
nobohan
e90ea31683 add type hinting in Point and PointException 2021-05-03 09:28:05 +02:00
juminet
7c99f0b3e0 array synatx: array() -> [] 2021-05-03 09:28:05 +02:00
nobohan
c089960707 add type hinting in Point and PointException 2021-05-03 09:28:05 +02:00
nobohan
0b2f29f1e8 add migration for address 2021-05-03 09:28:05 +02:00
nobohan
9a4f50472a add point type + Address: add Point field : fix dependency injection of the Point type 2021-05-03 09:28:05 +02:00
nobohan
7d1a1c4004 #32 add point type + Address: add Point field + add null on nullable fields 2021-05-03 09:28:05 +02:00
nobohan
ebd58d4229 add more fields to Address entity + rename streetAddress1 and streetAddress2 2021-05-03 09:25:41 +02:00
nobohan
dd48795f64 #23 enable postgis in a chil main migration 2021-05-03 09:25:41 +02:00
3d45b6687f adding addPersons component with modal, search field and basic suggestions 2021-04-30 23:18:57 +02:00
35e6d36ce0 fetch postParticipation request, catch fetch error, store mutation+action 2021-04-30 16:33:49 +02:00
4900c81c11 improve inheritance with translations i18n.js files
vue-i18n --> chill main i18n ---( )---> app index
chill bundle i18n --> app i18n --^
2021-04-30 16:32:06 +02:00
52472b0ec3 Merge branch 'fix-tests-main' into 'master'
Fix tests for chill main bundle

See merge request Chill-Projet/chill-bundles!24
2021-04-29 22:35:47 +00:00
ec68e6f761 make inheritance for vue translations i18n.js files
By importing only the app i18n file,
we benefit from the whole inherited chain:

app i18n < chill bundle i18n < chill main bundle i18n
2021-04-29 18:32:22 +02:00
25bd170f6b improve modal system, test when a modal call next modal 2021-04-29 15:49:25 +02:00
6939b4a313 Merge branch 'master' into _31_interface_creation_parcours 2021-04-29 14:19:02 +02:00
d18922ed98 permit multiple modals in same component 2021-04-29 14:04:40 +02:00
e8bf242c42 Merge branch '_31_interface_creation_parcours' of gitlab.com:Chill-Projet/chill-bundles into _31_interface_creation_parcours 2021-04-29 12:44:29 +02:00
2050460bb3 add modal system, added/removed managed by vue, appearence managed by bootstrap
Modal component is an hybrid solution between :
- Vue3 modal implementation
  => with 'v-if:showModal' directive:parameter, html scope is added/removed not just shown/hidden
  => with slot we can pass content from parent component
  => some classes are passed from parent component
- Bootstrap 4.4 _modal.scss module
  => using bootstrap css classes, the modal have a responsive behaviour,
  => modal design can be configured using css classes (size, scroll)

See
* https://v3.vuejs.org/examples/modal.html#modal-component
* https://github.com/bootstrap-vue/bootstrap-vue/issues/5196
2021-04-29 12:40:28 +02:00
nobohan
4add30e895 add fixture for parcours: replace createQuery by createQueryBuilder 2021-04-29 12:23:41 +02:00
e1dbfdafd7 test modals with vue and modals with bootstrap 2021-04-28 22:01:05 +02:00
75becb2294 Merge branch '_31_interface_creation_parcours' of gitlab.com:Chill-Projet/chill-bundles into _31_interface_creation_parcours 2021-04-28 21:58:52 +02:00
94e494361f adding show/edit links (prepare modal) + save button 2021-04-28 18:00:46 +02:00
cab3b1059d ChillMainBundle: use localize function 2021-04-28 15:56:50 +02:00
nobohan
d27bdf68fb Merge branch '_31_interface_creation_parcours' of https://gitlab.com/Chill-Projet/chill-bundles into _31_interface_creation_parcours
merge..
2021-04-28 12:24:29 +02:00
nobohan
82b82920e1 add 2 fixtures for parcours 2021-04-28 12:24:25 +02:00
4bb3eadf91 renaming vuejs root dir 2021-04-28 11:41:15 +02:00
4c82e65c1f Merge branch '14-correctif-creation-personne' into 'master'
Use injected EntityManager - fix property visibility.

See merge request Chill-Projet/chill-bundles!25
2021-04-28 08:36:34 +00:00
cf4d7df7ad Merge branch 'bootstrap-serializer' into 'master'
Bootstrap serializer

See merge request Chill-Projet/chill-bundles!17
2021-04-28 08:32:02 +00:00
86d13410c3 Merge branch 'bootstrap-serializer' into fix-tests-main 2021-04-28 10:29:53 +02:00
19fdf2a503 Add test for AccompanyingCourseController 2021-04-28 10:28:10 +02:00
3a0c25c871 fix addPerson feature with vue3+store+i18n 2021-04-28 10:10:16 +02:00
083338da8d Merge branch 'master' into _31_interface_creation_parcours 2021-04-28 08:54:20 +02:00
37e5c9ceaa Merge branch '_31_interface_creation_parcours' of gitlab.com:Chill-Projet/chill-bundles into _31_interface_creation_parcours 2021-04-28 08:49:32 +02:00
Pol Dellaiera
5448238697 Set final keyword - remove redundant information in phpdoc. 2021-04-28 07:21:19 +02:00
Pol Dellaiera
c5250a1059 Use injected EntityManager - fix property visibility. 2021-04-27 23:07:59 +02:00
b2c1a7b8de Merge remote-tracking branch 'origin/master' into fix-tests-main 2021-04-27 22:50:32 +02:00
b4583fc6dc improve serializers 2021-04-27 22:48:48 +02:00
f7c508939c Add test for AccompanyingCourseController 2021-04-27 22:40:00 +02:00
4cf77a9b0e adapt multi components to new store and new api endpoints
* base of i18n (yarn add new deps)
2021-04-27 22:03:39 +02:00
a2160bef7d WIP: first implementation for test 2021-04-27 19:33:34 +02:00
nobohan
c2a4a95eba add a fixture for accompanying period - wip 2021-04-27 18:52:37 +02:00
8641d6bdce try to fix correct values for redis 2021-04-27 18:06:58 +02:00
5f4d513aa6 try to connect to redis in gitlab-ci 2021-04-27 17:57:09 +02:00
f47b15de39 try to fix .gitlab-ci with correct redis parameters 2021-04-27 17:52:12 +02:00
7426dc02cf currently restrict to chill main test suite 2021-04-27 17:18:46 +02:00
a570160aed update chill app to working commit 2021-04-27 17:18:26 +02:00
7596bd5a06 fix tests for chill main 2021-04-27 16:33:44 +02:00
01f9d03b14 init vuex store 2021-04-27 15:11:13 +02:00
66426f5102 serializer on accompanying course
Two new routes:

* `GET /{_locale}/person/api/1.0/accompanying-course/{parcours_id}/show.json`: get a json representation for a course
* `POST /{_locale}/person/api/1.0/accompanying-course/{parcours_id}/participation.json`:
add a particitipation to course. Usage:

    `curl -v --cookie "PHPSESSID=fed98aa23e40cb36e630f84155aea3bb;" -X
POST --data '{ "id": 481 }'
http://localhost:8001/fr/person/api/1.0/accompanying-course/270/participation.json`

    Will add the person with id "481" to the course.
2021-04-26 17:01:22 +02:00
Pol Dellaiera
03243605da Remove unrelated code style change. 2021-04-02 11:18:52 +02:00
Pol Dellaiera
48e2d2ceab Do not use DateTimeImmutable. 2021-04-02 11:18:48 +02:00
Pol Dellaiera
777fb25860 tests: Add missing test based on review's feedback. 2021-04-02 11:12:50 +02:00
Pol Dellaiera
03601b9707 Update Person::getLastAddress() based on feedback. 2021-04-02 11:11:24 +02:00
c205bbddd3 writing test to reproduce bug 2021-03-08 10:26:12 +01:00
878 changed files with 8802 additions and 7206 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ docs/build/
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

View File

@@ -30,6 +30,10 @@ variables:
POSTGRES_PASSWORD: postgres
# fetch the chill-app using git submodules
GIT_SUBMODULE_STRATEGY: recursive
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_URL: redis://redis:6379
# Run our tests
test:

71
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
use drupol\PhpCsFixerConfigsPhp\Config\Php7;
use PhpCsFixer\RuleSet\RuleSetDescriptionInterface;
use PhpCsFixer\RuleSet\RuleSets;
require __DIR__ . '/vendor/autoload.php';
$vendorDirectory = dirname((new ReflectionClass(Php7::class))->getFileName(), 5);
$config = require $vendorDirectory . '/drupol/php-conventions/config/php73/php_cs_fixer.config.php';
$config
->getFinder()
->ignoreDotFiles(false);
$rules = $config->getRules();
$riskyRules = array_reduce(
array_filter(
RuleSets::getSetDefinitions(),
static function (RuleSetDescriptionInterface $ruleset): bool {
return $ruleset->isRisky();
}
),
static function (array $carry, RuleSetDescriptionInterface $ruleSetDescription): array {
return array_merge($carry, array_keys($ruleSetDescription->getRules()));
},
[]
);
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
// Remove properties containing the word 'risky'.
// Remove custom risky properties
$rules = array_filter(
array_filter(
array_diff_key(
$rules,
array_flip($riskyRules)
),
static function (string $property): bool {
return false === strpos(strtolower($property), 'risky');
},
ARRAY_FILTER_USE_KEY
),
static function (string $property): bool {
return false === in_array(
$property,
[
'static_lambda',
'ordered_interfaces',
'psr4',
]
);
},
ARRAY_FILTER_USE_KEY
);
return $config->setRules($rules);

View File

@@ -1,25 +0,0 @@
<?php
/**
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
$config = require __DIR__ . '/vendor/drupol/php-conventions/config/php73/php_cs_fixer.config.php';
$config
->getFinder()
->ignoreDotFiles(false)
->name(['.php_cs.dist']);
$rules = $config->getRules();
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
return $config->setRules($rules);

9
README.md Normal file
View File

@@ -0,0 +1,9 @@
# Chill framework
Documentation of the Chill software.
The online documentation can be found at http://docs.chill.social
See the [`docs`][1] directory for more.
[1]: docs/README.md

View File

@@ -64,7 +64,7 @@
"symfony/symfony": "*"
},
"require-dev": {
"drupol/php-conventions": "4.*",
"drupol/php-conventions": "5.*",
"fakerphp/faker": "^1.13",
"phpunit/phpunit": "^7.0",
"symfony/dotenv": "^5.1",

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
@@ -20,7 +16,7 @@ use Doctrine\ORM\Query\Expr;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
{
// add specific role for this filter
public function addRole()

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\ExportInterface;
@@ -93,7 +89,7 @@ class CountPerson implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
// we gather all center the user choose.
$centers = array_map(static function ($el) {
$centers = array_map(function ($el) {
return $el['center'];
}, $acl);

View File

@@ -0,0 +1,453 @@
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
.. _api:
API
###
Chill provides a basic framework to build REST api.
Configure a route
=================
Follow those steps to build a REST api:
1. Create your model;
2. Configure the API;
You can also:
* hook into the controller to customize some steps;
* add more route and steps
.. note::
Useful links:
* `How to use annotation to configure serialization <https://symfony.com/doc/current/serializer.html>`_
* `How to create your custom normalizer <https://symfony.com/doc/current/serializer/custom_normalizer.html>`_
Auto-loading the routes
***********************
Ensure that those lines are present in your file `app/config/routing.yml`:
.. code-block:: yaml
chill_cruds:
resource: 'chill_main_crud_route_loader:load'
type: service
Create your model
*****************
Create your model on the usual way:
.. code-block:: php
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\OriginRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=OriginRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_origin")
*/
class Origin
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $label;
/**
* @ORM\Column(type="date_immutable", nullable=true)
*/
private $noActiveAfter;
// .. getters and setters
}
Configure api
*************
Configure the api using Yaml (see the full configuration: :ref:`api_full_configuration`):
.. code-block:: yaml
# config/packages/chill_main.yaml
chill_main:
apis:
accompanying_period_origin:
base_path: '/api/1.0/person/accompanying-period/origin'
class: 'Chill\PersonBundle\Entity\AccompanyingPeriod\Origin'
name: accompanying_period_origin
base_role: 'ROLE_USER'
actions:
_index:
methods:
GET: true
HEAD: true
_entity:
methods:
GET: true
HEAD: true
.. note::
If you are working on a shared bundle (aka "The chill bundles"), you should define your configuration inside the class :code:`ChillXXXXBundleExtension`, using the "prependConfig" feature:
.. code-block:: php
namespace Chill\PersonBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ChillPersonExtension
* Loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
* @package Chill\PersonBundle\DependencyInjection
*/
class ChillPersonExtension extends Extension implements PrependExtensionInterface
{
public function prepend(ContainerBuilder $container)
{
$this->prependCruds($container);
}
/**
* @param ContainerBuilder $container
*/
protected function prependCruds(ContainerBuilder $container)
{
$container->prependExtensionConfig('chill_main', [
'apis' => [
[
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Origin::class,
'name' => 'accompanying_period_origin',
'base_path' => '/api/1.0/person/accompanying-period/origin',
'controller' => \Chill\PersonBundle\Controller\OpeningApiController::class,
'base_role' => 'ROLE_USER',
'actions' => [
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
],
],
'_entity' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
]
],
]
]
]
]);
}
}
The :code:`_index` and :code:`_entity` action
=============================================
The :code:`_index` and :code:`_entity` action are default actions:
* they will call a specific method in the default controller;
* they will generate defined routes:
Index:
Name: :code:`chill_api_single_accompanying_period_origin__index`
Path: :code:`/api/1.0/person/accompanying-period/origin.{_format}`
Entity:
Name: :code:`chill_api_single_accompanying_period_origin__entity`
Path: :code:`/api/1.0/person/accompanying-period/origin/{id}.{_format}`
Role
====
By default, the key `base_role` is used to check ACL. Take care of creating the :code:`Voter` required to take that into account.
For index action, the role will be called with :code:`NULL` as :code:`$subject`. The retrieved entity will be the subject for single queries.
You can also define a role for each method. In this case, this role is used for the given method, and, if any, the base role is taken into account.
.. code-block:: yaml
# config/packages/chill_main.yaml
chill_main:
apis:
accompanying_period_origin:
base_path: '/api/1.0/person/bla/bla'
class: 'Chill\PersonBundle\Entity\Blah'
name: bla
actions:
_entity:
methods:
GET: true
HEAD: true
roles:
GET: MY_ROLE_SEE
HEAD: MY ROLE_SEE
Customize the controller
========================
You can customize the controller by hooking into the default actions. Take care of extending :code:`Chill\MainBundle\CRUD\Controller\ApiController`.
.. code-block:: php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class OpeningApiController extends ApiController
{
protected function customizeQuery(string $action, Request $request, $qb): void
{
$qb->where($qb->expr()->gt('e.noActiveAfter', ':now'))
->orWhere($qb->expr()->isNull('e.noActiveAfter'));
$qb->setParameter('now', new \DateTime('now'));
}
}
And set your controller in configuration:
.. code-block:: yaml
chill_main:
apis:
accompanying_period_origin:
base_path: '/api/1.0/person/accompanying-period/origin'
class: 'Chill\PersonBundle\Entity\AccompanyingPeriod\Origin'
name: accompanying_period_origin
# add a controller
controller: 'Chill\PersonBundle\Controller\OpeningApiController'
base_role: 'ROLE_USER'
actions:
_index:
methods:
GET: true
HEAD: true
_entity:
methods:
GET: true
HEAD: true
Create your own actions
=======================
You can add your own actions:
.. code-block:: yaml
chill_main:
apis:
-
class: Chill\PersonBundle\Entity\AccompanyingPeriod
name: accompanying_course
base_path: /api/1.0/person/accompanying-course
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
actions:
# add a custom participation:
participation:
methods:
POST: true
DELETE: true
GET: false
HEAD: false
PUT: false
roles:
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
GET: null
HEAD: null
PUT: null
single-collection: single
The key :code:`single-collection` with value :code:`single` will add a :code:`/{id}/ + "action name"` (in this example, :code:`/{id}/participation`) into the path, after the base path. If the value is :code:`collection`, no id will be set, but the action name will be append to the path.
Then, create the corresponding action into your controller:
.. code-block:: php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
use Chill\PersonBundle\Entity\Person;
class AccompanyingCourseApiController extends ApiController
{
protected EventDispatcherInterface $eventDispatcher;
protected ValidatorInterface $validator;
public function __construct(EventDispatcherInterface $eventDispatcher, $validator)
{
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
}
public function participationApi($id, Request $request, $_format)
{
/** @var AccompanyingPeriod $accompanyingPeriod */
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
$person = $this->getSerializer()
->deserialize($request->getContent(), Person::class, $_format, []);
if (NULL === $person) {
throw new BadRequestException('person id not found');
}
$this->onPostCheckACL('participation', $request, $accompanyingPeriod, $_format);
switch ($request->getMethod()) {
case Request::METHOD_POST:
$participation = $accompanyingPeriod->addPerson($person);
break;
case Request::METHOD_DELETE:
$participation = $accompanyingPeriod->removePerson($person);
break;
default:
throw new BadRequestException("This method is not supported");
}
$errors = $this->validator->validate($accompanyingPeriod);
if ($errors->count() > 0) {
// only format accepted
return $this->json($errors);
}
$this->getDoctrine()->getManager()->flush();
return $this->json($participation);
}
}
Serialization for collection
============================
A specific model has been defined for returning collection:
.. code-block:: json
{
"count": 49,
"results": [
],
"pagination": {
"more": true,
"next": "/api/1.0/search.json&q=xxxx......&page=2",
"previous": null,
"first": 0,
"items_per_page": 1
}
}
This can be achieved quickly by assembling results into a :code:`Chill\MainBundle\Serializer\Model\Collection`. The pagination information is given by using :code:`Paginator` (see :ref:`Pagination <pagination-ref>`).
.. code-block:: php
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Chill\MainBundle\Pagination\PaginatorInterface;
class MyController extends AbstractController
{
protected function serializeCollection(PaginatorInterface $paginator, $entities): Response
{
$model = new Collection($entities, $paginator);
return $this->json($model, Response::HTTP_OK, [], $context);
}
}
.. _api_full_configuration:
Full configuration example
==========================
.. code-block:: yaml
apis:
-
class: Chill\PersonBundle\Entity\AccompanyingPeriod
name: accompanying_course
base_path: /api/1.0/person/accompanying-course
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
actions:
_entity:
roles:
GET: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
HEAD: null
POST: null
DELETE: null
PUT: null
controller_action: null
path: null
single-collection: single
methods:
GET: true
HEAD: true
POST: false
DELETE: false
PUT: false
participation:
methods:
POST: true
DELETE: true
GET: false
HEAD: false
PUT: false
roles:
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
GET: null
HEAD: null
PUT: null
controller_action: null
# the requirements for the route. Will be set to `[ 'id' => '\d+' ]` if left empty.
requirements: []
path: null
single-collection: single
base_role: null

View File

@@ -16,6 +16,7 @@ As Chill rely on the `symfony <http://symfony.com>`_ framework, reading the fram
Instructions to create a new bundle <create-a-new-bundle.rst>
CRUD (Create - Update - Delete) for one entity <crud.rst>
Helpers for building a REST API <api.rst>
Routing <routing.rst>
Menus <menus.rst>
Forms <forms.rst>

View File

@@ -7,6 +7,8 @@
Free Documentation License".
.. _pagination-ref:
Pagination
##########
@@ -15,7 +17,7 @@ The Bundle :code:`Chill\MainBundle` provides a **Pagination** api which allow yo
A simple example
****************
In the controller, get the :class:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
In the controller, get the :code:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
.. literalinclude:: pagination/example.php

View File

@@ -1,21 +1,17 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\MyBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class example extends Controller
class ItemController extends Controller
{
public function yourAction()
{
@@ -40,12 +36,13 @@ class example extends Controller
// use the paginator to get the number of items to display
->setMaxResults($paginator->getItemsPerPage());
return $this->render(
'ChillMyBundle:Item:list.html.twig',
[
'items' => $items,
'paginator' => $paginator,
]
);
return $this
->render(
'ChillMyBundle:Item:list.html.twig',
[
'items' => $items,
'paginator' => $paginator,
]
);
}
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\HealthBundle\Controller;
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
@@ -29,7 +25,7 @@ class ConsultationController extends Controller
*/
public function listAction($id)
{
/** @var \Chill\PersonBundle\Entity\Person $person */
/* @var $person \Chill\PersonBundle\Entity\Person */
$person = $this->get('chill.person.repository.person')
->find($id);
@@ -39,7 +35,7 @@ class ConsultationController extends Controller
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
/** @var \Chill\MainBundle\Security\Authorization\AuthorizationHelper $authorizationHelper */
/* @var $authorizationHelper \Chill\MainBundle\Security\Authorization\AuthorizationHelper */
$authorizationHelper = $this->get('chill.main.security.'
. 'authorization.helper');

View File

@@ -1,18 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
// Chill\MainBundle\DependencyInjection\Configuration.php
namespace Chill\MainBundle\DependencyInjection;
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
@@ -23,7 +17,7 @@ namespace Chill\MainBundle\DependencyInjection;
/**
* Configure the main bundle.
*/
class ChillMainConfiguration implements ConfigurationInterface
class Configuration implements ConfigurationInterface
{
use AddWidgetConfigurationTrait;
@@ -33,7 +27,7 @@ class ChillMainConfiguration implements ConfigurationInterface
private $containerBuilder;
public function __construct(
array $widgetFactories,
array $widgetFactories = [],
ContainerBuilder $containerBuilder
) {
// we register here widget factories (see below)
@@ -42,9 +36,6 @@ class ChillMainConfiguration implements ConfigurationInterface
$this->containerBuilder = $containerBuilder;
}
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
@@ -62,8 +53,7 @@ class ChillMainConfiguration implements ConfigurationInterface
->end() // end of widgets/children
->end() // end of widgets
->end() // end of root/children
->end() // end of root
;
->end(); // end of root
return $treeBuilder;
}

View File

@@ -1,18 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
//Chill\MainBundle\DependencyInjection\ChillMainExtension.php
namespace Chill\MainBundle\DependencyInjection;
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;

View File

@@ -1,18 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
// Chill/PersonBundle/Widget/PersonListWidgetFactory
namespace Chill\PersonBundle\Widget;
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
@@ -22,7 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* add configuration for the person_list widget.
*/
class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
class PersonListWidgetFactory extends AbstractWidgetFactory
{
/*
* append the option to the configuration
@@ -42,8 +36,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
->end();
}
/**
* return an array with the allowed places where the widget can be rendered.
/*
* return an array with the allowed places where the widget can be rendered
*
* @return string[]
*/
@@ -65,8 +59,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
return 'chill_person.widget.person_list';
}
/**
* return the widget alias.
/*
* return the widget alias
*
* @return string
*/

View File

@@ -1,18 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
// Chill/PersonBundle/Widget/PersonListWidget.php
namespace Chill\PersonBundle\Widget;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
@@ -33,7 +27,7 @@ use Twig_Environment;
*
* The configuration is defined by `PersonListWidgetFactory`
*/
class ChillPersonAddAPersonWidget implements WidgetInterface
class PersonListWidget implements WidgetInterface
{
/**
* the authorization helper.

View File

@@ -1,18 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
// Chill/PersonBundle/DependencyInjection/ChillPersonExtension.php
namespace Chill\PersonBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -26,9 +20,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillPersonExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
// ...

View File

@@ -2,7 +2,8 @@ imports:
- { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml }
parameters:
tasks.phpcsfixer.config: .php_cs.dist
tasks.phpcsfixer.config: .php-cs-fixer.dist.php
tasks.license.name: AGPL-3.0
tasks.license.holder: Champs-Libres
tasks.license.date_from: 2001
tasks.phpcsfixer.allow_risky: false

View File

@@ -18,11 +18,11 @@
<testsuite name="MainBundle">
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
</testsuite>
<!--
<testsuite name="PersonBundle">
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
</testsuite>
-->
</testsuites>
<listeners>

View File

@@ -1,6 +1,5 @@
Chill is a software for social workers.
Chill is a software for social workers
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
@see https://www.champs-libres.coop/

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\Activity;
@@ -25,6 +21,9 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Role\Role;
/**
* Class ActivityController.
*/
class ActivityController extends AbstractController
{
/**
@@ -128,7 +127,7 @@ class ActivityController extends AbstractController
{
$em = $this->getDoctrine()->getManager();
/** @var Activity $activity */
/* @var $activity Activity */
$activity = $em->getRepository('ChillActivityBundle:Activity')
->find($id);
$person = $activity->getPerson();
@@ -152,7 +151,7 @@ class ActivityController extends AbstractController
'comment' => $activity->getComment()->getComment(),
'scope_id' => $activity->getScope()->getId(),
'reasons_ids' => $activity->getReasons()
->map(static function ($ar) {
->map(function ($ar) {
return $ar->getId();
})
->toArray(),

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* ActivityReasonCategory controller.
*/
class ActivityReasonCategoryController extends AbstractController
{
/**

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* ActivityReason controller.
*/
class ActivityReasonController extends AbstractController
{
/**

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityType;
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ActivityTypeController.
*/
class ActivityTypeController extends AbstractController
{
/**

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\Activity;
@@ -22,12 +18,10 @@ use Doctrine\Persistence\ObjectManager;
use Faker\Factory as FakerFactory;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use function in_array;
/**
* Load reports into DB.
*/
class LoadActivity extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
@@ -53,7 +47,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
->findAll();
foreach ($persons as $person) {
$activityNbr = mt_rand(0, 3);
$activityNbr = rand(0, 3);
for ($i = 0; $i < $activityNbr; ++$i) {
echo 'Creating an activity type for : ' . $person . "\n";
@@ -77,7 +71,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
$usedId = [];
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
for ($i = 0; rand(0, 4) > $i; ++$i) {
$reason = $this->getRandomActivityReason($usedId);
$usedId[] = $reason->getId();
$activity->addReason($reason);
@@ -95,7 +89,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
{
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
// we have a reason which should be excluded. Find another...
return $this->getRandomActivityReason($excludingIds);
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReason;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityType;

View File

@@ -1,12 +1,10 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
namespace Chill\ActivityBundle\DataFixtures\ORM;
@@ -19,10 +17,10 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
declare(strict_types=1);
/**
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
* and a role CHILL_ACTIVITY_SEE for administrative.
*/
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
{
public function getOrder()
@@ -45,9 +43,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
}
break;
case 'administrative':
case 'direction':
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
if (in_array($scope->getName()['en'], ['administrative', 'social'])) {
break 2; // we do not want any power on social or administrative
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DependencyInjection;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillActivityExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
@@ -66,7 +59,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
]);
}
/** (non-PHPdoc).
/* (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prependRoutes(ContainerBuilder $container)

View File

@@ -1,23 +1,17 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int;
/**
* This is the class that validates and merges configuration from your app/config files.
*
@@ -25,9 +19,6 @@ use function is_int;
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_activity');
@@ -64,7 +55,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty()
->validate()
->ifTrue(static function ($data) {
->ifTrue(function ($data) {
return !is_int($data);
})->thenInvalid('The value %s is not a valid integer')
->end()

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Chill\MainBundle\Entity\Center;
@@ -27,6 +23,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Activity.
*
* @ORM\Entity
* @ORM\Table(name="activity")
* @ORM\HasLifecycleCallbacks

View File

@@ -1,21 +1,19 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ActivityReason.
*
* @ORM\Entity
* @ORM\Table(name="activityreason")
* @ORM\HasLifecycleCallbacks

View File

@@ -1,22 +1,20 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ActivityReasonCategory.
*
* @ORM\Entity
* @ORM\Table(name="activityreasoncategory")
* @ORM\HasLifecycleCallbacks

View File

@@ -1,21 +1,19 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ActivityType.
*
* @ORM\Entity
* @ORM\Table(name="activitytype")
* @ORM\HasLifecycleCallbacks

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@@ -26,9 +22,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
class ActivityReasonAggregator implements
AggregatorInterface,
ExportElementValidatedInterface
@@ -86,7 +79,7 @@ class ActivityReasonAggregator implements
array_key_exists('activity', $join)
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
|| (!array_key_exists('activity', $join))
or (!array_key_exists('activity', $join))
) {
$qb->add(
'join',
@@ -140,6 +133,7 @@ class ActivityReasonAggregator implements
$this->reasonRepository->findBy(['id' => $values]);
break;
case 'categories':
$this->categoryRepository->findBy(['id' => $values]);
@@ -162,7 +156,7 @@ class ActivityReasonAggregator implements
switch ($data['level']) {
case 'reasons':
/** @var \Chill\ActivityBundle\Entity\ActivityReason $r */
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
$r = $this->reasonRepository->find($value);
return $this->stringHelper->localize($r->getCategory()->getName())
@@ -170,6 +164,7 @@ class ActivityReasonAggregator implements
. $this->stringHelper->localize($r->getName());
break;
case 'categories':
$c = $this->categoryRepository->find($value);

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@@ -78,7 +74,7 @@ class ActivityTypeAggregator implements AggregatorInterface
return 'Activity type';
}
/** @var \Chill\ActivityBundle\Entity\ActivityType $r */
/* @var $r \Chill\ActivityBundle\Entity\ActivityType */
$t = $this->typeRepository->find($value);
return $this->stringHelper->localize($t->getName());

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@@ -53,7 +49,7 @@ class CountActivity implements ExportInterface
throw new LogicException("the key {$key} is not used by this export");
}
return static function ($value) {
return function ($value) {
return '_header' === $value ?
'Number of activities'
:
@@ -84,7 +80,7 @@ class CountActivity implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$qb = $this->entityManager->createQueryBuilder();
$centers = array_map(static function ($el) {
$centers = array_map(function ($el) {
return $el['center'];
}, $acl);

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -29,8 +25,6 @@ use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
use function in_array;
/**
* Create a list for all activities.
@@ -76,9 +70,6 @@ class ListActivity implements ListInterface
$this->translatableStringHelper = $translatableStringHelper;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('fields', ChoiceType::class, [
@@ -87,7 +78,7 @@ class ListActivity implements ListInterface
'choices' => array_combine($this->fields, $this->fields),
'label' => 'Fields to include in export',
'constraints' => [new Callback([
'callback' => static function ($selected, ExecutionContextInterface $context) {
'callback' => function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
@@ -99,8 +90,6 @@ class ListActivity implements ListInterface
}
/**
* {@inheritdoc}
*
* @return type
*/
public function getAllowedFormattersTypes()
@@ -117,7 +106,7 @@ class ListActivity implements ListInterface
{
switch ($key) {
case 'date':
return static function ($value) {
return function ($value) {
if ('_header' === $value) {
return 'date';
}
@@ -126,16 +115,18 @@ class ListActivity implements ListInterface
return $date->format('d-m-Y');
};
case 'attendee':
return static function ($value) {
return function ($value) {
if ('_header' === $value) {
return 'attendee';
}
return $value ? 1 : 0;
};
case 'list_reasons':
/** @var EntityRepository $activityReasonsRepository */
/* @var $activityReasonsRepository EntityRepository */
$activityRepository = $this->entityManager
->getRepository('ChillActivityBundle:Activity');
@@ -155,6 +146,7 @@ class ListActivity implements ListInterface
. '"';
}, $activity->getReasons()->toArray()));
};
case 'circle_name':
return function ($value) {
if ('_header' === $value) {
@@ -164,6 +156,7 @@ class ListActivity implements ListInterface
return $this->translatableStringHelper
->localize(json_decode($value, true));
};
case 'type_name':
return function ($value) {
if ('_header' === $value) {
@@ -175,7 +168,7 @@ class ListActivity implements ListInterface
};
default:
return static function ($value) use ($key) {
return function ($value) use ($key) {
if ('_header' === $value) {
return $key;
}
@@ -207,7 +200,7 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
$centers = array_map(function ($el) {
return $el['center'];
}, $acl);
@@ -227,39 +220,46 @@ class ListActivity implements ListInterface
->setParameter('authorized_centers', $centers);
foreach ($this->fields as $f) {
if (in_array($f, $data['fields'], true)) {
if (in_array($f, $data['fields'])) {
switch ($f) {
case 'id':
$qb->addSelect('activity.id AS id');
break;
case 'person_firstname':
$qb->addSelect('person.firstName AS person_firstname');
break;
case 'person_lastname':
$qb->addSelect('person.lastName AS person_lastname');
break;
case 'person_id':
$qb->addSelect('person.id AS person_id');
break;
case 'user_username':
$qb->join('activity.user', 'user');
$qb->addSelect('user.username AS user_username');
break;
case 'circle_name':
$qb->join('activity.scope', 'circle');
$qb->addSelect('circle.name AS circle_name');
break;
case 'type_name':
$qb->join('activity.type', 'type');
$qb->addSelect('type.name AS type_name');
break;
case 'list_reasons':
// this is a trick... The reasons is filled with the
// activity id which will be used to load reasons

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@@ -81,7 +77,7 @@ class StatActivityDuration implements ExportInterface
$header = 'Sum of activities duration';
}
return static function ($value) use ($header) {
return function ($value) use ($header) {
return '_header' === $value ?
$header
:
@@ -113,7 +109,7 @@ class StatActivityDuration implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) {
$centers = array_map(function ($el) {
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder();

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
@@ -84,7 +80,7 @@ class ActivityDateFilter implements FilterInterface
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var \Symfony\Component\Form\FormInterface $filterForm */
/* @var $filterForm \Symfony\Component\Form\FormInterface */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -27,12 +23,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function count;
class ActivityReasonFilter implements
ExportElementValidatedInterface,
FilterInterface
FilterInterface,
ExportElementValidatedInterface
{
/**
* The repository for activity reasons.
@@ -71,7 +64,7 @@ class ActivityReasonFilter implements
array_key_exists('activity', $join)
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
|| (!array_key_exists('activity', $join))
or (!array_key_exists('activity', $join))
) {
$qb->add(
'join',
@@ -102,10 +95,10 @@ class ActivityReasonFilter implements
$builder->add('reasons', EntityType::class, [
'class' => 'ChillActivityBundle:ActivityReason',
'choice_label' => static function (ActivityReason $reason) use ($helper) {
'choice_label' => function (ActivityReason $reason) use ($helper) {
return $helper->localize($reason->getName());
},
'group_by' => static function (ActivityReason $reason) use ($helper) {
'group_by' => function (ActivityReason $reason) use ($helper) {
return $helper->localize($reason->getCategory()->getName());
},
'multiple' => true,

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Entity\ActivityType;
@@ -27,11 +23,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class ActivityTypeFilter implements
ExportElementValidatedInterface,
FilterInterface
FilterInterface,
ExportElementValidatedInterface
{
/**
* @var TranslatableStringHelper
@@ -85,7 +79,7 @@ class ActivityTypeFilter implements
$builder->add('types', EntityType::class, [
'class' => ActivityType::class,
'choice_label' => static function (ActivityType $type) use ($helper) {
'choice_label' => function (ActivityType $type) use ($helper) {
return $helper->localize($type->getName());
},
'multiple' => true,

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -30,11 +26,9 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class PersonHavingActivityBetweenDateFilter implements
ExportElementValidatedInterface,
FilterInterface
FilterInterface,
ExportElementValidatedInterface
{
/**
* @var EntityRepository
@@ -151,7 +145,7 @@ class PersonHavingActivityBetweenDateFilter implements
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var \Symfony\Component\Form\FormInterface $filterForm */
/* @var $filterForm \Symfony\Component\Form\FormInterface */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
@@ -36,8 +32,6 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array;
class ActivityType extends AbstractType
{
/**
@@ -135,7 +129,7 @@ class ActivityType extends AbstractType
$builder->get('durationTime')
->addEventListener(
FormEvents::PRE_SET_DATA,
static function (FormEvent $formEvent) use (
function (FormEvent $formEvent) use (
$timeChoices,
$builder,
$durationTimeTransformer,
@@ -144,7 +138,7 @@ class ActivityType extends AbstractType
// set the timezone to GMT, and fix the difference between current and GMT
// the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new DateTimeZone('GMT');
/** @var DateTime $data */
/* @var $data \DateTime */
$data = $formEvent->getData() === null ?
DateTime::createFromFormat('U', 300) :
$formEvent->getData();
@@ -154,7 +148,7 @@ class ActivityType extends AbstractType
// test if the timestamp is in the choices.
// If not, recreate the field with the new timestamp
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
if (!in_array($data->getTimestamp(), $timeChoices)) {
// the data are not in the possible values. add them
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
$form = $builder->create(

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Chill\ActivityBundle\Entity\ActivityReason;
@@ -59,7 +55,7 @@ class TranslatableActivityReason extends AbstractType
return null;
},
'query_builder' => static function (EntityRepository $er) {
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('r')
->where('r.active = true');
},

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
@@ -41,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType
[
'class' => 'ChillActivityBundle:ActivityReasonCategory',
'choice_label' => 'name[' . $locale . ']',
'query_builder' => static function (EntityRepository $er) {
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.active = true');
},

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Form\Type;
use Chill\ActivityBundle\Entity\ActivityType;
@@ -42,7 +38,7 @@ class TranslatableActivityType extends AbstractType
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
/** @var \Doctrine\ORM\QueryBuilder $qb */
/* @var $qb \Doctrine\ORM\QueryBuilder */
$qb = $options['query_builder'];
if (true === $options['active_only']) {

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Menu;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -50,7 +46,7 @@ class MenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/** @var \Chill\PersonBundle\Entity\Person $person */
/* @var $person \Chill\PersonBundle\Entity\Person */
$person = $parameters['person'];
$user = $this->tokenStorage->getToken()->getUser();
$roleSee = new Role(ActivityVoter::SEE);

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Menu;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -41,7 +37,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/** @var \Chill\PersonBundle\Entity\Person $person */
/* @var $person \Chill\PersonBundle\Entity\Person */
$person = $parameters['person'];
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
@@ -309,31 +305,22 @@ class appDevDebugProjectContainer extends Container
];
}
/**
* {@inheritdoc}
*/
public function compile()
{
throw new LogicException('You cannot compile a dumped frozen container.');
}
/**
* {@inheritdoc}
*/
public function getParameter($name)
{
$name = strtolower($name);
if (!(isset($this->parameters[$name]) || \array_key_exists($name, $this->parameters))) {
if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
return $this->parameters[$name];
}
/**
* {@inheritdoc}
*/
public function getParameterBag()
{
if (null === $this->parameterBag) {
@@ -343,19 +330,13 @@ class appDevDebugProjectContainer extends Container
return $this->parameterBag;
}
/**
* {@inheritdoc}
*/
public function hasParameter($name)
{
$name = strtolower($name);
return isset($this->parameters[$name]) || \array_key_exists($name, $this->parameters);
return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
}
/**
* {@inheritdoc}
*/
public function setParameter($name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
@@ -4538,7 +4519,7 @@ class appDevDebugProjectContainer extends Container
$instance->addGlobal('app', $e);
$instance->addGlobal('installation', ['name' => 'Chill']);
$instance->addGlobal('available_languages', [0 => 'fr']);
\call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
return $instance;
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
@@ -23,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(\in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Security\Authorization;
use Chill\MainBundle\Entity\Center;
@@ -69,7 +65,7 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
{
if (
$subject instanceof Center
&& in_array($attribute, $this->getAttributes(), true)
&& in_array($attribute, $this->getAttributes())
) {
return true;
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Security\Authorization;
use Chill\ActivityBundle\Entity\Activity;
@@ -64,7 +60,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
protected function supports($attribute, $subject)
{
if ($subject instanceof Activity) {
return in_array($attribute, $this->getAttributes(), true);
return in_array($attribute, $this->getAttributes());
}
if ($subject instanceof Person) {
@@ -84,7 +80,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
if ($subject instanceof Person) {
$centers = $this->helper->getReachableCenters($token->getUser(), new Role($attribute));
return in_array($subject->getCenter(), $centers, true);
return in_array($subject->getCenter(), $centers);
}
/* @var $subject Activity */

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Templating\Entity;
use Chill\ActivityBundle\Entity\ActivityReason;

View File

@@ -1,31 +1,10 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
*
* 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 <http://www.gnu.org/licenses/>.
*/
namespace Chill\ActivityBundle\Test;

View File

@@ -1,33 +1,27 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Role\Role;
use function count;
use function in_array;
/**
* @internal
* @coversNothing
*/
final class ActivityControllerTest extends WebTestCase
class ActivityControllerTest extends WebTestCase
{
public function getSecuredPagesAuthenticated()
{
self::bootKernel();
static::bootKernel();
$person = $this->getPersonFromFixtures();
$activities = $this->getActivitiesForPerson($person);
@@ -63,7 +57,7 @@ final class ActivityControllerTest extends WebTestCase
*/
public function getSecuredPagesUnauthenticated()
{
self::bootKernel();
static::bootKernel();
$person = $this->getPersonFromFixtures();
$activities = $this->getActivitiesForPerson($person);
@@ -86,8 +80,8 @@ final class ActivityControllerTest extends WebTestCase
$client->request('GET', $url);
self::assertEquals(302, $client->getResponse()->getStatusCode());
self::assertTrue(
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertTrue(
$client->getResponse()->isRedirect('http://localhost/login'),
sprintf('the page "%s" does not redirect to http://localhost/login', $url)
);
@@ -103,7 +97,7 @@ final class ActivityControllerTest extends WebTestCase
{
$client->request('GET', $url);
self::assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
}
public function testCompleteScenario()
@@ -117,7 +111,7 @@ final class ActivityControllerTest extends WebTestCase
'en/person/%d/activity/',
$person->getId()
));
self::assertEquals(
$this->assertEquals(
200,
$client->getResponse()->getStatusCode(),
'Unexpected HTTP status code for GET /activity/'
@@ -142,11 +136,11 @@ final class ActivityControllerTest extends WebTestCase
$client->submit($form);
self::assertTrue($client->getResponse()->isRedirect());
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
// Check data in the show view
self::assertGreaterThan(
$this->assertGreaterThan(
0,
$crawler->filter('dd:contains("January 15, 2015")')->count(),
'Missing element dd:contains("January 15, 2015")'
@@ -164,17 +158,17 @@ final class ActivityControllerTest extends WebTestCase
$client->submit($form);
self::assertTrue($client->getResponse()->isRedirect());
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
// check that new data are present
self::assertGreaterThan(
$this->assertGreaterThan(
0,
$crawler->filter('dd:contains("January 25, 2015")')->count(),
'Missing element dd:contains("January 25, 2015")'
);
self::assertGreaterThan(
$this->assertGreaterThan(
0,
$crawler->filter('dd:contains("Foo")')->count(),
'Missing element dd:contains("Foo")'
@@ -188,14 +182,14 @@ final class ActivityControllerTest extends WebTestCase
$form = $button->form();
$client->submit($form);
self::assertTrue($client->getResponse()->isRedirect(sprintf(
$this->assertTrue($client->getResponse()->isRedirect(sprintf(
'/en/person/%d/activity/',
$person->getId()
)));
$crawler = $client->followRedirect();
self::assertNotContains('January 25, 2015', $crawler->text());
$this->assertNotContains('January 25, 2015', $crawler->text());
}
/**
@@ -206,7 +200,7 @@ final class ActivityControllerTest extends WebTestCase
*/
private function createFakeUser()
{
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$em = $container->get('doctrine.orm.entity_manager');
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
@@ -248,7 +242,7 @@ final class ActivityControllerTest extends WebTestCase
private function getActivitiesForPerson(\Chill\PersonBundle\Entity\Person $person)
{
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$activities = $em->getRepository('ChillActivityBundle:Activity')
@@ -269,7 +263,7 @@ final class ActivityControllerTest extends WebTestCase
*/
private function getAuthenticatedClient($username = 'center a_social')
{
return self::createClient([], [
return static::createClient([], [
'PHP_AUTH_USER' => $username,
'PHP_AUTH_PW' => 'password',
]);
@@ -280,7 +274,7 @@ final class ActivityControllerTest extends WebTestCase
*/
private function getPersonFromFixtures()
{
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$person = $em->getRepository('ChillPersonBundle:Person')
@@ -304,14 +298,14 @@ final class ActivityControllerTest extends WebTestCase
*/
private function getRandomActivityReason(array $excludeIds = [])
{
$reasons = self::$kernel->getContainer()
$reasons = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityReason')
->findAll();
$reason = $reasons[array_rand($reasons)];
if (in_array($reason->getId(), $excludeIds, true)) {
if (in_array($reason->getId(), $excludeIds)) {
return $this->getRandomActivityReason($excludeIds);
}
@@ -323,7 +317,7 @@ final class ActivityControllerTest extends WebTestCase
*/
private function getRandomActivityType()
{
$types = self::$kernel->getContainer()
$types = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillActivityBundle:ActivityType')
->findAll();
@@ -339,7 +333,7 @@ final class ActivityControllerTest extends WebTestCase
*/
private function getRandomScope($username, $centerName)
{
$user = self::$kernel->getContainer()
$user = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:User')
->findOneByUsername($username);
@@ -349,20 +343,20 @@ final class ActivityControllerTest extends WebTestCase
. 'does not exists in database. Did you add fixtures ?');
}
$center = self::$kernel->getContainer()
$center = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:Center')
->findOneByName($centerName);
// get scope reachable by both role UPDATE and DELETE
$reachableScopesUpdate = self::$kernel->getContainer()
$reachableScopesUpdate = static::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
new Role('CHILL_ACTIVITY_UPDATE'),
$center
);
$reachableScopesDelete = self::$kernel->getContainer()
$reachableScopesDelete = static::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
@@ -370,8 +364,8 @@ final class ActivityControllerTest extends WebTestCase
$center
);
$reachableScopesId = array_intersect(
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
);
if (count($reachableScopesId) === 0) {
@@ -380,7 +374,7 @@ final class ActivityControllerTest extends WebTestCase
}
foreach ($reachableScopesUpdate as $scope) {
if (in_array($scope->getId(), $reachableScopesId, true)) {
if (in_array($scope->getId(), $reachableScopesId)) {
$reachableScopes[] = $scope;
}
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
final class ActivityReasonCategoryControllerTest extends WebTestCase
class ActivityReasonCategoryControllerTest extends WebTestCase
{
public function testToWrite()
{
self::markTestSkipped();
$this->markTestSkipped();
}
/*

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
final class ActivityReasonControllerTest extends WebTestCase
class ActivityReasonControllerTest extends WebTestCase
{
public function testToWrite()
{
self::markTestSkipped();
$this->markTestSkipped();
}
/*

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
final class ActivityTypeControllerTest extends WebTestCase
class ActivityTypeControllerTest extends WebTestCase
{
public function testToWrite()
{
self::markTestSkipped();
$this->markTestSkipped();
}
/*

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
*/
private $aggregator;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
@@ -61,11 +57,11 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
*/
private $aggregator;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
@@ -60,11 +56,11 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Aggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
class ActivityUserAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
*/
private $aggregator;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
@@ -60,11 +56,11 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
final class CountActivityTest extends AbstractExportTest
class CountActivityTest extends AbstractExportTest
{
/**
* @var
*/
private $export;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.count_activity');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
final class ListActivityTest extends AbstractExportTest
class ListActivityTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\ListActivity
*/
private $export;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.list_activity');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
final class StatActivityDurationSumTest extends AbstractExportTest
class StatActivityDurationSumTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
*/
private $export;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.sum_activity_duration');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
@@ -20,18 +16,18 @@ use Doctrine\Common\Collections\ArrayCollection;
* @internal
* @coversNothing
*/
final class ActivityReasonFilterTest extends AbstractFilterTest
class ActivityReasonFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
*/
private $filter;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.reason_filter');
@@ -52,11 +48,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
public function getFormData()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$reasons = $em->createQuery('SELECT reason '
@@ -73,11 +69,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,38 +1,33 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use DateTime;
use function array_slice;
/**
* @internal
* @coversNothing
*/
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
*/
private $filter;
protected function setUp()
public function setUp()
{
self::bootKernel();
static::bootKernel();
$container = self::$kernel->getContainer();
$container = static::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.'
. 'person_having_an_activity_between_date_filter');
@@ -73,11 +68,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
$em = self::$kernel->getContainer()
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [
@@ -102,11 +97,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
*/
private function getActivityReasons()
{
if (null === self::$kernel) {
self::bootKernel();
if (null === static::$kernel) {
static::bootKernel();
}
return self::$kernel->getContainer()
return static::$kernel->getContainer()
->get('chill_activity.repository.reason')
->findAll();
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form;
use Chill\ActivityBundle\Entity\Activity;
@@ -25,7 +21,7 @@ use Symfony\Component\Security\Core\Role\Role;
* @internal
* @coversNothing
*/
final class ActivityTypeTest extends KernelTestCase
class ActivityTypeTest extends KernelTestCase
{
/**
* @var \Chill\MainBundle\Entity\Center
@@ -47,7 +43,7 @@ final class ActivityTypeTest extends KernelTestCase
*/
protected $user;
protected function setUp()
public function setUp()
{
self::bootKernel();
@@ -93,9 +89,9 @@ final class ActivityTypeTest extends KernelTestCase
$form->submit([]);
self::assertTrue($form->isSynchronized());
self::assertTrue($form->isValid());
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
$this->assertTrue($form->isSynchronized());
$this->assertTrue($form->isValid());
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
}
public function testFormSubmitting()
@@ -118,25 +114,25 @@ final class ActivityTypeTest extends KernelTestCase
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
// var_dump($form->getErrors());
self::assertTrue($form->isSynchronized(), 'Test the form is synchronized');
self::assertTrue($form->isValid(), 'test the form is valid');
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
$this->assertTrue($form->isSynchronized(), 'Test the form is synchronized');
$this->assertTrue($form->isValid(), 'test the form is valid');
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
// test the activity
/** @var Activity $activity */
/* @var $activity Activity */
$activity = $form->getData()['activity'];
self::assertEquals(
$this->assertEquals(
'09-03-2015',
$activity->getDate()->format('d-m-Y'),
'Test the date is correct'
);
self::assertEquals(
$this->assertEquals(
'00:05',
$activity->getDurationTime()->format('H:i'),
'Test the formatted hour is correct'
);
self::assertTrue($activity->getAttendee());
$this->assertEquals(true, $activity->getAttendee());
// $this->assertEquals('blabla', $activity->getRemark());
}
@@ -170,14 +166,14 @@ final class ActivityTypeTest extends KernelTestCase
'attendee' => true,
]]);
self::assertTrue($form->isSynchronized());
self::assertTrue($form->isValid());
$this->assertTrue($form->isSynchronized());
$this->assertTrue($form->isValid());
// test the activity
/** @var Activity $activity */
/* @var $activity Activity */
$activity = $form->getData()['activity'];
self::assertEquals(
$this->assertEquals(
'00:01',
$activity->getDurationTime()->format('H:i'),
'Test the formatted hour is correct'
@@ -186,14 +182,14 @@ final class ActivityTypeTest extends KernelTestCase
// test the view : we want to be sure that the entry with 60 seconds exists
$view = $form->createView();
self::assertTrue(isset($view['activity']['durationTime']));
$this->assertTrue(isset($view['activity']['durationTime']));
// map all the values in an array
$values = array_map(
static function ($choice) { return $choice->value; },
function ($choice) { return $choice->value; },
$view['activity']['durationTime']->vars['choices']
);
self::assertContains(60, $values);
$this->assertContains(60, $values);
}
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form\Type;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
@@ -24,14 +20,14 @@ use Symfony\Component\Form\Test\TypeTestCase;
* @internal
* @coversNothing
*/
final class TranslatableActivityReasonTest extends TypeTestCase
class TranslatableActivityReasonTest extends TypeTestCase
{
/**
* @var Prophecy\Prophet
*/
private static $prophet;
protected function setUp()
public function setUp()
{
parent::setUp();
}
@@ -42,7 +38,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
$this->getTranslatableStringHelper()
);
self::markTestSkipped('See issue 651');
$this->markTestSkipped('See issue 651');
}
/**
@@ -85,7 +81,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
$request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->getCurrentRequest()->will(static function () use ($request) {
$requestStack->getCurrentRequest()->will(function () use ($request) {
return $request;
});

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Form\Type;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
@@ -21,7 +17,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
* @internal
* @coversNothing
*/
final class TranslatableActivityTypeTest extends KernelTestCase
class TranslatableActivityTypeTest extends KernelTestCase
{
/**
* @var \Symfony\Component\Form\FormBuilderInterface
@@ -33,7 +29,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
*/
protected $container;
protected function setUp()
public function setUp()
{
self::bootKernel();
@@ -63,13 +59,13 @@ final class TranslatableActivityTypeTest extends KernelTestCase
'type' => $type->getId(),
]);
self::assertTrue($form->isSynchronized());
self::assertInstanceOf(
$this->assertTrue($form->isSynchronized());
$this->assertInstanceOf(
\Chill\ActivityBundle\Entity\ActivityType::class,
$form->getData()['type'],
'The data is an instance of Chill\\ActivityBundle\\Entity\\ActivityType'
);
self::assertEquals($type->getId(), $form->getData()['type']->getId());
$this->assertEquals($type->getId(), $form->getData()['type']->getId());
// test the ordering of the types in the form
// since 2016-11-14 the types are not alphabetically ordered, skipping

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Security\Authorization;
use Chill\ActivityBundle\Test\PrepareActivityTrait;
@@ -28,7 +24,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
* @internal
* @coversNothing
*/
final class ActivityVoterTest extends KernelTestCase
class ActivityVoterTest extends KernelTestCase
{
use PrepareActivityTrait;
use PrepareCenterTrait;
@@ -46,10 +42,10 @@ final class ActivityVoterTest extends KernelTestCase
*/
protected $voter;
protected function setUp()
public function setUp()
{
self::bootKernel();
$this->voter = self::$kernel->getContainer()
static::bootKernel();
$this->voter = static::$kernel->getContainer()
->get('chill.activity.security.authorization.activity_voter');
$this->prophet = new \Prophecy\Prophet();
}
@@ -115,7 +111,7 @@ final class ActivityVoterTest extends KernelTestCase
$scope = $this->prepareScope(1, 'default');
$activity = $this->prepareActivity($scope, $person);
self::assertEquals(
$this->assertEquals(
VoterInterface::ACCESS_DENIED,
$this->voter->vote($token, $activity, ['CHILL_ACTIVITY_SEE']),
'assert that a null user is not allowed to see'
@@ -140,7 +136,7 @@ final class ActivityVoterTest extends KernelTestCase
$token = $this->prepareToken($user);
$activity = $this->prepareActivity($scope, $this->preparePerson($center));
self::assertEquals(
$this->assertEquals(
$expectedResult,
$this->voter->vote($token, $activity, [$attribute]),
$message

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Timeline;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -19,10 +15,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
final class TimelineProviderTest extends WebTestCase
class TimelineProviderTest extends WebTestCase
{
public function testAnActivityIsShownOnTimeline()
{
self::markTestSkipped('we have to write fixtures before writing this tests');
$this->markTestSkipped('we have to write fixtures before writing this tests');
}
}

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Timeline;
use Chill\MainBundle\Entity\Scope;
@@ -24,8 +20,6 @@ use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use function count;
/**
* Provide activity for inclusion in timeline.
*/
@@ -64,9 +58,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
$this->user = $storage->getToken()->getUser();
}
/**
* {@inheritdoc}
*/
public function fetchQuery($context, array $args)
{
$this->checkContext($context);
@@ -89,9 +80,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
];
}
/**
* {@inheritdoc}
*/
public function getEntities(array $ids)
{
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
@@ -106,9 +94,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
return $result;
}
/**
* {@inheritdoc}
*/
public function getEntityTemplate($entity, $context, array $args)
{
$this->checkContext($context);
@@ -123,9 +108,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
];
}
/**
* {@inheritdoc}
*/
public function supportsType($type)
{
return 'activity' === $type;
@@ -189,7 +171,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
foreach ($reachableCenters as $center) {
$reachablesScopesId = array_map(
static function (Scope $scope) {
function (Scope $scope) {
return $scope->getId();
},
$this->helper->getReachableScopes(

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -24,7 +20,7 @@ class Version20150701091248 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0C59BB1592');
$this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2');
@@ -42,7 +38,7 @@ class Version20150701091248 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -24,7 +20,7 @@ class Version20150702093317 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN name;');
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;');
@@ -37,7 +33,7 @@ class Version20150702093317 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;');
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -24,7 +20,7 @@ class Version20150704091347 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark SET NOT NULL;');
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
@@ -33,7 +29,7 @@ class Version20150704091347 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark DROP NOT NULL;');
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
@@ -27,7 +23,7 @@ class Version20160222103457 extends AbstractMigration
public function down(Schema $schema): void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
'Migration can only be executed safely on \'postgresql\'.'
);
@@ -39,7 +35,7 @@ class Version20160222103457 extends AbstractMigration
// try to keep at least on activity reason...
$this->addSql(
'UPDATE activity
'UPDATE activity
SET reason_id=rid
FROM (
SELECT activity_id AS aid, MIN(activityreason_id) AS rid
@@ -54,7 +50,7 @@ class Version20160222103457 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
'Migration can only be executed safely on \'postgresql\'.'
);

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;

View File

@@ -1,12 +1,10 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);

View File

@@ -1,12 +1,10 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Calculator;
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;

View File

@@ -1,22 +1,20 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Calculator;
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
use OutOfBoundsException;
use function array_key_exists;
use function array_keys;
use function implode;
class CalculatorManager
{

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Calculator;
class CalculatorResult

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle;
use Chill\AMLI\BudgetBundle\DependencyInjection\Compiler\CalculatorCompilerPass;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Config;
class ConfigRepository

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Controller;
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
@@ -24,8 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use function get_class;
abstract class AbstractElementController extends Controller
{
/**
@@ -117,7 +111,7 @@ abstract class AbstractElementController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($form->isSubmitted() and $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->flush();
@@ -141,7 +135,7 @@ abstract class AbstractElementController extends Controller
*/
protected function _new(Person $person, Request $request, $template, $flashMessageOnSuccess)
{
/** @var \Chill\AMLI\BudgetBundle\Entity\AbstractElement $element */
/* @var $element \Chill\AMLI\BudgetBundle\Entity\AbstractElement */
$element = $this->createNewElement()
->setPerson($person);
@@ -152,7 +146,7 @@ abstract class AbstractElementController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($form->isSubmitted() and $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($element);
$em->flush();

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Controller;
use Chill\AMLI\BudgetBundle\Entity\Charge;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Controller;
use Chill\AMLI\BudgetBundle\Calculator\CalculatorManager;
@@ -25,7 +21,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
use function array_merge;
class ElementController extends Controller
{

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\Controller;
use Chill\AMLI\BudgetBundle\Entity\Resource;

View File

@@ -1,16 +1,12 @@
<?php
/**
* Chill is a software for social workers.
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\AMLI\BudgetBundle\DependencyInjection;
use Chill\AMLI\BudgetBundle\Security\Authorization\BudgetElementVoter;
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
@@ -54,7 +47,7 @@ class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInte
$this->prependRoutes($container);
}
/** (non-PHPdoc).
/* (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prependRoutes(ContainerBuilder $container)

Some files were not shown because too many files have changed in this diff Show More