mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-11 17:25:02 +00:00
Compare commits
139 Commits
feature-ad
...
feature-ad
Author | SHA1 | Date | |
---|---|---|---|
|
ee4e0b86fd | ||
|
ce4cbe3b8d | ||
|
c5b8b6345d | ||
8b51bfbaf5 | |||
|
f6cf0dba2f | ||
|
0625afecdd | ||
a63c38b6aa | |||
8915c42008 | |||
503293a359 | |||
7bdf71315a | |||
6f5d457122 | |||
b4274264a7 | |||
8002725c87 | |||
2c9edf3741 | |||
3f562449e1 | |||
1cce39bcb5 | |||
ad690db886 | |||
|
1b8462b40d | ||
|
8c98f2cf6e | ||
f3260f57a4 | |||
b4ad0128e4 | |||
e1c8278f71 | |||
|
ed3f46ce7f | ||
33457d3cbc | |||
e919b4322e | |||
7503c845df | |||
3686a294d3 | |||
b6131379f9 | |||
e1fcc41ace | |||
f2a04cebe6 | |||
c693002ddb | |||
ee77c8540a | |||
a536d2780e | |||
f880598052 | |||
e7985ea52f | |||
f56dc65021 | |||
|
4770758aee | ||
90fe484d81 | |||
2b8bbe019d | |||
9e1c151402 | |||
088e522292 | |||
b8e6e98a74 | |||
2db847ada2 | |||
07e0692783 | |||
e78d53064b | |||
e6fcb5ff22 | |||
f02e33fda7 | |||
1bbec9efae | |||
3b53c4451c | |||
30f490959b | |||
|
0a894b0db1 | ||
c20e9507d5 | |||
f89c690f1b | |||
|
7819c1204c | ||
|
f61af9d02a | ||
|
e470a6a97e | ||
|
cd8c47449b | ||
120e7cade5 | |||
ac550e05e8 | |||
d6e7fadb4f | |||
|
2be1c08c44 | ||
|
86c177bbbb | ||
|
d426d28ba0 | ||
|
72e69fc0b3 | ||
cc8de353d4 | |||
4495a5d33b | |||
9dffe30aad | |||
d393e74896 | |||
daf083dc88 | |||
|
ce859697b5 | ||
|
1587c762f8 | ||
|
17c01d9b46 | ||
a1bb9ea352 | |||
|
a1895ec65f | ||
|
c5faa0b99d | ||
|
e9d142f3e8 | ||
|
91860afd80 | ||
|
bec0700d39 | ||
|
05d3d7f5c7 | ||
|
ebff36d257 | ||
|
a709b3afb6 | ||
|
69a3c6a9b2 | ||
|
8c33d876e8 | ||
|
1ec2fbcc16 | ||
|
bc4e29141b | ||
|
e90ea31683 | ||
|
7c99f0b3e0 | ||
|
c089960707 | ||
|
0b2f29f1e8 | ||
|
9a4f50472a | ||
|
7d1a1c4004 | ||
|
ebd58d4229 | ||
|
dd48795f64 | ||
3d45b6687f | |||
35e6d36ce0 | |||
4900c81c11 | |||
52472b0ec3 | |||
ec68e6f761 | |||
25bd170f6b | |||
6939b4a313 | |||
d18922ed98 | |||
e8bf242c42 | |||
2050460bb3 | |||
|
4add30e895 | ||
e1dbfdafd7 | |||
75becb2294 | |||
94e494361f | |||
cab3b1059d | |||
|
d27bdf68fb | ||
|
82b82920e1 | ||
4bb3eadf91 | |||
4c82e65c1f | |||
cf4d7df7ad | |||
86d13410c3 | |||
19fdf2a503 | |||
3a0c25c871 | |||
083338da8d | |||
37e5c9ceaa | |||
|
5448238697 | ||
|
c5250a1059 | ||
b2c1a7b8de | |||
b4583fc6dc | |||
f7c508939c | |||
4cf77a9b0e | |||
a2160bef7d | |||
|
c2a4a95eba | ||
8641d6bdce | |||
5f4d513aa6 | |||
f47b15de39 | |||
7426dc02cf | |||
a570160aed | |||
7596bd5a06 | |||
01f9d03b14 | |||
66426f5102 | |||
|
03243605da | ||
|
48e2d2ceab | ||
|
777fb25860 | ||
|
03601b9707 | ||
c205bbddd3 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ docs/build/
|
|||||||
/phpunit.xml
|
/phpunit.xml
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
###< phpunit/phpunit ###
|
###< phpunit/phpunit ###
|
||||||
|
|
||||||
|
@@ -30,6 +30,10 @@ variables:
|
|||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
# fetch the chill-app using git submodules
|
# fetch the chill-app using git submodules
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
|
REDIS_HOST: redis
|
||||||
|
REDIS_PORT: 6379
|
||||||
|
REDIS_URL: redis://redis:6379
|
||||||
|
|
||||||
|
|
||||||
# Run our tests
|
# Run our tests
|
||||||
test:
|
test:
|
||||||
|
71
.php-cs-fixer.dist.php
Normal file
71
.php-cs-fixer.dist.php
Normal 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);
|
25
.php_cs.dist
25
.php_cs.dist
@@ -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
9
README.md
Normal 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
|
@@ -64,7 +64,7 @@
|
|||||||
"symfony/symfony": "*"
|
"symfony/symfony": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"drupol/php-conventions": "4.*",
|
"drupol/php-conventions": "5.*",
|
||||||
"fakerphp/faker": "^1.13",
|
"fakerphp/faker": "^1.13",
|
||||||
"phpunit/phpunit": "^7.0",
|
"phpunit/phpunit": "^7.0",
|
||||||
"symfony/dotenv": "^5.1",
|
"symfony/dotenv": "^5.1",
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
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\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
|
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
// add specific role for this filter
|
// add specific role for this filter
|
||||||
public function addRole()
|
public function addRole()
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\PersonBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\ExportInterface;
|
use Chill\MainBundle\Export\ExportInterface;
|
||||||
@@ -93,7 +89,7 @@ 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) {
|
$centers = array_map(function ($el) {
|
||||||
return $el['center'];
|
return $el['center'];
|
||||||
}, $acl);
|
}, $acl);
|
||||||
|
|
||||||
|
453
docs/source/development/api.rst
Normal file
453
docs/source/development/api.rst
Normal 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
|
||||||
|
|
||||||
|
|
@@ -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>
|
Instructions to create a new bundle <create-a-new-bundle.rst>
|
||||||
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
||||||
|
Helpers for building a REST API <api.rst>
|
||||||
Routing <routing.rst>
|
Routing <routing.rst>
|
||||||
Menus <menus.rst>
|
Menus <menus.rst>
|
||||||
Forms <forms.rst>
|
Forms <forms.rst>
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
Free Documentation License".
|
Free Documentation License".
|
||||||
|
|
||||||
|
|
||||||
|
.. _pagination-ref:
|
||||||
|
|
||||||
Pagination
|
Pagination
|
||||||
##########
|
##########
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ The Bundle :code:`Chill\MainBundle` provides a **Pagination** api which allow yo
|
|||||||
A simple example
|
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
|
.. literalinclude:: pagination/example.php
|
||||||
|
@@ -1,21 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\MyBundle\Controller;
|
namespace Chill\MyBundle\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
class example extends Controller
|
class ItemController extends Controller
|
||||||
{
|
{
|
||||||
public function yourAction()
|
public function yourAction()
|
||||||
{
|
{
|
||||||
@@ -40,12 +36,13 @@ class example extends Controller
|
|||||||
// use the paginator to get the number of items to display
|
// use the paginator to get the number of items to display
|
||||||
->setMaxResults($paginator->getItemsPerPage());
|
->setMaxResults($paginator->getItemsPerPage());
|
||||||
|
|
||||||
return $this->render(
|
return $this
|
||||||
'ChillMyBundle:Item:list.html.twig',
|
->render(
|
||||||
[
|
'ChillMyBundle:Item:list.html.twig',
|
||||||
'items' => $items,
|
[
|
||||||
'paginator' => $paginator,
|
'items' => $items,
|
||||||
]
|
'paginator' => $paginator,
|
||||||
);
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\HealthBundle\Controller;
|
namespace Chill\HealthBundle\Controller;
|
||||||
|
|
||||||
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
||||||
@@ -29,7 +25,7 @@ class ConsultationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function listAction($id)
|
public function listAction($id)
|
||||||
{
|
{
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
$person = $this->get('chill.person.repository.person')
|
$person = $this->get('chill.person.repository.person')
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
@@ -39,7 +35,7 @@ class ConsultationController extends Controller
|
|||||||
|
|
||||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
$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.'
|
$authorizationHelper = $this->get('chill.main.security.'
|
||||||
. 'authorization.helper');
|
. 'authorization.helper');
|
||||||
|
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\MainBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
||||||
@@ -23,7 +17,7 @@ namespace Chill\MainBundle\DependencyInjection;
|
|||||||
/**
|
/**
|
||||||
* Configure the main bundle.
|
* Configure the main bundle.
|
||||||
*/
|
*/
|
||||||
class ChillMainConfiguration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
use AddWidgetConfigurationTrait;
|
use AddWidgetConfigurationTrait;
|
||||||
|
|
||||||
@@ -33,7 +27,7 @@ class ChillMainConfiguration implements ConfigurationInterface
|
|||||||
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)
|
||||||
@@ -42,9 +36,6 @@ class ChillMainConfiguration implements ConfigurationInterface
|
|||||||
$this->containerBuilder = $containerBuilder;
|
$this->containerBuilder = $containerBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getConfigTreeBuilder()
|
public function getConfigTreeBuilder()
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
@@ -62,8 +53,7 @@ class ChillMainConfiguration implements ConfigurationInterface
|
|||||||
->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;
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\MainBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\PersonBundle\Widget;
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
||||||
@@ -22,7 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
/**
|
/**
|
||||||
* add configuration for the person_list widget.
|
* add configuration for the person_list widget.
|
||||||
*/
|
*/
|
||||||
class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
class PersonListWidgetFactory extends AbstractWidgetFactory
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* append the option to the configuration
|
* append the option to the configuration
|
||||||
@@ -42,8 +36,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
|||||||
->end();
|
->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[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
@@ -65,8 +59,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
|||||||
return 'chill_person.widget.person_list';
|
return 'chill_person.widget.person_list';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* return the widget alias.
|
* return the widget alias
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\PersonBundle\Widget;
|
||||||
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
@@ -33,7 +27,7 @@ use Twig_Environment;
|
|||||||
*
|
*
|
||||||
* The configuration is defined by `PersonListWidgetFactory`
|
* The configuration is defined by `PersonListWidgetFactory`
|
||||||
*/
|
*/
|
||||||
class ChillPersonAddAPersonWidget implements WidgetInterface
|
class PersonListWidget implements WidgetInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* the authorization helper.
|
* the authorization helper.
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\PersonBundle\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
@@ -26,9 +20,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||||||
*/
|
*/
|
||||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
// ...
|
// ...
|
||||||
|
@@ -2,7 +2,8 @@ imports:
|
|||||||
- { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml }
|
- { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml }
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
tasks.phpcsfixer.config: .php_cs.dist
|
tasks.phpcsfixer.config: .php-cs-fixer.dist.php
|
||||||
tasks.license.name: AGPL-3.0
|
tasks.license.name: AGPL-3.0
|
||||||
tasks.license.holder: Champs-Libres
|
tasks.license.holder: Champs-Libres
|
||||||
tasks.license.date_from: 2001
|
tasks.license.date_from: 2001
|
||||||
|
tasks.phpcsfixer.allow_risky: false
|
||||||
|
@@ -18,11 +18,11 @@
|
|||||||
<testsuite name="MainBundle">
|
<testsuite name="MainBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<!--
|
||||||
<testsuite name="PersonBundle">
|
<testsuite name="PersonBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
-->
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<listeners>
|
<listeners>
|
||||||
|
@@ -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
|
For the full copyright and license information, please view
|
||||||
the LICENSE file that was distributed with this source code.
|
the LICENSE file that was distributed with this source code.
|
||||||
|
|
||||||
@see https://www.champs-libres.coop/
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle;
|
namespace Chill\ActivityBundle;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
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\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityController.
|
||||||
|
*/
|
||||||
class ActivityController extends AbstractController
|
class ActivityController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +127,7 @@ class ActivityController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
/** @var Activity $activity */
|
/* @var $activity Activity */
|
||||||
$activity = $em->getRepository('ChillActivityBundle:Activity')
|
$activity = $em->getRepository('ChillActivityBundle:Activity')
|
||||||
->find($id);
|
->find($id);
|
||||||
$person = $activity->getPerson();
|
$person = $activity->getPerson();
|
||||||
@@ -152,7 +151,7 @@ class ActivityController extends AbstractController
|
|||||||
'comment' => $activity->getComment()->getComment(),
|
'comment' => $activity->getComment()->getComment(),
|
||||||
'scope_id' => $activity->getScope()->getId(),
|
'scope_id' => $activity->getScope()->getId(),
|
||||||
'reasons_ids' => $activity->getReasons()
|
'reasons_ids' => $activity->getReasons()
|
||||||
->map(static function ($ar) {
|
->map(function ($ar) {
|
||||||
return $ar->getId();
|
return $ar->getId();
|
||||||
})
|
})
|
||||||
->toArray(),
|
->toArray(),
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
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\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityReasonCategory controller.
|
||||||
|
*/
|
||||||
class ActivityReasonCategoryController extends AbstractController
|
class ActivityReasonCategoryController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
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\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityReason controller.
|
||||||
|
*/
|
||||||
class ActivityReasonController extends AbstractController
|
class ActivityReasonController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
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\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityTypeController.
|
||||||
|
*/
|
||||||
class ActivityTypeController extends AbstractController
|
class ActivityTypeController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
@@ -22,12 +18,10 @@ use Doctrine\Persistence\ObjectManager;
|
|||||||
use Faker\Factory as FakerFactory;
|
use Faker\Factory as FakerFactory;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load reports into DB.
|
* Load reports into DB.
|
||||||
*/
|
*/
|
||||||
class LoadActivity extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
|
||||||
{
|
{
|
||||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
|
|
||||||
@@ -53,7 +47,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
foreach ($persons as $person) {
|
foreach ($persons as $person) {
|
||||||
$activityNbr = mt_rand(0, 3);
|
$activityNbr = rand(0, 3);
|
||||||
|
|
||||||
for ($i = 0; $i < $activityNbr; ++$i) {
|
for ($i = 0; $i < $activityNbr; ++$i) {
|
||||||
echo 'Creating an activity type for : ' . $person . "\n";
|
echo 'Creating an activity type for : ' . $person . "\n";
|
||||||
@@ -77,7 +71,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
|
|
||||||
$usedId = [];
|
$usedId = [];
|
||||||
|
|
||||||
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
|
for ($i = 0; rand(0, 4) > $i; ++$i) {
|
||||||
$reason = $this->getRandomActivityReason($usedId);
|
$reason = $this->getRandomActivityReason($usedId);
|
||||||
$usedId[] = $reason->getId();
|
$usedId[] = $reason->getId();
|
||||||
$activity->addReason($reason);
|
$activity->addReason($reason);
|
||||||
@@ -95,7 +89,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
{
|
{
|
||||||
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
$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...
|
// we have a reason which should be excluded. Find another...
|
||||||
return $this->getRandomActivityReason($excludingIds);
|
return $this->getRandomActivityReason($excludingIds);
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
@@ -19,10 +17,10 @@ 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;
|
/**
|
||||||
|
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
||||||
declare(strict_types=1);
|
* and a role CHILL_ACTIVITY_SEE for administrative.
|
||||||
|
*/
|
||||||
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
@@ -45,9 +43,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'administrative':
|
case 'administrative':
|
||||||
case 'direction':
|
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
|
break 2; // we do not want any power on social or administrative
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DependencyInjection;
|
namespace Chill\ActivityBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||||||
*/
|
*/
|
||||||
class ChillActivityExtension extends Extension implements PrependExtensionInterface
|
class ChillActivityExtension extends Extension implements PrependExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
@@ -66,7 +59,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** (non-PHPdoc).
|
/* (non-PHPdoc)
|
||||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||||
*/
|
*/
|
||||||
public function prependRoutes(ContainerBuilder $container)
|
public function prependRoutes(ContainerBuilder $container)
|
||||||
|
@@ -1,23 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DependencyInjection;
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that validates and merges configuration from your app/config files.
|
* 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
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getConfigTreeBuilder()
|
public function getConfigTreeBuilder()
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder('chill_activity');
|
$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.')
|
->info('The number of seconds of this duration. Must be an integer.')
|
||||||
->cannotBeEmpty()
|
->cannotBeEmpty()
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(static function ($data) {
|
->ifTrue(function ($data) {
|
||||||
return !is_int($data);
|
return !is_int($data);
|
||||||
})->thenInvalid('The value %s is not a valid integer')
|
})->thenInvalid('The value %s is not a valid integer')
|
||||||
->end()
|
->end()
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
@@ -27,6 +23,8 @@ use Doctrine\Common\Collections\Collection;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Activity.
|
||||||
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="activity")
|
* @ORM\Table(name="activity")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
@@ -1,21 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ActivityReason.
|
||||||
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="activityreason")
|
* @ORM\Table(name="activityreason")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
@@ -1,22 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ActivityReasonCategory.
|
||||||
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="activityreasoncategory")
|
* @ORM\Table(name="activityreasoncategory")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
@@ -1,21 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ActivityType.
|
||||||
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="activitytype")
|
* @ORM\Table(name="activitytype")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
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\Security\Core\Role\Role;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
|
||||||
use function count;
|
|
||||||
|
|
||||||
class ActivityReasonAggregator implements
|
class ActivityReasonAggregator implements
|
||||||
AggregatorInterface,
|
AggregatorInterface,
|
||||||
ExportElementValidatedInterface
|
ExportElementValidatedInterface
|
||||||
@@ -86,7 +79,7 @@ class ActivityReasonAggregator implements
|
|||||||
array_key_exists('activity', $join)
|
array_key_exists('activity', $join)
|
||||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||||
)
|
)
|
||||||
|| (!array_key_exists('activity', $join))
|
or (!array_key_exists('activity', $join))
|
||||||
) {
|
) {
|
||||||
$qb->add(
|
$qb->add(
|
||||||
'join',
|
'join',
|
||||||
@@ -140,6 +133,7 @@ class ActivityReasonAggregator implements
|
|||||||
$this->reasonRepository->findBy(['id' => $values]);
|
$this->reasonRepository->findBy(['id' => $values]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'categories':
|
case 'categories':
|
||||||
$this->categoryRepository->findBy(['id' => $values]);
|
$this->categoryRepository->findBy(['id' => $values]);
|
||||||
|
|
||||||
@@ -162,7 +156,7 @@ class ActivityReasonAggregator implements
|
|||||||
|
|
||||||
switch ($data['level']) {
|
switch ($data['level']) {
|
||||||
case 'reasons':
|
case 'reasons':
|
||||||
/** @var \Chill\ActivityBundle\Entity\ActivityReason $r */
|
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
|
||||||
$r = $this->reasonRepository->find($value);
|
$r = $this->reasonRepository->find($value);
|
||||||
|
|
||||||
return $this->stringHelper->localize($r->getCategory()->getName())
|
return $this->stringHelper->localize($r->getCategory()->getName())
|
||||||
@@ -170,6 +164,7 @@ class ActivityReasonAggregator implements
|
|||||||
. $this->stringHelper->localize($r->getName());
|
. $this->stringHelper->localize($r->getName());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'categories':
|
case 'categories':
|
||||||
$c = $this->categoryRepository->find($value);
|
$c = $this->categoryRepository->find($value);
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
@@ -78,7 +74,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
return 'Activity type';
|
return 'Activity type';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Chill\ActivityBundle\Entity\ActivityType $r */
|
/* @var $r \Chill\ActivityBundle\Entity\ActivityType */
|
||||||
$t = $this->typeRepository->find($value);
|
$t = $this->typeRepository->find($value);
|
||||||
|
|
||||||
return $this->stringHelper->localize($t->getName());
|
return $this->stringHelper->localize($t->getName());
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
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");
|
throw new LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static function ($value) {
|
return function ($value) {
|
||||||
return '_header' === $value ?
|
return '_header' === $value ?
|
||||||
'Number of activities'
|
'Number of activities'
|
||||||
:
|
:
|
||||||
@@ -84,7 +80,7 @@ class CountActivity implements ExportInterface
|
|||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(function ($el) {
|
||||||
return $el['center'];
|
return $el['center'];
|
||||||
}, $acl);
|
}, $acl);
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
@@ -29,8 +25,6 @@ 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 in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a list for all activities.
|
* Create a list for all activities.
|
||||||
@@ -76,9 +70,6 @@ class ListActivity implements ListInterface
|
|||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('fields', ChoiceType::class, [
|
$builder->add('fields', ChoiceType::class, [
|
||||||
@@ -87,7 +78,7 @@ class ListActivity implements ListInterface
|
|||||||
'choices' => array_combine($this->fields, $this->fields),
|
'choices' => array_combine($this->fields, $this->fields),
|
||||||
'label' => 'Fields to include in export',
|
'label' => 'Fields to include in export',
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback([
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
'callback' => function ($selected, ExecutionContextInterface $context) {
|
||||||
if (count($selected) === 0) {
|
if (count($selected) === 0) {
|
||||||
$context->buildViolation('You must select at least one element')
|
$context->buildViolation('You must select at least one element')
|
||||||
->atPath('fields')
|
->atPath('fields')
|
||||||
@@ -99,8 +90,6 @@ class ListActivity implements ListInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function getAllowedFormattersTypes()
|
public function getAllowedFormattersTypes()
|
||||||
@@ -117,7 +106,7 @@ class ListActivity implements ListInterface
|
|||||||
{
|
{
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'date':
|
case 'date':
|
||||||
return static function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'date';
|
return 'date';
|
||||||
}
|
}
|
||||||
@@ -126,16 +115,18 @@ class ListActivity implements ListInterface
|
|||||||
|
|
||||||
return $date->format('d-m-Y');
|
return $date->format('d-m-Y');
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'attendee':
|
case 'attendee':
|
||||||
return static function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'attendee';
|
return 'attendee';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'list_reasons':
|
case 'list_reasons':
|
||||||
/** @var EntityRepository $activityReasonsRepository */
|
/* @var $activityReasonsRepository EntityRepository */
|
||||||
$activityRepository = $this->entityManager
|
$activityRepository = $this->entityManager
|
||||||
->getRepository('ChillActivityBundle:Activity');
|
->getRepository('ChillActivityBundle:Activity');
|
||||||
|
|
||||||
@@ -155,6 +146,7 @@ class ListActivity implements ListInterface
|
|||||||
. '"';
|
. '"';
|
||||||
}, $activity->getReasons()->toArray()));
|
}, $activity->getReasons()->toArray()));
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'circle_name':
|
case 'circle_name':
|
||||||
return function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
@@ -164,6 +156,7 @@ class ListActivity implements ListInterface
|
|||||||
return $this->translatableStringHelper
|
return $this->translatableStringHelper
|
||||||
->localize(json_decode($value, true));
|
->localize(json_decode($value, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'type_name':
|
case 'type_name':
|
||||||
return function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
@@ -175,7 +168,7 @@ class ListActivity implements ListInterface
|
|||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return static function ($value) use ($key) {
|
return function ($value) use ($key) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
@@ -207,7 +200,7 @@ 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) {
|
$centers = array_map(function ($el) {
|
||||||
return $el['center'];
|
return $el['center'];
|
||||||
}, $acl);
|
}, $acl);
|
||||||
|
|
||||||
@@ -227,39 +220,46 @@ class ListActivity implements ListInterface
|
|||||||
->setParameter('authorized_centers', $centers);
|
->setParameter('authorized_centers', $centers);
|
||||||
|
|
||||||
foreach ($this->fields as $f) {
|
foreach ($this->fields as $f) {
|
||||||
if (in_array($f, $data['fields'], true)) {
|
if (in_array($f, $data['fields'])) {
|
||||||
switch ($f) {
|
switch ($f) {
|
||||||
case 'id':
|
case 'id':
|
||||||
$qb->addSelect('activity.id AS id');
|
$qb->addSelect('activity.id AS id');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'person_firstname':
|
case 'person_firstname':
|
||||||
$qb->addSelect('person.firstName AS person_firstname');
|
$qb->addSelect('person.firstName AS person_firstname');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'person_lastname':
|
case 'person_lastname':
|
||||||
$qb->addSelect('person.lastName AS person_lastname');
|
$qb->addSelect('person.lastName AS person_lastname');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'person_id':
|
case 'person_id':
|
||||||
$qb->addSelect('person.id AS person_id');
|
$qb->addSelect('person.id AS person_id');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'user_username':
|
case 'user_username':
|
||||||
$qb->join('activity.user', 'user');
|
$qb->join('activity.user', 'user');
|
||||||
$qb->addSelect('user.username AS user_username');
|
$qb->addSelect('user.username AS user_username');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'circle_name':
|
case 'circle_name':
|
||||||
$qb->join('activity.scope', 'circle');
|
$qb->join('activity.scope', 'circle');
|
||||||
$qb->addSelect('circle.name AS circle_name');
|
$qb->addSelect('circle.name AS circle_name');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'type_name':
|
case 'type_name':
|
||||||
$qb->join('activity.type', 'type');
|
$qb->join('activity.type', 'type');
|
||||||
$qb->addSelect('type.name AS type_name');
|
$qb->addSelect('type.name AS type_name');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'list_reasons':
|
case 'list_reasons':
|
||||||
// this is a trick... The reasons is filled with the
|
// this is a trick... The reasons is filled with the
|
||||||
// activity id which will be used to load reasons
|
// activity id which will be used to load reasons
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
@@ -81,7 +77,7 @@ class StatActivityDuration implements ExportInterface
|
|||||||
$header = 'Sum of activities duration';
|
$header = 'Sum of activities duration';
|
||||||
}
|
}
|
||||||
|
|
||||||
return static function ($value) use ($header) {
|
return function ($value) use ($header) {
|
||||||
return '_header' === $value ?
|
return '_header' === $value ?
|
||||||
$header
|
$header
|
||||||
:
|
:
|
||||||
@@ -113,7 +109,7 @@ class StatActivityDuration implements ExportInterface
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(function ($el) {
|
||||||
return $el['center'];
|
return $el['center'];
|
||||||
}, $acl);
|
}, $acl);
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
@@ -84,7 +80,7 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
||||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||||
$filterForm = $event->getForm()->getParent();
|
$filterForm = $event->getForm()->getParent();
|
||||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
@@ -27,12 +23,9 @@ 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 count;
|
|
||||||
|
|
||||||
class ActivityReasonFilter implements
|
class ActivityReasonFilter implements
|
||||||
ExportElementValidatedInterface,
|
FilterInterface,
|
||||||
FilterInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The repository for activity reasons.
|
* The repository for activity reasons.
|
||||||
@@ -71,7 +64,7 @@ class ActivityReasonFilter implements
|
|||||||
array_key_exists('activity', $join)
|
array_key_exists('activity', $join)
|
||||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||||
)
|
)
|
||||||
|| (!array_key_exists('activity', $join))
|
or (!array_key_exists('activity', $join))
|
||||||
) {
|
) {
|
||||||
$qb->add(
|
$qb->add(
|
||||||
'join',
|
'join',
|
||||||
@@ -102,10 +95,10 @@ class ActivityReasonFilter implements
|
|||||||
|
|
||||||
$builder->add('reasons', EntityType::class, [
|
$builder->add('reasons', EntityType::class, [
|
||||||
'class' => 'ChillActivityBundle:ActivityReason',
|
'class' => 'ChillActivityBundle:ActivityReason',
|
||||||
'choice_label' => static function (ActivityReason $reason) use ($helper) {
|
'choice_label' => function (ActivityReason $reason) use ($helper) {
|
||||||
return $helper->localize($reason->getName());
|
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());
|
return $helper->localize($reason->getCategory()->getName());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
@@ -27,11 +23,9 @@ 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;
|
|
||||||
|
|
||||||
class ActivityTypeFilter implements
|
class ActivityTypeFilter implements
|
||||||
ExportElementValidatedInterface,
|
FilterInterface,
|
||||||
FilterInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
@@ -85,7 +79,7 @@ class ActivityTypeFilter implements
|
|||||||
|
|
||||||
$builder->add('types', EntityType::class, [
|
$builder->add('types', EntityType::class, [
|
||||||
'class' => ActivityType::class,
|
'class' => ActivityType::class,
|
||||||
'choice_label' => static function (ActivityType $type) use ($helper) {
|
'choice_label' => function (ActivityType $type) use ($helper) {
|
||||||
return $helper->localize($type->getName());
|
return $helper->localize($type->getName());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
@@ -30,11 +26,9 @@ use Symfony\Component\Form\FormEvents;
|
|||||||
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;
|
|
||||||
|
|
||||||
class PersonHavingActivityBetweenDateFilter implements
|
class PersonHavingActivityBetweenDateFilter implements
|
||||||
ExportElementValidatedInterface,
|
FilterInterface,
|
||||||
FilterInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
@@ -151,7 +145,7 @@ class PersonHavingActivityBetweenDateFilter implements
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
||||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||||
$filterForm = $event->getForm()->getParent();
|
$filterForm = $event->getForm()->getParent();
|
||||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
||||||
@@ -36,8 +32,6 @@ 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;
|
|
||||||
|
|
||||||
class ActivityType extends AbstractType
|
class ActivityType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -135,7 +129,7 @@ class ActivityType extends AbstractType
|
|||||||
$builder->get('durationTime')
|
$builder->get('durationTime')
|
||||||
->addEventListener(
|
->addEventListener(
|
||||||
FormEvents::PRE_SET_DATA,
|
FormEvents::PRE_SET_DATA,
|
||||||
static function (FormEvent $formEvent) use (
|
function (FormEvent $formEvent) use (
|
||||||
$timeChoices,
|
$timeChoices,
|
||||||
$builder,
|
$builder,
|
||||||
$durationTimeTransformer,
|
$durationTimeTransformer,
|
||||||
@@ -144,7 +138,7 @@ class ActivityType extends AbstractType
|
|||||||
// set the timezone to GMT, and fix the difference between current and GMT
|
// set the timezone to GMT, and fix the difference between current and GMT
|
||||||
// the datetimetransformer will then handle timezone as GMT
|
// the datetimetransformer will then handle timezone as GMT
|
||||||
$timezoneUTC = new DateTimeZone('GMT');
|
$timezoneUTC = new DateTimeZone('GMT');
|
||||||
/** @var DateTime $data */
|
/* @var $data \DateTime */
|
||||||
$data = $formEvent->getData() === null ?
|
$data = $formEvent->getData() === null ?
|
||||||
DateTime::createFromFormat('U', 300) :
|
DateTime::createFromFormat('U', 300) :
|
||||||
$formEvent->getData();
|
$formEvent->getData();
|
||||||
@@ -154,7 +148,7 @@ class ActivityType extends AbstractType
|
|||||||
|
|
||||||
// test if the timestamp is in the choices.
|
// test if the timestamp is in the choices.
|
||||||
// If not, recreate the field with the new timestamp
|
// 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
|
// the data are not in the possible values. add them
|
||||||
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
||||||
$form = $builder->create(
|
$form = $builder->create(
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
@@ -59,7 +55,7 @@ class TranslatableActivityReason extends AbstractType
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
'query_builder' => static function (EntityRepository $er) {
|
'query_builder' => function (EntityRepository $er) {
|
||||||
return $er->createQueryBuilder('r')
|
return $er->createQueryBuilder('r')
|
||||||
->where('r.active = true');
|
->where('r.active = true');
|
||||||
},
|
},
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
@@ -41,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType
|
|||||||
[
|
[
|
||||||
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
||||||
'choice_label' => 'name[' . $locale . ']',
|
'choice_label' => 'name[' . $locale . ']',
|
||||||
'query_builder' => static function (EntityRepository $er) {
|
'query_builder' => function (EntityRepository $er) {
|
||||||
return $er->createQueryBuilder('c')
|
return $er->createQueryBuilder('c')
|
||||||
->where('c.active = true');
|
->where('c.active = true');
|
||||||
},
|
},
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
@@ -42,7 +38,7 @@ class TranslatableActivityType extends AbstractType
|
|||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
/** @var \Doctrine\ORM\QueryBuilder $qb */
|
/* @var $qb \Doctrine\ORM\QueryBuilder */
|
||||||
$qb = $options['query_builder'];
|
$qb = $options['query_builder'];
|
||||||
|
|
||||||
if (true === $options['active_only']) {
|
if (true === $options['active_only']) {
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Menu;
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
@@ -50,7 +46,7 @@ class MenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
$person = $parameters['person'];
|
$person = $parameters['person'];
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
$user = $this->tokenStorage->getToken()->getUser();
|
||||||
$roleSee = new Role(ActivityVoter::SEE);
|
$roleSee = new Role(ActivityVoter::SEE);
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Menu;
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
@@ -41,7 +37,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
$person = $parameters['person'];
|
$person = $parameters['person'];
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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\Config\Loader\LoaderInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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 Composer\Autoload\ClassLoader;
|
||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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\Container;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
||||||
@@ -309,31 +305,22 @@ class appDevDebugProjectContainer extends Container
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function compile()
|
public function compile()
|
||||||
{
|
{
|
||||||
throw new LogicException('You cannot compile a dumped frozen container.');
|
throw new LogicException('You cannot compile a dumped frozen container.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($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));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->parameters[$name];
|
return $this->parameters[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getParameterBag()
|
public function getParameterBag()
|
||||||
{
|
{
|
||||||
if (null === $this->parameterBag) {
|
if (null === $this->parameterBag) {
|
||||||
@@ -343,19 +330,13 @@ class appDevDebugProjectContainer extends Container
|
|||||||
return $this->parameterBag;
|
return $this->parameterBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($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)
|
public function setParameter($name, $value)
|
||||||
{
|
{
|
||||||
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
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('app', $e);
|
||||||
$instance->addGlobal('installation', ['name' => 'Chill']);
|
$instance->addGlobal('installation', ['name' => 'Chill']);
|
||||||
$instance->addGlobal('available_languages', [0 => 'fr']);
|
$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;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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\Debug\Debug;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@@ -23,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
if (
|
if (
|
||||||
isset($_SERVER['HTTP_CLIENT_IP'])
|
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']) || php_sapi_name() === 'cli-server')
|
||||||
) {
|
) {
|
||||||
header('HTTP/1.0 403 Forbidden');
|
header('HTTP/1.0 403 Forbidden');
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Security\Authorization;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
@@ -69,7 +65,7 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
|
|||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
$subject instanceof Center
|
$subject instanceof Center
|
||||||
&& in_array($attribute, $this->getAttributes(), true)
|
&& in_array($attribute, $this->getAttributes())
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Security\Authorization;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
@@ -64,7 +60,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
|||||||
protected function supports($attribute, $subject)
|
protected function supports($attribute, $subject)
|
||||||
{
|
{
|
||||||
if ($subject instanceof Activity) {
|
if ($subject instanceof Activity) {
|
||||||
return in_array($attribute, $this->getAttributes(), true);
|
return in_array($attribute, $this->getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subject instanceof Person) {
|
if ($subject instanceof Person) {
|
||||||
@@ -84,7 +80,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
|||||||
if ($subject instanceof Person) {
|
if ($subject instanceof Person) {
|
||||||
$centers = $this->helper->getReachableCenters($token->getUser(), new Role($attribute));
|
$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 */
|
/* @var $subject Activity */
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Templating\Entity;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
@@ -1,31 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Test;
|
||||||
|
@@ -1,33 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Controller;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityControllerTest extends WebTestCase
|
class ActivityControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
public function getSecuredPagesAuthenticated()
|
public function getSecuredPagesAuthenticated()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
|
|
||||||
$person = $this->getPersonFromFixtures();
|
$person = $this->getPersonFromFixtures();
|
||||||
$activities = $this->getActivitiesForPerson($person);
|
$activities = $this->getActivitiesForPerson($person);
|
||||||
@@ -63,7 +57,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function getSecuredPagesUnauthenticated()
|
public function getSecuredPagesUnauthenticated()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
$person = $this->getPersonFromFixtures();
|
$person = $this->getPersonFromFixtures();
|
||||||
$activities = $this->getActivitiesForPerson($person);
|
$activities = $this->getActivitiesForPerson($person);
|
||||||
|
|
||||||
@@ -86,8 +80,8 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$client->request('GET', $url);
|
$client->request('GET', $url);
|
||||||
|
|
||||||
self::assertEquals(302, $client->getResponse()->getStatusCode());
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
self::assertTrue(
|
$this->assertTrue(
|
||||||
$client->getResponse()->isRedirect('http://localhost/login'),
|
$client->getResponse()->isRedirect('http://localhost/login'),
|
||||||
sprintf('the page "%s" does not redirect to http://localhost/login', $url)
|
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);
|
$client->request('GET', $url);
|
||||||
|
|
||||||
self::assertEquals(403, $client->getResponse()->getStatusCode());
|
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCompleteScenario()
|
public function testCompleteScenario()
|
||||||
@@ -117,7 +111,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
'en/person/%d/activity/',
|
'en/person/%d/activity/',
|
||||||
$person->getId()
|
$person->getId()
|
||||||
));
|
));
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
200,
|
200,
|
||||||
$client->getResponse()->getStatusCode(),
|
$client->getResponse()->getStatusCode(),
|
||||||
'Unexpected HTTP status code for GET /activity/'
|
'Unexpected HTTP status code for GET /activity/'
|
||||||
@@ -142,11 +136,11 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
self::assertTrue($client->getResponse()->isRedirect());
|
$this->assertTrue($client->getResponse()->isRedirect());
|
||||||
$crawler = $client->followRedirect();
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
// Check data in the show view
|
// Check data in the show view
|
||||||
self::assertGreaterThan(
|
$this->assertGreaterThan(
|
||||||
0,
|
0,
|
||||||
$crawler->filter('dd:contains("January 15, 2015")')->count(),
|
$crawler->filter('dd:contains("January 15, 2015")')->count(),
|
||||||
'Missing element dd:contains("January 15, 2015")'
|
'Missing element dd:contains("January 15, 2015")'
|
||||||
@@ -164,17 +158,17 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
self::assertTrue($client->getResponse()->isRedirect());
|
$this->assertTrue($client->getResponse()->isRedirect());
|
||||||
|
|
||||||
$crawler = $client->followRedirect();
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
// check that new data are present
|
// check that new data are present
|
||||||
self::assertGreaterThan(
|
$this->assertGreaterThan(
|
||||||
0,
|
0,
|
||||||
$crawler->filter('dd:contains("January 25, 2015")')->count(),
|
$crawler->filter('dd:contains("January 25, 2015")')->count(),
|
||||||
'Missing element dd:contains("January 25, 2015")'
|
'Missing element dd:contains("January 25, 2015")'
|
||||||
);
|
);
|
||||||
self::assertGreaterThan(
|
$this->assertGreaterThan(
|
||||||
0,
|
0,
|
||||||
$crawler->filter('dd:contains("Foo")')->count(),
|
$crawler->filter('dd:contains("Foo")')->count(),
|
||||||
'Missing element dd:contains("Foo")'
|
'Missing element dd:contains("Foo")'
|
||||||
@@ -188,14 +182,14 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
$form = $button->form();
|
$form = $button->form();
|
||||||
|
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
self::assertTrue($client->getResponse()->isRedirect(sprintf(
|
$this->assertTrue($client->getResponse()->isRedirect(sprintf(
|
||||||
'/en/person/%d/activity/',
|
'/en/person/%d/activity/',
|
||||||
$person->getId()
|
$person->getId()
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$crawler = $client->followRedirect();
|
$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()
|
private function createFakeUser()
|
||||||
{
|
{
|
||||||
$container = self::$kernel->getContainer();
|
$container = static::$kernel->getContainer();
|
||||||
$em = $container->get('doctrine.orm.entity_manager');
|
$em = $container->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
|
//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)
|
private function getActivitiesForPerson(\Chill\PersonBundle\Entity\Person $person)
|
||||||
{
|
{
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
$activities = $em->getRepository('ChillActivityBundle:Activity')
|
$activities = $em->getRepository('ChillActivityBundle:Activity')
|
||||||
@@ -269,7 +263,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private function getAuthenticatedClient($username = 'center a_social')
|
private function getAuthenticatedClient($username = 'center a_social')
|
||||||
{
|
{
|
||||||
return self::createClient([], [
|
return static::createClient([], [
|
||||||
'PHP_AUTH_USER' => $username,
|
'PHP_AUTH_USER' => $username,
|
||||||
'PHP_AUTH_PW' => 'password',
|
'PHP_AUTH_PW' => 'password',
|
||||||
]);
|
]);
|
||||||
@@ -280,7 +274,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private function getPersonFromFixtures()
|
private function getPersonFromFixtures()
|
||||||
{
|
{
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')
|
$person = $em->getRepository('ChillPersonBundle:Person')
|
||||||
@@ -304,14 +298,14 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private function getRandomActivityReason(array $excludeIds = [])
|
private function getRandomActivityReason(array $excludeIds = [])
|
||||||
{
|
{
|
||||||
$reasons = self::$kernel->getContainer()
|
$reasons = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager')
|
->get('doctrine.orm.entity_manager')
|
||||||
->getRepository('ChillActivityBundle:ActivityReason')
|
->getRepository('ChillActivityBundle:ActivityReason')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$reason = $reasons[array_rand($reasons)];
|
$reason = $reasons[array_rand($reasons)];
|
||||||
|
|
||||||
if (in_array($reason->getId(), $excludeIds, true)) {
|
if (in_array($reason->getId(), $excludeIds)) {
|
||||||
return $this->getRandomActivityReason($excludeIds);
|
return $this->getRandomActivityReason($excludeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +317,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private function getRandomActivityType()
|
private function getRandomActivityType()
|
||||||
{
|
{
|
||||||
$types = self::$kernel->getContainer()
|
$types = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager')
|
->get('doctrine.orm.entity_manager')
|
||||||
->getRepository('ChillActivityBundle:ActivityType')
|
->getRepository('ChillActivityBundle:ActivityType')
|
||||||
->findAll();
|
->findAll();
|
||||||
@@ -339,7 +333,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
private function getRandomScope($username, $centerName)
|
private function getRandomScope($username, $centerName)
|
||||||
{
|
{
|
||||||
$user = self::$kernel->getContainer()
|
$user = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager')
|
->get('doctrine.orm.entity_manager')
|
||||||
->getRepository('ChillMainBundle:User')
|
->getRepository('ChillMainBundle:User')
|
||||||
->findOneByUsername($username);
|
->findOneByUsername($username);
|
||||||
@@ -349,20 +343,20 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
. 'does not exists in database. Did you add fixtures ?');
|
. 'does not exists in database. Did you add fixtures ?');
|
||||||
}
|
}
|
||||||
|
|
||||||
$center = self::$kernel->getContainer()
|
$center = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager')
|
->get('doctrine.orm.entity_manager')
|
||||||
->getRepository('ChillMainBundle:Center')
|
->getRepository('ChillMainBundle:Center')
|
||||||
->findOneByName($centerName);
|
->findOneByName($centerName);
|
||||||
|
|
||||||
// get scope reachable by both role UPDATE and DELETE
|
// get scope reachable by both role UPDATE and DELETE
|
||||||
$reachableScopesUpdate = self::$kernel->getContainer()
|
$reachableScopesUpdate = static::$kernel->getContainer()
|
||||||
->get('chill.main.security.authorization.helper')
|
->get('chill.main.security.authorization.helper')
|
||||||
->getReachableScopes(
|
->getReachableScopes(
|
||||||
$user,
|
$user,
|
||||||
new Role('CHILL_ACTIVITY_UPDATE'),
|
new Role('CHILL_ACTIVITY_UPDATE'),
|
||||||
$center
|
$center
|
||||||
);
|
);
|
||||||
$reachableScopesDelete = self::$kernel->getContainer()
|
$reachableScopesDelete = static::$kernel->getContainer()
|
||||||
->get('chill.main.security.authorization.helper')
|
->get('chill.main.security.authorization.helper')
|
||||||
->getReachableScopes(
|
->getReachableScopes(
|
||||||
$user,
|
$user,
|
||||||
@@ -370,8 +364,8 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
$center
|
$center
|
||||||
);
|
);
|
||||||
$reachableScopesId = array_intersect(
|
$reachableScopesId = array_intersect(
|
||||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($reachableScopesId) === 0) {
|
if (count($reachableScopesId) === 0) {
|
||||||
@@ -380,7 +374,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($reachableScopesUpdate as $scope) {
|
foreach ($reachableScopesUpdate as $scope) {
|
||||||
if (in_array($scope->getId(), $reachableScopesId, true)) {
|
if (in_array($scope->getId(), $reachableScopesId)) {
|
||||||
$reachableScopes[] = $scope;
|
$reachableScopes[] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonCategoryControllerTest extends WebTestCase
|
class ActivityReasonCategoryControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
public function testToWrite()
|
public function testToWrite()
|
||||||
{
|
{
|
||||||
self::markTestSkipped();
|
$this->markTestSkipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonControllerTest extends WebTestCase
|
class ActivityReasonControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
public function testToWrite()
|
public function testToWrite()
|
||||||
{
|
{
|
||||||
self::markTestSkipped();
|
$this->markTestSkipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTypeControllerTest extends WebTestCase
|
class ActivityTypeControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
public function testToWrite()
|
public function testToWrite()
|
||||||
{
|
{
|
||||||
self::markTestSkipped();
|
$this->markTestSkipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||||
*/
|
*/
|
||||||
private $aggregator;
|
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');
|
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
|
||||||
|
|
||||||
@@ -61,11 +57,11 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
|||||||
|
|
||||||
public function getQueryBuilders()
|
public function getQueryBuilders()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||||
*/
|
*/
|
||||||
private $aggregator;
|
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');
|
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
|
||||||
|
|
||||||
@@ -60,11 +56,11 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
|||||||
|
|
||||||
public function getQueryBuilders()
|
public function getQueryBuilders()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
|
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
|
||||||
*/
|
*/
|
||||||
private $aggregator;
|
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');
|
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
|
||||||
|
|
||||||
@@ -60,11 +56,11 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
|||||||
|
|
||||||
public function getQueryBuilders()
|
public function getQueryBuilders()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class CountActivityTest extends AbstractExportTest
|
class CountActivityTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var
|
||||||
*/
|
*/
|
||||||
private $export;
|
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();
|
$container = self::$kernel->getContainer();
|
||||||
|
|
||||||
$this->export = $container->get('chill.activity.export.count_activity');
|
$this->export = $container->get('chill.activity.export.count_activity');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ListActivityTest extends AbstractExportTest
|
class ListActivityTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\ActivityBundle\Export\Export\ListActivity
|
* @var \Chill\ActivityBundle\Export\Export\ListActivity
|
||||||
*/
|
*/
|
||||||
private $export;
|
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();
|
$container = self::$kernel->getContainer();
|
||||||
|
|
||||||
$this->export = $container->get('chill.activity.export.list_activity');
|
$this->export = $container->get('chill.activity.export.list_activity');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class StatActivityDurationSumTest extends AbstractExportTest
|
class StatActivityDurationSumTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
|
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
|
||||||
*/
|
*/
|
||||||
private $export;
|
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();
|
$container = self::$kernel->getContainer();
|
||||||
|
|
||||||
$this->export = $container->get('chill.activity.export.sum_activity_duration');
|
$this->export = $container->get('chill.activity.export.sum_activity_duration');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
@@ -20,18 +16,18 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonFilterTest extends AbstractFilterTest
|
class ActivityReasonFilterTest extends AbstractFilterTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
|
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
|
||||||
*/
|
*/
|
||||||
private $filter;
|
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');
|
$this->filter = $container->get('chill.activity.export.reason_filter');
|
||||||
|
|
||||||
@@ -52,11 +48,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
|||||||
|
|
||||||
public function getFormData()
|
public function getFormData()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
$reasons = $em->createQuery('SELECT reason '
|
$reasons = $em->createQuery('SELECT reason '
|
||||||
@@ -73,11 +69,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
|||||||
|
|
||||||
public function getQueryBuilders()
|
public function getQueryBuilders()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -1,38 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use function array_slice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
|
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
|
||||||
*/
|
*/
|
||||||
private $filter;
|
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.'
|
$this->filter = $container->get('chill.activity.export.'
|
||||||
. 'person_having_an_activity_between_date_filter');
|
. 'person_having_an_activity_between_date_filter');
|
||||||
@@ -73,11 +68,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
|||||||
|
|
||||||
public function getQueryBuilders()
|
public function getQueryBuilders()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = self::$kernel->getContainer()
|
$em = static::$kernel->getContainer()
|
||||||
->get('doctrine.orm.entity_manager');
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -102,11 +97,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
|||||||
*/
|
*/
|
||||||
private function getActivityReasons()
|
private function getActivityReasons()
|
||||||
{
|
{
|
||||||
if (null === self::$kernel) {
|
if (null === static::$kernel) {
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$kernel->getContainer()
|
return static::$kernel->getContainer()
|
||||||
->get('chill_activity.repository.reason')
|
->get('chill_activity.repository.reason')
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
@@ -25,7 +21,7 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTypeTest extends KernelTestCase
|
class ActivityTypeTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Chill\MainBundle\Entity\Center
|
* @var \Chill\MainBundle\Entity\Center
|
||||||
@@ -47,7 +43,7 @@ final class ActivityTypeTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
|
||||||
@@ -93,9 +89,9 @@ final class ActivityTypeTest extends KernelTestCase
|
|||||||
|
|
||||||
$form->submit([]);
|
$form->submit([]);
|
||||||
|
|
||||||
self::assertTrue($form->isSynchronized());
|
$this->assertTrue($form->isSynchronized());
|
||||||
self::assertTrue($form->isValid());
|
$this->assertTrue($form->isValid());
|
||||||
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
|
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormSubmitting()
|
public function testFormSubmitting()
|
||||||
@@ -118,25 +114,25 @@ final class ActivityTypeTest extends KernelTestCase
|
|||||||
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
|
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
|
||||||
// var_dump($form->getErrors());
|
// var_dump($form->getErrors());
|
||||||
|
|
||||||
self::assertTrue($form->isSynchronized(), 'Test the form is synchronized');
|
$this->assertTrue($form->isSynchronized(), 'Test the form is synchronized');
|
||||||
self::assertTrue($form->isValid(), 'test the form is valid');
|
$this->assertTrue($form->isValid(), 'test the form is valid');
|
||||||
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
|
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||||
|
|
||||||
// test the activity
|
// test the activity
|
||||||
/** @var Activity $activity */
|
/* @var $activity Activity */
|
||||||
$activity = $form->getData()['activity'];
|
$activity = $form->getData()['activity'];
|
||||||
|
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
'09-03-2015',
|
'09-03-2015',
|
||||||
$activity->getDate()->format('d-m-Y'),
|
$activity->getDate()->format('d-m-Y'),
|
||||||
'Test the date is correct'
|
'Test the date is correct'
|
||||||
);
|
);
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
'00:05',
|
'00:05',
|
||||||
$activity->getDurationTime()->format('H:i'),
|
$activity->getDurationTime()->format('H:i'),
|
||||||
'Test the formatted hour is correct'
|
'Test the formatted hour is correct'
|
||||||
);
|
);
|
||||||
self::assertTrue($activity->getAttendee());
|
$this->assertEquals(true, $activity->getAttendee());
|
||||||
// $this->assertEquals('blabla', $activity->getRemark());
|
// $this->assertEquals('blabla', $activity->getRemark());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,14 +166,14 @@ final class ActivityTypeTest extends KernelTestCase
|
|||||||
'attendee' => true,
|
'attendee' => true,
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
self::assertTrue($form->isSynchronized());
|
$this->assertTrue($form->isSynchronized());
|
||||||
self::assertTrue($form->isValid());
|
$this->assertTrue($form->isValid());
|
||||||
|
|
||||||
// test the activity
|
// test the activity
|
||||||
/** @var Activity $activity */
|
/* @var $activity Activity */
|
||||||
$activity = $form->getData()['activity'];
|
$activity = $form->getData()['activity'];
|
||||||
|
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
'00:01',
|
'00:01',
|
||||||
$activity->getDurationTime()->format('H:i'),
|
$activity->getDurationTime()->format('H:i'),
|
||||||
'Test the formatted hour is correct'
|
'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
|
// test the view : we want to be sure that the entry with 60 seconds exists
|
||||||
$view = $form->createView();
|
$view = $form->createView();
|
||||||
|
|
||||||
self::assertTrue(isset($view['activity']['durationTime']));
|
$this->assertTrue(isset($view['activity']['durationTime']));
|
||||||
|
|
||||||
// map all the values in an array
|
// map all the values in an array
|
||||||
$values = array_map(
|
$values = array_map(
|
||||||
static function ($choice) { return $choice->value; },
|
function ($choice) { return $choice->value; },
|
||||||
$view['activity']['durationTime']->vars['choices']
|
$view['activity']['durationTime']->vars['choices']
|
||||||
);
|
);
|
||||||
|
|
||||||
self::assertContains(60, $values);
|
$this->assertContains(60, $values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
||||||
@@ -24,14 +20,14 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class TranslatableActivityReasonTest extends TypeTestCase
|
class TranslatableActivityReasonTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Prophecy\Prophet
|
* @var Prophecy\Prophet
|
||||||
*/
|
*/
|
||||||
private static $prophet;
|
private static $prophet;
|
||||||
|
|
||||||
protected function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
@@ -42,7 +38,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
|
|||||||
$this->getTranslatableStringHelper()
|
$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);
|
$request->getLocale()->willReturn($fallbackLocale);
|
||||||
|
|
||||||
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
|
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
|
||||||
$requestStack->getCurrentRequest()->will(static function () use ($request) {
|
$requestStack->getCurrentRequest()->will(function () use ($request) {
|
||||||
return $request;
|
return $request;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
|
||||||
@@ -21,7 +17,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class TranslatableActivityTypeTest extends KernelTestCase
|
class TranslatableActivityTypeTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\Form\FormBuilderInterface
|
* @var \Symfony\Component\Form\FormBuilderInterface
|
||||||
@@ -33,7 +29,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
protected $container;
|
protected $container;
|
||||||
|
|
||||||
protected function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
|
||||||
@@ -63,13 +59,13 @@ final class TranslatableActivityTypeTest extends KernelTestCase
|
|||||||
'type' => $type->getId(),
|
'type' => $type->getId(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertTrue($form->isSynchronized());
|
$this->assertTrue($form->isSynchronized());
|
||||||
self::assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
\Chill\ActivityBundle\Entity\ActivityType::class,
|
\Chill\ActivityBundle\Entity\ActivityType::class,
|
||||||
$form->getData()['type'],
|
$form->getData()['type'],
|
||||||
'The data is an instance of Chill\\ActivityBundle\\Entity\\ActivityType'
|
'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
|
// test the ordering of the types in the form
|
||||||
// since 2016-11-14 the types are not alphabetically ordered, skipping
|
// since 2016-11-14 the types are not alphabetically ordered, skipping
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Security\Authorization;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Test\PrepareActivityTrait;
|
use Chill\ActivityBundle\Test\PrepareActivityTrait;
|
||||||
@@ -28,7 +24,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityVoterTest extends KernelTestCase
|
class ActivityVoterTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
use PrepareActivityTrait;
|
use PrepareActivityTrait;
|
||||||
use PrepareCenterTrait;
|
use PrepareCenterTrait;
|
||||||
@@ -46,10 +42,10 @@ final class ActivityVoterTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
protected $voter;
|
protected $voter;
|
||||||
|
|
||||||
protected function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
static::bootKernel();
|
||||||
$this->voter = self::$kernel->getContainer()
|
$this->voter = static::$kernel->getContainer()
|
||||||
->get('chill.activity.security.authorization.activity_voter');
|
->get('chill.activity.security.authorization.activity_voter');
|
||||||
$this->prophet = new \Prophecy\Prophet();
|
$this->prophet = new \Prophecy\Prophet();
|
||||||
}
|
}
|
||||||
@@ -115,7 +111,7 @@ final class ActivityVoterTest extends KernelTestCase
|
|||||||
$scope = $this->prepareScope(1, 'default');
|
$scope = $this->prepareScope(1, 'default');
|
||||||
$activity = $this->prepareActivity($scope, $person);
|
$activity = $this->prepareActivity($scope, $person);
|
||||||
|
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
VoterInterface::ACCESS_DENIED,
|
VoterInterface::ACCESS_DENIED,
|
||||||
$this->voter->vote($token, $activity, ['CHILL_ACTIVITY_SEE']),
|
$this->voter->vote($token, $activity, ['CHILL_ACTIVITY_SEE']),
|
||||||
'assert that a null user is not allowed to see'
|
'assert that a null user is not allowed to see'
|
||||||
@@ -140,7 +136,7 @@ final class ActivityVoterTest extends KernelTestCase
|
|||||||
$token = $this->prepareToken($user);
|
$token = $this->prepareToken($user);
|
||||||
$activity = $this->prepareActivity($scope, $this->preparePerson($center));
|
$activity = $this->prepareActivity($scope, $this->preparePerson($center));
|
||||||
|
|
||||||
self::assertEquals(
|
$this->assertEquals(
|
||||||
$expectedResult,
|
$expectedResult,
|
||||||
$this->voter->vote($token, $activity, [$attribute]),
|
$this->voter->vote($token, $activity, [$attribute]),
|
||||||
$message
|
$message
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\ActivityBundle\Tests\Timeline;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
@@ -19,10 +15,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
* @internal
|
* @internal
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class TimelineProviderTest extends WebTestCase
|
class TimelineProviderTest extends WebTestCase
|
||||||
{
|
{
|
||||||
public function testAnActivityIsShownOnTimeline()
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Timeline;
|
namespace Chill\ActivityBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
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\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
use function count;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide activity for inclusion in timeline.
|
* Provide activity for inclusion in timeline.
|
||||||
*/
|
*/
|
||||||
@@ -64,9 +58,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
$this->user = $storage->getToken()->getUser();
|
$this->user = $storage->getToken()->getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
$this->checkContext($context);
|
$this->checkContext($context);
|
||||||
@@ -89,9 +80,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getEntities(array $ids)
|
public function getEntities(array $ids)
|
||||||
{
|
{
|
||||||
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
||||||
@@ -106,9 +94,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getEntityTemplate($entity, $context, array $args)
|
public function getEntityTemplate($entity, $context, array $args)
|
||||||
{
|
{
|
||||||
$this->checkContext($context);
|
$this->checkContext($context);
|
||||||
@@ -123,9 +108,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function supportsType($type)
|
public function supportsType($type)
|
||||||
{
|
{
|
||||||
return 'activity' === $type;
|
return 'activity' === $type;
|
||||||
@@ -189,7 +171,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
|
|
||||||
foreach ($reachableCenters as $center) {
|
foreach ($reachableCenters as $center) {
|
||||||
$reachablesScopesId = array_map(
|
$reachablesScopesId = array_map(
|
||||||
static function (Scope $scope) {
|
function (Scope $scope) {
|
||||||
return $scope->getId();
|
return $scope->getId();
|
||||||
},
|
},
|
||||||
$this->helper->getReachableScopes(
|
$this->helper->getReachableScopes(
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
@@ -24,7 +20,7 @@ class Version20150701091248 extends AbstractMigration
|
|||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
// 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 Activity DROP CONSTRAINT FK_55026B0C59BB1592');
|
||||||
$this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2');
|
$this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2');
|
||||||
@@ -42,7 +38,7 @@ class Version20150701091248 extends AbstractMigration
|
|||||||
public function up(Schema $schema): void
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
// 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 Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
@@ -24,7 +20,7 @@ class Version20150702093317 extends AbstractMigration
|
|||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
// 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 DROP COLUMN name;');
|
||||||
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;');
|
$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
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
// 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 DROP COLUMN label;');
|
||||||
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');
|
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
@@ -24,7 +20,7 @@ class Version20150704091347 extends AbstractMigration
|
|||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
// 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 remark SET NOT NULL;');
|
||||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP 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
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
// 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 remark DROP NOT NULL;');
|
||||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
|
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
@@ -27,7 +23,7 @@ class Version20160222103457 extends AbstractMigration
|
|||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->abortIf(
|
$this->abortIf(
|
||||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||||
'Migration can only be executed safely on \'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...
|
// try to keep at least on activity reason...
|
||||||
$this->addSql(
|
$this->addSql(
|
||||||
'UPDATE activity
|
'UPDATE activity
|
||||||
SET reason_id=rid
|
SET reason_id=rid
|
||||||
FROM (
|
FROM (
|
||||||
SELECT activity_id AS aid, MIN(activityreason_id) AS rid
|
SELECT activity_id AS aid, MIN(activityreason_id) AS rid
|
||||||
@@ -54,7 +50,7 @@ class Version20160222103457 extends AbstractMigration
|
|||||||
public function up(Schema $schema): void
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->abortIf(
|
$this->abortIf(
|
||||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||||
'Migration can only be executed safely on \'postgresql\'.'
|
'Migration can only be executed safely on \'postgresql\'.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Calculator;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
||||||
|
@@ -1,22 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
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 implode;
|
||||||
|
|
||||||
class CalculatorManager
|
class CalculatorManager
|
||||||
{
|
{
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Calculator;
|
||||||
|
|
||||||
class CalculatorResult
|
class CalculatorResult
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\AMLI\BudgetBundle;
|
namespace Chill\AMLI\BudgetBundle;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\DependencyInjection\Compiler\CalculatorCompilerPass;
|
use Chill\AMLI\BudgetBundle\DependencyInjection\Compiler\CalculatorCompilerPass;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Config;
|
||||||
|
|
||||||
class ConfigRepository
|
class ConfigRepository
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
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\HttpFoundation\Request;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use function get_class;
|
|
||||||
|
|
||||||
abstract class AbstractElementController extends Controller
|
abstract class AbstractElementController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +111,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() and $form->isValid()) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
@@ -141,7 +135,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function _new(Person $person, Request $request, $template, $flashMessageOnSuccess)
|
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()
|
$element = $this->createNewElement()
|
||||||
->setPerson($person);
|
->setPerson($person);
|
||||||
|
|
||||||
@@ -152,7 +146,7 @@ abstract class AbstractElementController extends Controller
|
|||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() and $form->isValid()) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($element);
|
$em->persist($element);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Entity\Charge;
|
use Chill\AMLI\BudgetBundle\Entity\Charge;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Calculator\CalculatorManager;
|
use Chill\AMLI\BudgetBundle\Calculator\CalculatorManager;
|
||||||
@@ -25,7 +21,7 @@ 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 count;
|
use function array_merge;
|
||||||
|
|
||||||
class ElementController extends Controller
|
class ElementController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Entity\Resource;
|
use Chill\AMLI\BudgetBundle\Entity\Resource;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* For the full copyright and license information, please view
|
||||||
* the LICENSE file that was distributed with this source code.
|
* 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;
|
namespace Chill\AMLI\BudgetBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\AMLI\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
use Chill\AMLI\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
||||||
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||||||
*/
|
*/
|
||||||
class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInterface
|
class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
@@ -54,7 +47,7 @@ class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInte
|
|||||||
$this->prependRoutes($container);
|
$this->prependRoutes($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** (non-PHPdoc).
|
/* (non-PHPdoc)
|
||||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||||
*/
|
*/
|
||||||
public function prependRoutes(ContainerBuilder $container)
|
public function prependRoutes(ContainerBuilder $container)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user