fix conflicts when merging master

This commit is contained in:
nobohan 2022-01-04 15:56:32 +01:00
commit 52f817bde7
477 changed files with 6052 additions and 2047 deletions

View File

@ -60,7 +60,7 @@ code_style:
- bin - bin
- tests/app/vendor/ - tests/app/vendor/
sa_tests: phpstan_tests:
stage: Tests stage: Tests
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4 image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
script: script:
@ -71,6 +71,17 @@ sa_tests:
- bin - bin
- tests/app/vendor/ - tests/app/vendor/
psalm_tests:
stage: Tests
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
script:
- bin/grumphp run --tasks=psalm
artifacts:
expire_in: 30 min
paths:
- bin
- tests/app/vendor/
unit_tests: unit_tests:
stage: Tests stage: Tests
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4 image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
@ -79,7 +90,7 @@ unit_tests:
- php -d memory_limit=2G tests/app/bin/console cache:clear --env=dev - php -d memory_limit=2G tests/app/bin/console cache:clear --env=dev
- php -d memory_limit=3G tests/app/bin/console doctrine:fixtures:load -n - php -d memory_limit=3G tests/app/bin/console doctrine:fixtures:load -n
- php -d memory_limit=2G tests/app/bin/console cache:clear --env=test - php -d memory_limit=2G tests/app/bin/console cache:clear --env=test
- php -d memory_limit=3G bin/phpunit --colors=never - php -d memory_limit=4G bin/phpunit --colors=never
artifacts: artifacts:
expire_in: 30 min expire_in: 30 min
paths: paths:

View File

@ -18,12 +18,46 @@ and this project adheres to
* [household] household member editor: display alert if some members have already an household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#172) * [household] household member editor: display alert if some members have already an household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#172)
* [household] household member editor: do not add in new members if the member is included in the members of household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#123) * [household] household member editor: do not add in new members if the member is included in the members of household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#123)
* [household] household member editor: remove markNoAddress button (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109) * [household] household member editor: remove markNoAddress button (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109)
* [person]: ordering fields in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61)
* [person]: Add email and alt names in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61)
* AddAddress: optimize loading: wait for the user finish typing;
* UserPicker: fix bug with deprecated role
* docgen: add base context + tests
* docgen: add age for person
* [household menu] fix filiation order https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/265
* [AddAddress]: optimize loading: wait for the user finish typing;
* [UserPicker]: fix bug with deprecated role
* [docgen]: add base context + tests
* [docgen]: add age for person
* [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338)
* Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281)
* Household: show date validFrom and validTo when moving
* address reference: add index for refid
* [accompanyingCourse_work] fix styles conflicts + fix bug with remove goal (remove goals one at a time)
## Test releases
### test release 2021-12-14
* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262)
* [vendee/person] fix typo "situation professionelle" => "situation professionnelle"
* [main] add availableForUsers condition from locationType in the location API endpoint (champs-libres/departement-de-la-vendee/accent-suivi-developpement#248)
* [main] add the current location of the user as API point + add it in the activity location list (champs-libres/departement-de-la-vendee/accent-suivi-developpement#247)
* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl
* [badges] create specific badge for TMS, and make person/thirdparty badges clickable with on-the-fly modal in :
* concerned groups items (activity, calendar)
* accompanyingCourseWork lists
* accompanyingCourse lists
* [acompanyingCourse] add initial comment on Resume page
* [person] create button full width (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/330)
### test release 2021-12-11
* [main] add order field to civility
* [main] change address format in case the country is France, in Address render box and address normalizer * [main] change address format in case the country is France, in Address render box and address normalizer
* [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76) * [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76)
* [activity] fix visibility for location * [activity] fix visibility for location
* [origin] fix origin: use correctly the translatable strings * [origin] fix origin: use correctly the translatable strings
* /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');` * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');`
* [person] redirect bug fixed. * [person] redirect bug fixed.
* [action] add an unrelated issue within action creation. * [action] add an unrelated issue within action creation.
@ -36,8 +70,10 @@ and this project adheres to
* [person] show acceptSMS option (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) * [person] show acceptSMS option (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
* [person] add death information in person render box in twig and vue render boxes (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) * [person] add death information in person render box in twig and vue render boxes (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191)
* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262) * [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262)
* [vendee/person] fix typo "situation professionelle" => "situation professionnelle"
## Test releases * [accompanyingcourse_work] Changes in layout/behavior of edit form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/321)
* [badge-entity] design coherency between pills badge-person and 3 kinds of badge-thirdparty
* [AddPersons] suggestions row are clickable, not only checkbox
### test release 2021-12-06 ### test release 2021-12-06
@ -54,10 +90,6 @@ and this project adheres to
* [visgraph] improve and fix bugs on vis-network relationship graph * [visgraph] improve and fix bugs on vis-network relationship graph
* [bugfix] posting of birth- and deathdate through api fixed. * [bugfix] posting of birth- and deathdate through api fixed.
* [suggestions] improve suggestions lists * [suggestions] improve suggestions lists
* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty
* [AddPersons] suggestions row are clickable, not only checkbox
* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl
* [activity][calendar] concerned groups items are clickable with on-the-fly modal, create specific badge for TMS column
### Test release 2021-11-19 - bis ### Test release 2021-11-19 - bis

View File

@ -397,7 +397,6 @@ Créer une liste de suggestions à enlever (avec une croix rouge cliquable, l'an
<li> <li>
<span> <span>
item item
<a></a>
</span> </span>
</li> </li>
</ul> </ul>
@ -405,8 +404,8 @@ Créer une liste de suggestions à enlever (avec une croix rouge cliquable, l'an
Créer un titre enlevable (avec une croix rouge cliquable, l'ancre a est vide) Créer un titre enlevable (avec une croix rouge cliquable, l'ancre a est vide)
```html ```html
<div class="item-title"> <div class="item-title">
title <span>title</span>
<a></a>
</div> </div>
``` ```
Les classes `cols` ou `inline` peuvent être ajoutées à côté de `list-suggest` pour modifier la disposition de la liste. Les classes `cols` ou `inline` peuvent être ajoutées à côté de `list-suggest` pour modifier la disposition de la liste.
Dans le dernier exemple, on met une classe `removable` sur le span, si on veut pouvoir enlever l'élément.

View File

@ -1,55 +1,53 @@
{ {
"name": "chill-project/chill-bundles", "name": "chill-project/chill-bundles",
"type": "library",
"description": "Most used bundles for chill-project", "description": "Most used bundles for chill-project",
"license": "AGPL-3.0-only",
"type": "library",
"keywords": [ "keywords": [
"chill", "chill",
"social worker" "social worker"
], ],
"license": "AGPL-3.0-only",
"require": { "require": {
"champs-libres/async-uploader-bundle": "dev-sf4", "php": "^7.4",
"champs-libres/wopi-bundle": "dev-master", "champs-libres/async-uploader-bundle": "dev-sf4#d57134aee8e504a83c902ff0cf9f8d36ac418290",
"composer/package-versions-deprecated": "^1.10", "champs-libres/wopi-bundle": "dev-master#59b468503b9413f8d588ef9e626e7675560db3d8",
"champs-libres/wopi-lib": "dev-master#0e1da19bb6de820080b8651867a7e475be590060",
"doctrine/doctrine-bundle": "^2.1", "doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7", "doctrine/orm": "^2.7",
"erusev/parsedown": "^1.7", "erusev/parsedown": "^1.7",
"graylog2/gelf-php": "^1.5", "graylog2/gelf-php": "^1.5",
"knplabs/knp-menu": "^3.1",
"knplabs/knp-menu-bundle": "^3.0", "knplabs/knp-menu-bundle": "^3.0",
"knplabs/knp-time-bundle": "^1.12", "knplabs/knp-time-bundle": "^1.12",
"league/csv": "^9.7.1", "league/csv": "^9.7.1",
"nyholm/psr7": "^1.4", "nyholm/psr7": "^1.4",
"ocramius/package-versions": "^1.10",
"phpoffice/phpspreadsheet": "^1.16", "phpoffice/phpspreadsheet": "^1.16",
"ramsey/uuid-doctrine": "^1.7", "ramsey/uuid-doctrine": "^1.7",
"sensio/framework-extra-bundle": "^5.5", "sensio/framework-extra-bundle": "^5.5",
"spomky-labs/base64url": "^2.0", "spomky-labs/base64url": "^2.0",
"symfony/asset": "4.*", "symfony/asset": "^4.4",
"symfony/browser-kit": "^5.2", "symfony/browser-kit": "^4.4",
"symfony/css-selector": "^5.2", "symfony/css-selector": "^4.4",
"symfony/expression-language": "4.*", "symfony/expression-language": "^4.4",
"symfony/form": "4.*", "symfony/form": "^4.4",
"symfony/intl": "4.*", "symfony/framework-bundle": "^4.4",
"symfony/mime": "^4 || ^5", "symfony/intl": "^4.4",
"symfony/mime": "^4.4",
"symfony/monolog-bundle": "^3.5", "symfony/monolog-bundle": "^3.5",
"symfony/security-bundle": "4.*", "symfony/security-bundle": "^4.4",
"symfony/serializer": "^5.2", "symfony/serializer": "^5.3",
"symfony/swiftmailer-bundle": "^3.5", "symfony/swiftmailer-bundle": "^3.5",
"symfony/templating": "4.*", "symfony/templating": "^4.4",
"symfony/translation": "4.*", "symfony/translation": "^4.4",
"symfony/twig-bundle": "^4.4", "symfony/twig-bundle": "^4.4",
"symfony/validator": "4.*", "symfony/validator": "^4.4",
"symfony/webpack-encore-bundle": "^1.11", "symfony/webpack-encore-bundle": "^1.11",
"symfony/workflow": "4.*", "symfony/workflow": "^4.4",
"symfony/yaml": "4.*", "symfony/yaml": "^4.4",
"twig/extra-bundle": "^2.12 || ^3.0", "twig/extra-bundle": "^3.0",
"twig/intl-extra": "^3.0", "twig/intl-extra": "^3.0",
"twig/markdown-extra": "^3.3", "twig/markdown-extra": "^3.3"
"twig/twig": "^2.12 || ^3.0"
},
"conflict": {
"symfony/symfony": "*"
}, },
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", "doctrine/doctrine-fixtures-bundle": "^3.3",
@ -57,18 +55,17 @@
"fakerphp/faker": "^1.13", "fakerphp/faker": "^1.13",
"nelmio/alice": "^3.8", "nelmio/alice": "^3.8",
"phpstan/phpstan-strict-rules": "^1.0", "phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^7.0", "phpunit/phpunit": ">= 7.5",
"symfony/debug-bundle": "^5.1", "symfony/debug-bundle": "^5.1",
"symfony/dotenv": "^5.1", "symfony/dotenv": "^4.4",
"symfony/maker-bundle": "^1.20", "symfony/maker-bundle": "^1.20",
"symfony/phpunit-bridge": "^5.2", "symfony/phpunit-bridge": "^4.4",
"symfony/stopwatch": "^5.1", "symfony/stopwatch": "^4.4",
"symfony/var-dumper": "4.*", "symfony/var-dumper": "^4.4",
"symfony/web-profiler-bundle": "^5.0" "symfony/web-profiler-bundle": "^4.4"
}, },
"config": { "conflict": {
"bin-dir": "bin", "symfony/symfony": "*"
"vendor-dir": "tests/app/vendor"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -95,8 +92,19 @@
"Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests" "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests"
} }
}, },
"minimum-stability": "dev", "config": {
"prefer-stable": true, "allow-plugins": {
"composer/package-versions-deprecated": true,
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true,
"phpro/grumphp": true,
"ocramius/package-versions": true
},
"bin-dir": "bin",
"optimize-autoloader": true,
"sort-packages": true,
"vendor-dir": "tests/app/vendor"
},
"scripts": { "scripts": {
"auto-scripts": { "auto-scripts": {
"cache:clear": "symfony-cmd", "cache:clear": "symfony-cmd",

View File

@ -91,7 +91,9 @@ class CountPerson implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
// we gather all center the user choose. // we gather all center the user choose.
$centers = array_map(static function ($el) { return $el['center']; }, $acl); $centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder(); $qb = $this->entityManager->createQueryBuilder();

View File

@ -11,53 +11,53 @@ declare(strict_types=1);
namespace Chill\MainBundle\DependencyInjection; namespace Chill\MainBundle\DependencyInjection;
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait; use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
/** /**
* Configure the main bundle. * Configure the main bundle.
*/ */
class ChillMainConfiguration implements ConfigurationInterface class ChillMainConfiguration implements ConfigurationInterface
{ {
use AddWidgetConfigurationTrait; use AddWidgetConfigurationTrait;
/** /**
* @var ContainerBuilder * @var ContainerBuilder
*/ */
private $containerBuilder; private $containerBuilder;
public function __construct( public function __construct(
array $widgetFactories, array $widgetFactories,
ContainerBuilder $containerBuilder ContainerBuilder $containerBuilder
) { ) {
// we register here widget factories (see below) // we register here widget factories (see below)
$this->setWidgetFactories($widgetFactories); $this->setWidgetFactories($widgetFactories);
// we will need the container builder later... // we will need the container builder later...
$this->containerBuilder = $containerBuilder; $this->containerBuilder = $containerBuilder;
} }
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('chill_main'); $rootNode = $treeBuilder->root('chill_main');
$rootNode $rootNode
->children() ->children()
// ... // ...
->arrayNode('widgets') ->arrayNode('widgets')
->canBeDisabled() ->canBeDisabled()
->children() ->children()
// we declare here all configuration for homepage place // we declare here all configuration for homepage place
->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder)) ->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder))
->end() // end of widgets/children ->end() // end of widgets/children
->end() // end of widgets ->end() // end of widgets
->end() // end of root/children ->end() // end of root/children
->end() // end of root ->end() // end of root
; ;
return $treeBuilder; return $treeBuilder;
} }
} }

View File

@ -12,3 +12,28 @@ parameters:
tasks.phpcsfixer.allow_risky: true tasks.phpcsfixer.allow_risky: true
tasks.phpcsfixer.diff: true tasks.phpcsfixer.diff: true
tasks.phpstan.level: 1 tasks.phpstan.level: 1
tasks.phpstan.blocking: true
tasks.phpstan.ignore_patterns:
- "/.github/"
- "/.idea/"
- "/build/"
- "/benchmarks/"
- "/docs/"
- "/node_modules/"
- "/resource/"
- "/spec/"
- "/var/"
- "/vendor/"
# Psalm
tasks.psalm.blocking: true
tasks.psalm.ignore_patterns:
- "/.github/"
- "/.idea/"
- "/build/"
- "/benchmarks/"
- "/node_modules/"
- "/resource/"
- "/spec/"
- "/var/"
- "/vendor/"

View File

@ -417,15 +417,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
-
message:
"""
#^Instantiation of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\:
since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$#
"""
count: 3
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
- -
message: message:
""" """
@ -435,15 +426,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php path: src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php
-
message:
"""
#^Fetching class constant class of deprecated class Symfony\\\\Component\\\\Security\\\\Core\\\\Role\\\\Role\\:
since Symfony 4\\.3, to be removed in 5\\.0\\. Use strings as roles instead\\.$#
"""
count: 1
path: src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php
- -
message: message:
""" """
@ -877,11 +859,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
-
message: "#^Call to deprecated method setTimeout\\(\\) of class Redis\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php
- -
message: message:
""" """

View File

@ -2,10 +2,11 @@
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html --> <!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="tests/app/vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
colors="true" colors="true"
bootstrap="tests/app/tests/bootstrap.php" bootstrap="tests/app/tests/bootstrap.php"
stopOnFailure="true"
> >
<php> <php>
<ini name="error_reporting" value="-1" /> <ini name="error_reporting" value="-1" />

2006
psalm-baseline.xml Normal file

File diff suppressed because it is too large Load Diff

16
psalm.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config tests/app/vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="./tests/" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@ -39,6 +39,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use function array_key_exists; use function array_key_exists;
final class ActivityController extends AbstractController final class ActivityController extends AbstractController
@ -307,8 +308,10 @@ final class ActivityController extends AbstractController
$activityData = $request->query->get('activityData'); $activityData = $request->query->get('activityData');
} }
if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType if (
|| !$activityType->isActive()) { !$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType
|| !$activityType->isActive()
) {
$params = $this->buildParamsToUrl($person, $accompanyingPeriod); $params = $this->buildParamsToUrl($person, $accompanyingPeriod);
if (null !== $activityData) { if (null !== $activityData) {

View File

@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReasonCategory; use Chill\ActivityBundle\Entity\ActivityReasonCategory;
use Chill\ActivityBundle\Form\ActivityReasonCategoryType; use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Form\ActivityReasonType; use Chill\ActivityBundle\Form\ActivityReasonType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@ -19,6 +19,7 @@ use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use function in_array; use function in_array;
/** /**

View File

@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int; use function is_int;
/** /**

View File

@ -25,6 +25,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists; use function array_key_exists;
use function count; use function count;

View File

@ -27,6 +27,7 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists; use function array_key_exists;
use function count; use function count;
use function in_array; use function in_array;
@ -189,7 +190,9 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static function ($el) { return $el['center']; }, $acl); $centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
// throw an error if any fields are present // throw an error if any fields are present
if (!array_key_exists('fields', $data)) { if (!array_key_exists('fields', $data)) {

View File

@ -25,6 +25,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists; use function array_key_exists;
use function count; use function count;

View File

@ -24,6 +24,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count; use function count;
class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface

View File

@ -31,6 +31,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count; use function count;
class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface

View File

@ -48,6 +48,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array; use function in_array;
class ActivityType extends AbstractType class ActivityType extends AbstractType

View File

@ -36,8 +36,10 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{ {
$period = $parameters['accompanyingCourse']; $period = $parameters['accompanyingCourse'];
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep() if (
&& $this->security->isGranted(ActivityVoter::SEE, $period)) { AccompanyingPeriod::STEP_DRAFT !== $period->getStep()
&& $this->security->isGranted(ActivityVoter::SEE, $period)
) {
$menu->addChild($this->translator->trans('Activity'), [ $menu->addChild($this->translator->trans('Activity'), [
'route' => 'chill_activity_activity_list', 'route' => 'chill_activity_activity_list',
'routeParameters' => [ 'routeParameters' => [

View File

@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use function in_array; use function in_array;
final class AdminMenuBuilder implements LocalMenuBuilderInterface final class AdminMenuBuilder implements LocalMenuBuilderInterface

View File

@ -22,6 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use function count; use function count;
use function in_array; use function in_array;
@ -167,7 +168,9 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center); $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
// we get the ids for those scopes // we get the ids for those scopes
$reachablesScopesId = array_map( $reachablesScopesId = array_map(
static function (Scope $scope) { return $scope->getId(); }, static function (Scope $scope) {
return $scope->getId();
},
$reachableScopes $reachableScopes
); );

View File

@ -17,6 +17,14 @@ const getLocations = () => fetchResults('/api/1.0/main/location.json');
const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json'); const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json');
const getUserCurrentLocation =
() => fetch('/api/1.0/main/user-current-location.json')
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
/* /*
* Load Location Type by defaultFor * Load Location Type by defaultFor
* @param {string} entity - can be "person" or "thirdparty" * @param {string} entity - can be "person" or "thirdparty"
@ -48,5 +56,6 @@ export {
getLocations, getLocations,
getLocationTypes, getLocationTypes,
getLocationTypeByDefaultFor, getLocationTypeByDefaultFor,
postLocation postLocation,
getUserCurrentLocation
}; };

View File

@ -1,8 +1,7 @@
<template> <template>
<li> <li>
<span :title="person.text"> <span :title="person.text">
<span class="chill_denomination">{{ textCutted }}</span> <span class="chill_denomination" @click.prevent="$emit('remove', person)">{{ textCutted }}</span>
<a @click.prevent="$emit('remove', person)"></a>
</span> </span>
</li> </li>
</template> </template>

View File

@ -15,7 +15,7 @@
:searchable="true" :searchable="true"
:placeholder="$t('activity.choose_location')" :placeholder="$t('activity.choose_location')"
:custom-label="customLabel" :custom-label="customLabel"
:options="locations" :options="availableLocations"
group-values="locations" group-values="locations"
group-label="locationGroup" group-label="locationGroup"
v-model="location" v-model="location"
@ -32,7 +32,7 @@
import { mapState, mapGetters } from "vuex"; import { mapState, mapGetters } from "vuex";
import VueMultiselect from "vue-multiselect"; import VueMultiselect from "vue-multiselect";
import NewLocation from "./Location/NewLocation.vue"; import NewLocation from "./Location/NewLocation.vue";
import { getLocations, getLocationTypeByDefaultFor } from "../api.js"; import { getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation } from "../api.js";
export default { export default {
name: "Location", name: "Location",
@ -40,13 +40,8 @@ export default {
NewLocation, NewLocation,
VueMultiselect, VueMultiselect,
}, },
data() {
return {
locations: [],
};
},
computed: { computed: {
...mapState(["activity"]), ...mapState(["activity", "availableLocations"]),
...mapGetters(["suggestedEntities"]), ...mapGetters(["suggestedEntities"]),
location: { location: {
get() { get() {
@ -57,53 +52,6 @@ export default {
}, },
}, },
}, },
mounted() {
getLocations().then(
(results) => {
getLocationTypeByDefaultFor('person').then(
(personLocationType) => {
if (personLocationType) {
const personLocation = this.makeAccompanyingPeriodLocation(personLocationType);
const concernedPersonsLocation =
this.makeConcernedPersonsLocation(personLocationType);
getLocationTypeByDefaultFor('thirdparty').then(
thirdpartyLocationType => {
const concernedThirdPartiesLocation =
this.makeConcernedThirdPartiesLocation(thirdpartyLocationType);
this.locations = [
{
locationGroup: 'Localisation du parcours',
locations: [personLocation]
},
{
locationGroup: 'Parties concernées',
locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation]
},
{
locationGroup: 'Autres localisations',
locations: results
}
];
}
)
} else {
this.locations = [
{
locationGroup: 'Localisations',
locations: response.results
}
];
}
if (window.default_location_id) {
let location = this.locations.filter(
(l) => l.id === window.default_location_id
);
this.$store.dispatch("updateLocation", location);
}
}
)
})
},
methods: { methods: {
labelAccompanyingCourseLocation(value) { labelAccompanyingCourseLocation(value) {
return `${value.address.text} (${value.locationType.title.fr})` return `${value.address.text} (${value.locationType.title.fr})`
@ -117,58 +65,6 @@ export default {
: value.locationType.title.fr : value.locationType.title.fr
: ''; : '';
}, },
makeConcernedPersonsLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
id: e.current_household_address.address_id,
},
locationType: locationType
});
}
}
)
return locations;
},
makeConcernedThirdPartiesLocation(locationType) {
let locations = [];
this.suggestedEntities.forEach(
(e) => {
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -this.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
locationType: locationType
});
}
}
)
return locations;
},
makeAccompanyingPeriodLocation(locationType) {
const accPeriodLocation = this.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {
id: accPeriodLocation.address_id,
text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}`
},
locationType: locationType
}
}
}, },
}; };
</script> </script>

View File

@ -1,6 +1,7 @@
import 'es6-promise/auto'; import 'es6-promise/auto';
import { createStore } from 'vuex'; import { createStore } from 'vuex';
import { postLocation } from './api'; import { postLocation } from './api';
import prepareLocations from './store.locations.js';
const debug = process.env.NODE_ENV !== 'production'; const debug = process.env.NODE_ENV !== 'production';
//console.log('window.activity', window.activity); //console.log('window.activity', window.activity);
@ -25,6 +26,7 @@ const store = createStore({
activity: window.activity, activity: window.activity,
socialIssuesOther: [], socialIssuesOther: [],
socialActionsList: [], socialActionsList: [],
availableLocations: [],
}, },
getters: { getters: {
suggestedEntities(state) { suggestedEntities(state) {
@ -200,6 +202,9 @@ const store = createStore({
console.log("### mutation: updateLocation", value); console.log("### mutation: updateLocation", value);
state.activity.location = value; state.activity.location = value;
}, },
addAvailableLocationGroup(state, group) {
state.availableLocations.push(group);
}
}, },
actions: { actions: {
addIssueSelected({ commit }, issue) { addIssueSelected({ commit }, issue) {
@ -335,4 +340,6 @@ const store = createStore({
}, },
}); });
prepareLocations(store);
export default store; export default store;

View File

@ -0,0 +1,123 @@
import {getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation} from "./api";
const makeConcernedPersonsLocation = (locationType, store) => {
let locations = [];
store.getters.suggestedEntities.forEach(
(e) => {
if (e.type === 'person' && e.current_household_address !== null){
locations.push({
type: 'location',
id: -store.getters.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: {
id: e.current_household_address.address_id,
},
locationType: locationType
});
}
}
)
return locations;
};
const makeConcernedThirdPartiesLocation = (locationType, store) => {
let locations = [];
store.getters.suggestedEntities.forEach(
(e) => {
if (e.type === 'thirdparty' && e.address !== null){
locations.push({
type: 'location',
id: -store.getters.suggestedEntities.indexOf(e)*10,
onthefly: true,
name: e.text,
address: { id: e.address.address_id },
locationType: locationType
});
}
}
)
return locations;
};
const makeAccompanyingPeriodLocation = (locationType, store) => {
const accPeriodLocation = store.state.activity.accompanyingPeriod.location;
return {
type: 'location',
id: -1,
onthefly: true,
name: '__AccompanyingCourseLocation__',
address: {
id: accPeriodLocation.address_id,
text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}`
},
locationType: locationType
}
};
export default function prepareLocations(store) {
// find the locations
let allLocations = getLocations().then(
(results) => {
store.commit('addAvailableLocationGroup', {
locationGroup: 'Autres localisations',
locations: results
});
}
);
let currentLocation = getUserCurrentLocation().then(
userCurrentLocation => {
if (null !== userCurrentLocation) {
store.commit('addAvailableLocationGroup', {
locationGroup: 'Ma localisation',
locations: [userCurrentLocation]
});
}
}
);
let partiesLocations = [], partyPromise;
['person', 'thirdparty'].forEach(kind => {
partyPromise = getLocationTypeByDefaultFor(kind).then(
(kindLocationType) => {
if (kindLocationType) {
let concernedKindLocations;
if (kind === 'person') {
concernedKindLocations = makeConcernedPersonsLocation(kindLocationType, store);
// add location for the parcours into suggestions
const personLocation = makeAccompanyingPeriodLocation(kindLocationType, store);
store.commit('addAvailableLocationGroup', {
locationGroup: 'Localisation du parcours',
locations: [personLocation]
});
} else {
concernedKindLocations = makeConcernedThirdPartiesLocation(kindLocationType, store);
}
store.commit('addAvailableLocationGroup', {
locationGroup: kind === 'person' ? 'Usagers concernés' : 'Tiers concernés',
locations: concernedKindLocations,
});
}
}
);
partiesLocations.push(partyPromise);
});
// when all location are loaded
Promise.all([allLocations, currentLocation, ...partiesLocations]).then(() => {
console.log('current location in activity', store.state.activity.location);
console.log('default loation id', window.default_location_id);
if (window.default_location_id) {
for (let group of store.state.availableLocations) {
console.log(group);
let location = group.locations.find((l) => l.id === window.default_location_id);
console.log(location);
if (location !== undefined) {
store.dispatch('updateLocation', location);
break;
}
}
}
});
}

View File

@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\Request;
// This check prevents access to debug front controllers that are deployed by accident to production servers. // This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || 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'], true) || \PHP_SAPI === 'cli-server')
) { ) {

View File

@ -127,24 +127,25 @@
</div> </div>
{% endif %} {% endif %}
{% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
<div class="wl-row">
<div class="wl-col title">
<h3>{{ 'Comment'|trans }}</h3>
</div>
<div class="wl-col list">
{{ activity.comment|chill_entity_render_box({
'disable_markdown': false,
'limit_lines': 3,
'metadata': false
}) }}
</div>
</div>
{% endif %}
{# Only if ACL SEE_DETAILS AND/OR only on template SHOW ?? {# Only if ACL SEE_DETAILS AND/OR only on template SHOW ??
durationTime durationTime
travelTime travelTime
comment comment
{% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
<div class="wl-row">
<div class="wl-col title">
<h3>{{ 'Comment'|trans }}</h3>
</div>
<div class="wl-col list">
{{ activity.comment|chill_entity_render_box({
'disable_markdown': false,
'limit_lines': 3,
'metadata': false
}) }}
</div>
</div>
{% endif %}
documents documents
attendee attendee
#} #}

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use function in_array; use function in_array;
class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
@ -64,8 +65,10 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
protected function supports($attribute, $subject) protected function supports($attribute, $subject)
{ {
if ($subject instanceof Center if (
&& in_array($attribute, $this->getAttributes(), true)) { $subject instanceof Center
&& in_array($attribute, $this->getAttributes(), true)
) {
return true; return true;
} }

View File

@ -24,6 +24,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use RuntimeException; use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use function in_array; use function in_array;
class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface

View File

@ -26,7 +26,7 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
*/ */
private $aggregator; private $aggregator;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -26,7 +26,7 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
*/ */
private $aggregator; private $aggregator;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -26,7 +26,7 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest
*/ */
private $aggregator; private $aggregator;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -24,7 +24,7 @@ final class CountActivityTest extends AbstractExportTest
*/ */
private $export; private $export;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -24,7 +24,7 @@ final class ListActivityTest extends AbstractExportTest
*/ */
private $export; private $export;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -26,7 +26,7 @@ final class StatActivityDurationSumTest extends AbstractExportTest
*/ */
private $export; private $export;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -25,7 +25,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
*/ */
private $filter; private $filter;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -26,7 +26,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
*/ */
private $filter; private $filter;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -45,7 +45,7 @@ final class ActivityTypeTest extends KernelTestCase
*/ */
protected $user; protected $user;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -29,7 +29,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
*/ */
private static $prophet; private static $prophet;
public function setUp() protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
} }

View File

@ -31,7 +31,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
*/ */
protected $container; protected $container;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -44,7 +44,7 @@ final class ActivityVoterTest extends KernelTestCase
*/ */
protected $voter; protected $voter;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->voter = self::$kernel->getContainer() $this->voter = self::$kernel->getContainer()

View File

@ -24,6 +24,7 @@ use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use function implode; use function implode;
use function in_array; use function in_array;
use function strtr; use function strtr;

View File

@ -17,6 +17,7 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function array_merge; use function array_merge;
use function count; use function count;

View File

@ -13,6 +13,7 @@ namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
use function count; use function count;
/** /**

View File

@ -19,6 +19,7 @@ use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use function random_int; use function random_int;
class LoadAsideActivity extends Fixture implements DependentFixtureInterface class LoadAsideActivity extends Fixture implements DependentFixtureInterface

View File

@ -18,10 +18,12 @@ class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
foreach ([ foreach (
'Appel téléphonique', [
'Formation', 'Appel téléphonique',
] as $key => $label) { 'Formation',
] as $key => $label
) {
$category = new AsideActivityCategory(); $category = new AsideActivityCategory();
$category->setTitle(['fr' => $label]); $category->setTitle(['fr' => $label]);
$manager->persist($category); $manager->persist($category);

View File

@ -13,6 +13,7 @@ namespace Chill\AsideActivityBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
use function is_int; use function is_int;
class Configuration implements ConfigurationInterface class Configuration implements ConfigurationInterface

View File

@ -32,6 +32,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array; use function in_array;
final class AsideActivityFormType extends AbstractType final class AsideActivityFormType extends AbstractType

View File

@ -13,6 +13,7 @@ namespace Chill\AsideActivityBundle\Menu;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use function in_array; use function in_array;
final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface

View File

@ -26,7 +26,7 @@ final class AsideActivityControllerTest extends WebTestCase
{ {
use PrepareClientTrait; use PrepareClientTrait;
public function setUp() protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
self::bootKernel(); self::bootKernel();

View File

@ -13,6 +13,7 @@ namespace Chill\AMLI\BudgetBundle\Calculator;
use Chill\AMLI\BudgetBundle\Entity\AbstractElement; use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
use OutOfBoundsException; use OutOfBoundsException;
use function array_key_exists; use function array_key_exists;
use function array_keys; use function array_keys;
use function implode; use function implode;

View File

@ -21,6 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use function get_class; use function get_class;
abstract class AbstractElementController extends Controller abstract class AbstractElementController extends Controller

View File

@ -22,6 +22,7 @@ use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use function array_merge; use function array_merge;
use function count; use function count;

View File

@ -21,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_flip; use function array_flip;
use function asort; use function asort;

View File

@ -21,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_flip; use function array_flip;
class ResourceType extends AbstractType class ResourceType extends AbstractType

View File

@ -18,6 +18,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use function in_array; use function in_array;
class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface

View File

@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use function count; use function count;
class CalendarRangeAPIController extends ApiController class CalendarRangeAPIController extends ApiController

View File

@ -28,6 +28,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata;
use function in_array; use function in_array;
/** /**

View File

@ -14,6 +14,7 @@ namespace Chill\CalendarBundle\Event;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Doctrine\Persistence\Event\LifecycleEventArgs; use Doctrine\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use function array_key_exists; use function array_key_exists;
class ListenToActivityCreate class ListenToActivityCreate

View File

@ -20,7 +20,6 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\CommentType;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable; use DateTimeImmutable;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;

View File

@ -1,6 +1,10 @@
import 'es6-promise/auto'; import 'es6-promise/auto';
import { createStore } from 'vuex'; import { createStore } from 'vuex';
import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api'; import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api';
import {
getLocations, getLocationTypeByDefaultFor,
getUserCurrentLocation
} from "../../../../../ChillActivityBundle/Resources/public/vuejs/Activity/api";
const debug = process.env.NODE_ENV !== 'production'; const debug = process.env.NODE_ENV !== 'production';
@ -217,9 +221,7 @@ const store = createStore({
hiddenLocation.value = value.id; hiddenLocation.value = value.id;
} }
commit("updateLocation", value); commit("updateLocation", value);
} }
} }
}); });

View File

@ -92,8 +92,11 @@
%} %}
<div class="item-row details"> <div class="item-row details">
<div class="item-col"> <div class="item-col">
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': accompanyingCourse, 'with_display': 'row', 'entity': calendar } %} 'context': accompanyingCourse,
'with_display': 'row',
'entity': calendar
} %}
</div> </div>
{% if calendar.comment.comment is not empty %} {% if calendar.comment.comment is not empty %}

View File

@ -26,7 +26,7 @@ final class CalendarControllerTest extends WebTestCase
/** /**
* Setup before each test method (see phpunit doc). * Setup before each test method (see phpunit doc).
*/ */
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->client = self::createClient([], [ $this->client = self::createClient([], [

View File

@ -25,6 +25,7 @@ use Symfony\Component\Console\Question\Question;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Parser;
use function count; use function count;
/** /**

View File

@ -23,6 +23,7 @@ use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists; use function array_key_exists;
use function count; use function count;
use function in_array; use function in_array;

View File

@ -135,7 +135,7 @@ class CustomFieldDate extends AbstractCustomField
return null; return null;
} }
return $date->format('Y-m-d'); return $date->format('Y-m-d');
default: default:
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.' $template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.'

View File

@ -21,6 +21,7 @@ use LogicException;
use Symfony\Bridge\Twig\TwigEngine; use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use function get_class; use function get_class;
use function gettype; use function gettype;
use function is_object; use function is_object;

View File

@ -18,7 +18,6 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\LessThanOrEqual; use Symfony\Component\Validator\Constraints\LessThanOrEqual;

View File

@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use function array_key_exists; use function array_key_exists;
class CustomFieldText extends AbstractCustomField class CustomFieldText extends AbstractCustomField
@ -65,8 +66,10 @@ class CustomFieldText extends AbstractCustomField
$attrArray = []; $attrArray = [];
if (array_key_exists(self::MULTIPLE_CF_INLINE, $options) if (
&& $options[self::MULTIPLE_CF_INLINE]) { array_key_exists(self::MULTIPLE_CF_INLINE, $options)
&& $options[self::MULTIPLE_CF_INLINE]
) {
$attrArray['class'] = 'multiple-cf-inline'; $attrArray['class'] = 'multiple-cf-inline';
} }

View File

@ -20,6 +20,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use function count; use function count;
class CustomFieldsGroupType extends AbstractType class CustomFieldsGroupType extends AbstractType

View File

@ -15,6 +15,7 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\Exception\TransformationFailedException;
use function gettype; use function gettype;
class CustomFieldsGroupToIdTransformer implements DataTransformerInterface class CustomFieldsGroupToIdTransformer implements DataTransformerInterface

View File

@ -14,7 +14,9 @@ namespace Chill\CustomFieldsBundle\Form\DataTransformer;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\DataTransformerInterface;
use function array_key_exists; use function array_key_exists;
use const JSON_THROW_ON_ERROR; use const JSON_THROW_ON_ERROR;
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
@ -33,7 +35,9 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
// @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here?
$customFieldsLablels = array_map( $customFieldsLablels = array_map(
static function ($e) { return $e->getLabel(); }, static function ($e) {
return $e->getLabel();
},
$customFields $customFields
); );

View File

@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_key_exists; use function array_key_exists;
/** /**

View File

@ -17,7 +17,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
class ChoicesListType extends AbstractType class ChoicesListType extends AbstractType

View File

@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\Request;
// This check prevents access to debug front controllers that are deployed by accident to production servers. // This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || 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'], true) || \PHP_SAPI === 'cli-server')
) { ) {

View File

@ -37,7 +37,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase
*/ */
private $cfProvider; private $cfProvider;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
@ -46,7 +46,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase
$this->cfChoice = $this->cfProvider->getCustomFieldByType('choice'); $this->cfChoice = $this->cfProvider->getCustomFieldByType('choice');
} }
public function tearDown() protected function tearDown(): void
{ {
parent::tearDown(); parent::tearDown();
} }

View File

@ -34,7 +34,7 @@ final class CustomFieldsNumberTest extends \Symfony\Bundle\FrameworkBundle\Test\
*/ */
private $formBuilder; private $formBuilder;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -28,7 +28,7 @@ final class CustomFieldsTextTest extends WebTestCase
*/ */
private $customFieldProvider; private $customFieldProvider;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->customFieldProvider = self::$kernel->getContainer() $this->customFieldProvider = self::$kernel->getContainer()

View File

@ -27,7 +27,7 @@ final class PostTextIntegerExtensionTest extends KernelTestCase
*/ */
private $formBuilder; private $formBuilder;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -27,7 +27,7 @@ final class PostTextNumberExtensionTest extends KernelTestCase
*/ */
private $formBuilder; private $formBuilder;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -33,7 +33,7 @@ final class CustomFieldsHelperTest extends KernelTestCase
*/ */
private $randomCFText; private $randomCFText;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();

View File

@ -34,7 +34,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase
*/ */
private $cfRendering; private $cfRendering;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->cfRendering = self::$kernel->getContainer() $this->cfRendering = self::$kernel->getContainer()

View File

@ -36,7 +36,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase
*/ */
private $cfRendering; private $cfRendering;
public function setUp() protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->cfRendering = self::$kernel->getContainer() $this->cfRendering = self::$kernel->getContainer()

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Context\Exception; namespace Chill\DocGeneratorBundle\Context\Exception;
use LogicException; use LogicException;
use function get_class; use function get_class;
use function gettype; use function gettype;
use function is_object; use function is_object;

View File

@ -28,12 +28,10 @@ use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Exception\TransferException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
// TODO à mettre dans services // TODO à mettre dans services
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
@ -42,7 +40,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
@ -206,8 +203,10 @@ final class DocGeneratorTemplateController extends AbstractController
$contextGenerationData = []; $contextGenerationData = [];
if ($context instanceof DocGeneratorContextWithPublicFormInterface if (
&& $context->hasPublicForm($template, $entity) || $isTest) { $context instanceof DocGeneratorContextWithPublicFormInterface
&& $context->hasPublicForm($template, $entity) || $isTest
) {
if ($context instanceof DocGeneratorContextWithPublicFormInterface) { if ($context instanceof DocGeneratorContextWithPublicFormInterface) {
$builder = $this->createFormBuilder( $builder = $this->createFormBuilder(
array_merge( array_merge(

View File

@ -54,8 +54,10 @@ class DocGeneratorTemplateType extends AbstractType
'required' => true, 'required' => true,
]); ]);
if ($context instanceof DocGeneratorContextWithAdminFormInterface if (
&& $context->hasAdminForm()) { $context instanceof DocGeneratorContextWithAdminFormInterface
&& $context->hasAdminForm()
) {
$sub = $builder $sub = $builder
->create('options', null, ['compound' => true]) ->create('options', null, ['compound' => true])
->addModelTransformer(new CallbackTransformer( ->addModelTransformer(new CallbackTransformer(

View File

@ -46,6 +46,7 @@ class RelatorioDriver implements DriverInterface
'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType),
]; ];
$form = new FormDataPart($formFields); $form = new FormDataPart($formFields);
dump(json_encode($data));
try { try {
$response = $this->relatorioClient->request('POST', $this->url, [ $response = $this->relatorioClient->request('POST', $this->url, [

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array; use function in_array;
class AdminMenuBuilder implements LocalMenuBuilderInterface class AdminMenuBuilder implements LocalMenuBuilderInterface

View File

@ -11,13 +11,15 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Serializer\Encoder; namespace Chill\DocGeneratorBundle\Serializer\Encoder;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use function array_keys; use function array_keys;
use function is_array; use function is_array;
class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInterface class DocGenEncoder implements EncoderInterface
{ {
public function encode($data, string $format, array $context = []) public function encode($data, $format, array $context = [])
{ {
if (!$this->isAssociative($data)) { if (!$this->isAssociative($data)) {
throw new UnexpectedValueException('Only associative arrays are allowed; lists are not allowed'); throw new UnexpectedValueException('Only associative arrays are allowed; lists are not allowed');
@ -29,7 +31,7 @@ class DocGenEncoder implements \Symfony\Component\Serializer\Encoder\EncoderInte
return $result; return $result;
} }
public function supportsEncoding(string $format) public function supportsEncoding($format)
{ {
return 'docgen' === $format; return 'docgen' === $format;
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Serializer\Helper; namespace Chill\DocGeneratorBundle\Serializer\Helper;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use function array_merge; use function array_merge;
class NormalizeNullValueHelper class NormalizeNullValueHelper

View File

@ -26,10 +26,11 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
/** /**
* @param Collection $object * @param Collection $object
* @param null|string $format
* *
* @return array|ArrayObject|bool|float|int|string|void|null * @return array|ArrayObject|bool|float|int|string|void|null
*/ */
public function normalize($object, ?string $format = null, array $context = []) public function normalize($object, $format = null, array $context = [])
{ {
$data = []; $data = [];
@ -44,7 +45,7 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
return $data; return $data;
} }
public function supportsNormalization($data, ?string $format = null, array $context = []) public function supportsNormalization($data, $format = null, array $context = [])
{ {
if ('docgen' !== $format) { if ('docgen' !== $format) {
return false; return false;

View File

@ -26,6 +26,7 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use function array_filter; use function array_filter;
use function array_key_exists; use function array_key_exists;
use function array_merge; use function array_merge;
@ -54,7 +55,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
$this->translatableStringHelper = $translatableStringHelper; $this->translatableStringHelper = $translatableStringHelper;
} }
public function normalize($object, ?string $format = null, array $context = []) public function normalize($object, $format = null, array $context = [])
{ {
$classMetadataKey = $object ?? $context['docgen:expects'] ?? null; $classMetadataKey = $object ?? $context['docgen:expects'] ?? null;
@ -65,7 +66,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
if (!$this->classMetadataFactory->hasMetadataFor($classMetadataKey)) { if (!$this->classMetadataFactory->hasMetadataFor($classMetadataKey)) {
throw new LogicException(sprintf( throw new LogicException(sprintf(
'This object does not have metadata: %s. Add groups on this entity to allow to serialize with the format %s and groups %s', 'This object does not have metadata: %s. Add groups on this entity to allow to serialize with the format %s and groups %s',
is_object($object) ? get_class($object) : '(todo' /*$context['docgen:expects'],*/ , is_object($object) ? get_class($object) : '(todo' /*$context['docgen:expects'],*/,
$format, $format,
implode(', ', ($context['groups'] ?? [])) implode(', ', ($context['groups'] ?? []))
)); ));
@ -95,7 +96,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
return $this->normalizeObject($object, $format, $context, $expectedGroups, $metadata, $attributes); return $this->normalizeObject($object, $format, $context, $expectedGroups, $metadata, $attributes);
} }
public function supportsNormalization($data, ?string $format = null): bool public function supportsNormalization($data, $format = null): bool
{ {
return 'docgen' === $format && (is_object($data) || null === $data); return 'docgen' === $format && (is_object($data) || null === $data);
} }

View File

@ -0,0 +1,53 @@
<?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.
*/
declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Service\Context;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class BaseContextData
{
private NormalizerInterface $normalizer;
private Security $security;
public function __construct(Security $security, NormalizerInterface $normalizer)
{
$this->security = $security;
$this->normalizer = $normalizer;
}
public function getData(): array
{
$data = [];
$user = $this->security->getUser();
$data['creator'] = $this->normalizer->normalize(
$user instanceof User ? $user : null,
'docgen',
['docgen:expects' => User::class, 'groups' => ['docgen:read']]
);
$data['createdAt'] = $this->normalizer->normalize(new DateTimeImmutable(), 'docgen', [
'docgen:expects' => DateTimeImmutable::class, 'groups' => ['docgen:read'],
]);
$data['location'] = $this->normalizer->normalize(
$user instanceof User ? $user->getCurrentLocation() : null,
'docgen',
['docgen:expects' => Location::class, 'groups' => ['docgen:read']]
);
return $data;
}
}

View File

@ -34,6 +34,11 @@ services:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
Chill\DocGeneratorBundle\Service\Context\:
resource: "../Service/Context/"
autowire: true
autoconfigure: true
Chill\DocGeneratorBundle\GeneratorDriver\: Chill\DocGeneratorBundle\GeneratorDriver\:
resource: "../GeneratorDriver/" resource: "../GeneratorDriver/"
autowire: true autowire: true

View File

@ -23,7 +23,7 @@ final class DocGenEncoderTest extends TestCase
{ {
private DocGenEncoder $encoder; private DocGenEncoder $encoder;
protected function setUp() protected function setUp(): void
{ {
parent::setUp(); parent::setUp();

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