mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-11 01:04:57 +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.result.cache
|
||||
###< phpunit/phpunit ###
|
||||
|
||||
|
@@ -30,6 +30,10 @@ variables:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
# fetch the chill-app using git submodules
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_URL: redis://redis:6379
|
||||
|
||||
|
||||
# Run our tests
|
||||
test:
|
||||
|
71
.php-cs-fixer.dist.php
Normal file
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": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"drupol/php-conventions": "4.*",
|
||||
"drupol/php-conventions": "5.*",
|
||||
"fakerphp/faker": "^1.13",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"symfony/dotenv": "^5.1",
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
@@ -20,7 +16,7 @@ use Doctrine\ORM\Query\Expr;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
|
||||
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
|
||||
{
|
||||
// add specific role for this filter
|
||||
public function addRole()
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Export\ExportInterface;
|
||||
@@ -93,7 +89,7 @@ class CountPerson implements ExportInterface
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
// we gather all center the user choose.
|
||||
$centers = array_map(static function ($el) {
|
||||
$centers = array_map(function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
|
||||
|
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>
|
||||
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
||||
Helpers for building a REST API <api.rst>
|
||||
Routing <routing.rst>
|
||||
Menus <menus.rst>
|
||||
Forms <forms.rst>
|
||||
|
@@ -7,6 +7,8 @@
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
.. _pagination-ref:
|
||||
|
||||
Pagination
|
||||
##########
|
||||
|
||||
@@ -15,7 +17,7 @@ The Bundle :code:`Chill\MainBundle` provides a **Pagination** api which allow yo
|
||||
A simple example
|
||||
****************
|
||||
|
||||
In the controller, get the :class:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
|
||||
In the controller, get the :code:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
|
||||
|
||||
|
||||
.. literalinclude:: pagination/example.php
|
||||
|
@@ -1,21 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MyBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
class example extends Controller
|
||||
class ItemController extends Controller
|
||||
{
|
||||
public function yourAction()
|
||||
{
|
||||
@@ -40,12 +36,13 @@ class example extends Controller
|
||||
// use the paginator to get the number of items to display
|
||||
->setMaxResults($paginator->getItemsPerPage());
|
||||
|
||||
return $this->render(
|
||||
'ChillMyBundle:Item:list.html.twig',
|
||||
[
|
||||
'items' => $items,
|
||||
'paginator' => $paginator,
|
||||
]
|
||||
);
|
||||
return $this
|
||||
->render(
|
||||
'ChillMyBundle:Item:list.html.twig',
|
||||
[
|
||||
'items' => $items,
|
||||
'paginator' => $paginator,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\HealthBundle\Controller;
|
||||
|
||||
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
||||
@@ -29,7 +25,7 @@ class ConsultationController extends Controller
|
||||
*/
|
||||
public function listAction($id)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $this->get('chill.person.repository.person')
|
||||
->find($id);
|
||||
|
||||
@@ -39,7 +35,7 @@ class ConsultationController extends Controller
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
||||
/** @var \Chill\MainBundle\Security\Authorization\AuthorizationHelper $authorizationHelper */
|
||||
/* @var $authorizationHelper \Chill\MainBundle\Security\Authorization\AuthorizationHelper */
|
||||
$authorizationHelper = $this->get('chill.main.security.'
|
||||
. 'authorization.helper');
|
||||
|
||||
|
@@ -1,18 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Chill\MainBundle\DependencyInjection\Configuration.php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
||||
@@ -23,7 +17,7 @@ namespace Chill\MainBundle\DependencyInjection;
|
||||
/**
|
||||
* Configure the main bundle.
|
||||
*/
|
||||
class ChillMainConfiguration implements ConfigurationInterface
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
use AddWidgetConfigurationTrait;
|
||||
|
||||
@@ -33,7 +27,7 @@ class ChillMainConfiguration implements ConfigurationInterface
|
||||
private $containerBuilder;
|
||||
|
||||
public function __construct(
|
||||
array $widgetFactories,
|
||||
array $widgetFactories = [],
|
||||
ContainerBuilder $containerBuilder
|
||||
) {
|
||||
// we register here widget factories (see below)
|
||||
@@ -42,9 +36,6 @@ class ChillMainConfiguration implements ConfigurationInterface
|
||||
$this->containerBuilder = $containerBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
@@ -62,8 +53,7 @@ class ChillMainConfiguration implements ConfigurationInterface
|
||||
->end() // end of widgets/children
|
||||
->end() // end of widgets
|
||||
->end() // end of root/children
|
||||
->end() // end of root
|
||||
;
|
||||
->end(); // end of root
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
@@ -1,18 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
//Chill\MainBundle\DependencyInjection\ChillMainExtension.php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
||||
|
@@ -1,18 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Chill/PersonBundle/Widget/PersonListWidgetFactory
|
||||
|
||||
namespace Chill\PersonBundle\Widget;
|
||||
|
||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
||||
@@ -22,7 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
/**
|
||||
* add configuration for the person_list widget.
|
||||
*/
|
||||
class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
||||
class PersonListWidgetFactory extends AbstractWidgetFactory
|
||||
{
|
||||
/*
|
||||
* append the option to the configuration
|
||||
@@ -42,8 +36,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
||||
->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array with the allowed places where the widget can be rendered.
|
||||
/*
|
||||
* return an array with the allowed places where the widget can be rendered
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@@ -65,8 +59,8 @@ class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
||||
return 'chill_person.widget.person_list';
|
||||
}
|
||||
|
||||
/**
|
||||
* return the widget alias.
|
||||
/*
|
||||
* return the widget alias
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@@ -1,18 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Chill/PersonBundle/Widget/PersonListWidget.php
|
||||
|
||||
namespace Chill\PersonBundle\Widget;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
@@ -33,7 +27,7 @@ use Twig_Environment;
|
||||
*
|
||||
* The configuration is defined by `PersonListWidgetFactory`
|
||||
*/
|
||||
class ChillPersonAddAPersonWidget implements WidgetInterface
|
||||
class PersonListWidget implements WidgetInterface
|
||||
{
|
||||
/**
|
||||
* the authorization helper.
|
||||
|
@@ -1,18 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Chill/PersonBundle/DependencyInjection/ChillPersonExtension.php
|
||||
|
||||
namespace Chill\PersonBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@@ -26,9 +20,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
*/
|
||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// ...
|
||||
|
@@ -2,7 +2,8 @@ imports:
|
||||
- { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml }
|
||||
|
||||
parameters:
|
||||
tasks.phpcsfixer.config: .php_cs.dist
|
||||
tasks.phpcsfixer.config: .php-cs-fixer.dist.php
|
||||
tasks.license.name: AGPL-3.0
|
||||
tasks.license.holder: Champs-Libres
|
||||
tasks.license.date_from: 2001
|
||||
tasks.phpcsfixer.allow_risky: false
|
||||
|
@@ -18,11 +18,11 @@
|
||||
<testsuite name="MainBundle">
|
||||
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
||||
</testsuite>
|
||||
|
||||
<!--
|
||||
<testsuite name="PersonBundle">
|
||||
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
||||
</testsuite>
|
||||
|
||||
-->
|
||||
</testsuites>
|
||||
|
||||
<listeners>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
Chill is a software for social workers.
|
||||
Chill is a software for social workers
|
||||
|
||||
For the full copyright and license information, please view
|
||||
the LICENSE file that was distributed with this source code.
|
||||
|
||||
@see https://www.champs-libres.coop/
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
@@ -25,6 +21,9 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
/**
|
||||
* Class ActivityController.
|
||||
*/
|
||||
class ActivityController extends AbstractController
|
||||
{
|
||||
/**
|
||||
@@ -128,7 +127,7 @@ class ActivityController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
/** @var Activity $activity */
|
||||
/* @var $activity Activity */
|
||||
$activity = $em->getRepository('ChillActivityBundle:Activity')
|
||||
->find($id);
|
||||
$person = $activity->getPerson();
|
||||
@@ -152,7 +151,7 @@ class ActivityController extends AbstractController
|
||||
'comment' => $activity->getComment()->getComment(),
|
||||
'scope_id' => $activity->getScope()->getId(),
|
||||
'reasons_ids' => $activity->getReasons()
|
||||
->map(static function ($ar) {
|
||||
->map(function ($ar) {
|
||||
return $ar->getId();
|
||||
})
|
||||
->toArray(),
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* ActivityReasonCategory controller.
|
||||
*/
|
||||
class ActivityReasonCategoryController extends AbstractController
|
||||
{
|
||||
/**
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* ActivityReason controller.
|
||||
*/
|
||||
class ActivityReasonController extends AbstractController
|
||||
{
|
||||
/**
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
@@ -19,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class ActivityTypeController.
|
||||
*/
|
||||
class ActivityTypeController extends AbstractController
|
||||
{
|
||||
/**
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
@@ -22,12 +18,10 @@ use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory as FakerFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Load reports into DB.
|
||||
*/
|
||||
class LoadActivity extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
||||
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
|
||||
{
|
||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
|
||||
@@ -53,7 +47,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
||||
->findAll();
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$activityNbr = mt_rand(0, 3);
|
||||
$activityNbr = rand(0, 3);
|
||||
|
||||
for ($i = 0; $i < $activityNbr; ++$i) {
|
||||
echo 'Creating an activity type for : ' . $person . "\n";
|
||||
@@ -77,7 +71,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
||||
|
||||
$usedId = [];
|
||||
|
||||
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
|
||||
for ($i = 0; rand(0, 4) > $i; ++$i) {
|
||||
$reason = $this->getRandomActivityReason($usedId);
|
||||
$usedId[] = $reason->getId();
|
||||
$activity->addReason($reason);
|
||||
@@ -95,7 +89,7 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
||||
{
|
||||
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
||||
|
||||
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
|
||||
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
|
||||
// we have a reason which should be excluded. Find another...
|
||||
return $this->getRandomActivityReason($excludingIds);
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||
@@ -19,10 +17,10 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
use function in_array;
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
||||
* and a role CHILL_ACTIVITY_SEE for administrative.
|
||||
*/
|
||||
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function getOrder()
|
||||
@@ -45,9 +43,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'])) {
|
||||
break 2; // we do not want any power on social or administrative
|
||||
}
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DependencyInjection;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
*/
|
||||
class ChillActivityExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
@@ -66,7 +59,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
||||
]);
|
||||
}
|
||||
|
||||
/** (non-PHPdoc).
|
||||
/* (non-PHPdoc)
|
||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||
*/
|
||||
public function prependRoutes(ContainerBuilder $container)
|
||||
|
@@ -1,23 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
use function is_int;
|
||||
|
||||
/**
|
||||
* This is the class that validates and merges configuration from your app/config files.
|
||||
*
|
||||
@@ -25,9 +19,6 @@ use function is_int;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_activity');
|
||||
@@ -64,7 +55,7 @@ class Configuration implements ConfigurationInterface
|
||||
->info('The number of seconds of this duration. Must be an integer.')
|
||||
->cannotBeEmpty()
|
||||
->validate()
|
||||
->ifTrue(static function ($data) {
|
||||
->ifTrue(function ($data) {
|
||||
return !is_int($data);
|
||||
})->thenInvalid('The value %s is not a valid integer')
|
||||
->end()
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
@@ -27,6 +23,8 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Activity.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="activity")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
|
@@ -1,21 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class ActivityReason.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="activityreason")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
|
@@ -1,22 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class ActivityReasonCategory.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="activityreasoncategory")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
|
@@ -1,21 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class ActivityType.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="activitytype")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
@@ -26,9 +22,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
class ActivityReasonAggregator implements
|
||||
AggregatorInterface,
|
||||
ExportElementValidatedInterface
|
||||
@@ -86,7 +79,7 @@ class ActivityReasonAggregator implements
|
||||
array_key_exists('activity', $join)
|
||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||
)
|
||||
|| (!array_key_exists('activity', $join))
|
||||
or (!array_key_exists('activity', $join))
|
||||
) {
|
||||
$qb->add(
|
||||
'join',
|
||||
@@ -140,6 +133,7 @@ class ActivityReasonAggregator implements
|
||||
$this->reasonRepository->findBy(['id' => $values]);
|
||||
|
||||
break;
|
||||
|
||||
case 'categories':
|
||||
$this->categoryRepository->findBy(['id' => $values]);
|
||||
|
||||
@@ -162,7 +156,7 @@ class ActivityReasonAggregator implements
|
||||
|
||||
switch ($data['level']) {
|
||||
case 'reasons':
|
||||
/** @var \Chill\ActivityBundle\Entity\ActivityReason $r */
|
||||
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
|
||||
$r = $this->reasonRepository->find($value);
|
||||
|
||||
return $this->stringHelper->localize($r->getCategory()->getName())
|
||||
@@ -170,6 +164,7 @@ class ActivityReasonAggregator implements
|
||||
. $this->stringHelper->localize($r->getName());
|
||||
|
||||
break;
|
||||
|
||||
case 'categories':
|
||||
$c = $this->categoryRepository->find($value);
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
@@ -78,7 +74,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
||||
return 'Activity type';
|
||||
}
|
||||
|
||||
/** @var \Chill\ActivityBundle\Entity\ActivityType $r */
|
||||
/* @var $r \Chill\ActivityBundle\Entity\ActivityType */
|
||||
$t = $this->typeRepository->find($value);
|
||||
|
||||
return $this->stringHelper->localize($t->getName());
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Export;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
@@ -53,7 +49,7 @@ class CountActivity implements ExportInterface
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
return static function ($value) {
|
||||
return function ($value) {
|
||||
return '_header' === $value ?
|
||||
'Number of activities'
|
||||
:
|
||||
@@ -84,7 +80,7 @@ class CountActivity implements ExportInterface
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
$centers = array_map(static function ($el) {
|
||||
$centers = array_map(function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Export;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
@@ -29,8 +25,6 @@ use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Create a list for all activities.
|
||||
@@ -76,9 +70,6 @@ class ListActivity implements ListInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('fields', ChoiceType::class, [
|
||||
@@ -87,7 +78,7 @@ class ListActivity implements ListInterface
|
||||
'choices' => array_combine($this->fields, $this->fields),
|
||||
'label' => 'Fields to include in export',
|
||||
'constraints' => [new Callback([
|
||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||
'callback' => function ($selected, ExecutionContextInterface $context) {
|
||||
if (count($selected) === 0) {
|
||||
$context->buildViolation('You must select at least one element')
|
||||
->atPath('fields')
|
||||
@@ -99,8 +90,6 @@ class ListActivity implements ListInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getAllowedFormattersTypes()
|
||||
@@ -117,7 +106,7 @@ class ListActivity implements ListInterface
|
||||
{
|
||||
switch ($key) {
|
||||
case 'date':
|
||||
return static function ($value) {
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'date';
|
||||
}
|
||||
@@ -126,16 +115,18 @@ class ListActivity implements ListInterface
|
||||
|
||||
return $date->format('d-m-Y');
|
||||
};
|
||||
|
||||
case 'attendee':
|
||||
return static function ($value) {
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'attendee';
|
||||
}
|
||||
|
||||
return $value ? 1 : 0;
|
||||
};
|
||||
|
||||
case 'list_reasons':
|
||||
/** @var EntityRepository $activityReasonsRepository */
|
||||
/* @var $activityReasonsRepository EntityRepository */
|
||||
$activityRepository = $this->entityManager
|
||||
->getRepository('ChillActivityBundle:Activity');
|
||||
|
||||
@@ -155,6 +146,7 @@ class ListActivity implements ListInterface
|
||||
. '"';
|
||||
}, $activity->getReasons()->toArray()));
|
||||
};
|
||||
|
||||
case 'circle_name':
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
@@ -164,6 +156,7 @@ class ListActivity implements ListInterface
|
||||
return $this->translatableStringHelper
|
||||
->localize(json_decode($value, true));
|
||||
};
|
||||
|
||||
case 'type_name':
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
@@ -175,7 +168,7 @@ class ListActivity implements ListInterface
|
||||
};
|
||||
|
||||
default:
|
||||
return static function ($value) use ($key) {
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return $key;
|
||||
}
|
||||
@@ -207,7 +200,7 @@ class ListActivity implements ListInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
$centers = array_map(function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
|
||||
@@ -227,39 +220,46 @@ class ListActivity implements ListInterface
|
||||
->setParameter('authorized_centers', $centers);
|
||||
|
||||
foreach ($this->fields as $f) {
|
||||
if (in_array($f, $data['fields'], true)) {
|
||||
if (in_array($f, $data['fields'])) {
|
||||
switch ($f) {
|
||||
case 'id':
|
||||
$qb->addSelect('activity.id AS id');
|
||||
|
||||
break;
|
||||
|
||||
case 'person_firstname':
|
||||
$qb->addSelect('person.firstName AS person_firstname');
|
||||
|
||||
break;
|
||||
|
||||
case 'person_lastname':
|
||||
$qb->addSelect('person.lastName AS person_lastname');
|
||||
|
||||
break;
|
||||
|
||||
case 'person_id':
|
||||
$qb->addSelect('person.id AS person_id');
|
||||
|
||||
break;
|
||||
|
||||
case 'user_username':
|
||||
$qb->join('activity.user', 'user');
|
||||
$qb->addSelect('user.username AS user_username');
|
||||
|
||||
break;
|
||||
|
||||
case 'circle_name':
|
||||
$qb->join('activity.scope', 'circle');
|
||||
$qb->addSelect('circle.name AS circle_name');
|
||||
|
||||
break;
|
||||
|
||||
case 'type_name':
|
||||
$qb->join('activity.type', 'type');
|
||||
$qb->addSelect('type.name AS type_name');
|
||||
|
||||
break;
|
||||
|
||||
case 'list_reasons':
|
||||
// this is a trick... The reasons is filled with the
|
||||
// activity id which will be used to load reasons
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Export;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
@@ -81,7 +77,7 @@ class StatActivityDuration implements ExportInterface
|
||||
$header = 'Sum of activities duration';
|
||||
}
|
||||
|
||||
return static function ($value) use ($header) {
|
||||
return function ($value) use ($header) {
|
||||
return '_header' === $value ?
|
||||
$header
|
||||
:
|
||||
@@ -113,7 +109,7 @@ class StatActivityDuration implements ExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
$centers = array_map(function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
@@ -84,7 +80,7 @@ class ActivityDateFilter implements FilterInterface
|
||||
]);
|
||||
|
||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
||||
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||
$filterForm = $event->getForm()->getParent();
|
||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
@@ -27,12 +23,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
class ActivityReasonFilter implements
|
||||
ExportElementValidatedInterface,
|
||||
FilterInterface
|
||||
FilterInterface,
|
||||
ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
* The repository for activity reasons.
|
||||
@@ -71,7 +64,7 @@ class ActivityReasonFilter implements
|
||||
array_key_exists('activity', $join)
|
||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||
)
|
||||
|| (!array_key_exists('activity', $join))
|
||||
or (!array_key_exists('activity', $join))
|
||||
) {
|
||||
$qb->add(
|
||||
'join',
|
||||
@@ -102,10 +95,10 @@ class ActivityReasonFilter implements
|
||||
|
||||
$builder->add('reasons', EntityType::class, [
|
||||
'class' => 'ChillActivityBundle:ActivityReason',
|
||||
'choice_label' => static function (ActivityReason $reason) use ($helper) {
|
||||
'choice_label' => function (ActivityReason $reason) use ($helper) {
|
||||
return $helper->localize($reason->getName());
|
||||
},
|
||||
'group_by' => static function (ActivityReason $reason) use ($helper) {
|
||||
'group_by' => function (ActivityReason $reason) use ($helper) {
|
||||
return $helper->localize($reason->getCategory()->getName());
|
||||
},
|
||||
'multiple' => true,
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
@@ -27,11 +23,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function count;
|
||||
|
||||
class ActivityTypeFilter implements
|
||||
ExportElementValidatedInterface,
|
||||
FilterInterface
|
||||
FilterInterface,
|
||||
ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
* @var TranslatableStringHelper
|
||||
@@ -85,7 +79,7 @@ class ActivityTypeFilter implements
|
||||
|
||||
$builder->add('types', EntityType::class, [
|
||||
'class' => ActivityType::class,
|
||||
'choice_label' => static function (ActivityType $type) use ($helper) {
|
||||
'choice_label' => function (ActivityType $type) use ($helper) {
|
||||
return $helper->localize($type->getName());
|
||||
},
|
||||
'multiple' => true,
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
@@ -30,11 +26,9 @@ use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
use function count;
|
||||
|
||||
class PersonHavingActivityBetweenDateFilter implements
|
||||
ExportElementValidatedInterface,
|
||||
FilterInterface
|
||||
FilterInterface,
|
||||
ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityRepository
|
||||
@@ -151,7 +145,7 @@ class PersonHavingActivityBetweenDateFilter implements
|
||||
]);
|
||||
|
||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
||||
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||
$filterForm = $event->getForm()->getParent();
|
||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form;
|
||||
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form;
|
||||
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
||||
@@ -36,8 +32,6 @@ use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class ActivityType extends AbstractType
|
||||
{
|
||||
/**
|
||||
@@ -135,7 +129,7 @@ class ActivityType extends AbstractType
|
||||
$builder->get('durationTime')
|
||||
->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
static function (FormEvent $formEvent) use (
|
||||
function (FormEvent $formEvent) use (
|
||||
$timeChoices,
|
||||
$builder,
|
||||
$durationTimeTransformer,
|
||||
@@ -144,7 +138,7 @@ class ActivityType extends AbstractType
|
||||
// set the timezone to GMT, and fix the difference between current and GMT
|
||||
// the datetimetransformer will then handle timezone as GMT
|
||||
$timezoneUTC = new DateTimeZone('GMT');
|
||||
/** @var DateTime $data */
|
||||
/* @var $data \DateTime */
|
||||
$data = $formEvent->getData() === null ?
|
||||
DateTime::createFromFormat('U', 300) :
|
||||
$formEvent->getData();
|
||||
@@ -154,7 +148,7 @@ class ActivityType extends AbstractType
|
||||
|
||||
// test if the timestamp is in the choices.
|
||||
// If not, recreate the field with the new timestamp
|
||||
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
|
||||
if (!in_array($data->getTimestamp(), $timeChoices)) {
|
||||
// the data are not in the possible values. add them
|
||||
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
||||
$form = $builder->create(
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form\Type;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
@@ -59,7 +55,7 @@ class TranslatableActivityReason extends AbstractType
|
||||
|
||||
return null;
|
||||
},
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('r')
|
||||
->where('r.active = true');
|
||||
},
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form\Type;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@@ -41,7 +37,7 @@ class TranslatableActivityReasonCategory extends AbstractType
|
||||
[
|
||||
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
||||
'choice_label' => 'name[' . $locale . ']',
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Form\Type;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
@@ -42,7 +38,7 @@ class TranslatableActivityType extends AbstractType
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
/** @var \Doctrine\ORM\QueryBuilder $qb */
|
||||
/* @var $qb \Doctrine\ORM\QueryBuilder */
|
||||
$qb = $options['query_builder'];
|
||||
|
||||
if (true === $options['active_only']) {
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Menu;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
@@ -50,7 +46,7 @@ class MenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $parameters['person'];
|
||||
$user = $this->tokenStorage->getToken()->getUser();
|
||||
$roleSee = new Role(ActivityVoter::SEE);
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Menu;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
@@ -41,7 +37,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
||||
@@ -309,31 +305,22 @@ class appDevDebugProjectContainer extends Container
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compile()
|
||||
{
|
||||
throw new LogicException('You cannot compile a dumped frozen container.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameter($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
|
||||
if (!(isset($this->parameters[$name]) || \array_key_exists($name, $this->parameters))) {
|
||||
if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||
}
|
||||
|
||||
return $this->parameters[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameterBag()
|
||||
{
|
||||
if (null === $this->parameterBag) {
|
||||
@@ -343,19 +330,13 @@ class appDevDebugProjectContainer extends Container
|
||||
return $this->parameterBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasParameter($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
|
||||
return isset($this->parameters[$name]) || \array_key_exists($name, $this->parameters);
|
||||
return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setParameter($name, $value)
|
||||
{
|
||||
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
||||
@@ -4538,7 +4519,7 @@ class appDevDebugProjectContainer extends Container
|
||||
$instance->addGlobal('app', $e);
|
||||
$instance->addGlobal('installation', ['name' => 'Chill']);
|
||||
$instance->addGlobal('available_languages', [0 => 'fr']);
|
||||
\call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
|
||||
call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
@@ -23,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
if (
|
||||
isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(\in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
@@ -69,7 +65,7 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
|
||||
{
|
||||
if (
|
||||
$subject instanceof Center
|
||||
&& in_array($attribute, $this->getAttributes(), true)
|
||||
&& in_array($attribute, $this->getAttributes())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Security\Authorization;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
@@ -64,7 +60,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
if ($subject instanceof Activity) {
|
||||
return in_array($attribute, $this->getAttributes(), true);
|
||||
return in_array($attribute, $this->getAttributes());
|
||||
}
|
||||
|
||||
if ($subject instanceof Person) {
|
||||
@@ -84,7 +80,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
if ($subject instanceof Person) {
|
||||
$centers = $this->helper->getReachableCenters($token->getUser(), new Role($attribute));
|
||||
|
||||
return in_array($subject->getCenter(), $centers, true);
|
||||
return in_array($subject->getCenter(), $centers);
|
||||
}
|
||||
|
||||
/* @var $subject Activity */
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Templating\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
|
@@ -1,31 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Test;
|
||||
|
@@ -1,33 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Controller;
|
||||
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityControllerTest extends WebTestCase
|
||||
class ActivityControllerTest extends WebTestCase
|
||||
{
|
||||
public function getSecuredPagesAuthenticated()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
@@ -63,7 +57,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
public function getSecuredPagesUnauthenticated()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
|
||||
@@ -86,8 +80,8 @@ final class ActivityControllerTest extends WebTestCase
|
||||
|
||||
$client->request('GET', $url);
|
||||
|
||||
self::assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
self::assertTrue(
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isRedirect('http://localhost/login'),
|
||||
sprintf('the page "%s" does not redirect to http://localhost/login', $url)
|
||||
);
|
||||
@@ -103,7 +97,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
{
|
||||
$client->request('GET', $url);
|
||||
|
||||
self::assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testCompleteScenario()
|
||||
@@ -117,7 +111,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
'en/person/%d/activity/',
|
||||
$person->getId()
|
||||
));
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$client->getResponse()->getStatusCode(),
|
||||
'Unexpected HTTP status code for GET /activity/'
|
||||
@@ -142,11 +136,11 @@ final class ActivityControllerTest extends WebTestCase
|
||||
|
||||
$client->submit($form);
|
||||
|
||||
self::assertTrue($client->getResponse()->isRedirect());
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check data in the show view
|
||||
self::assertGreaterThan(
|
||||
$this->assertGreaterThan(
|
||||
0,
|
||||
$crawler->filter('dd:contains("January 15, 2015")')->count(),
|
||||
'Missing element dd:contains("January 15, 2015")'
|
||||
@@ -164,17 +158,17 @@ final class ActivityControllerTest extends WebTestCase
|
||||
|
||||
$client->submit($form);
|
||||
|
||||
self::assertTrue($client->getResponse()->isRedirect());
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// check that new data are present
|
||||
self::assertGreaterThan(
|
||||
$this->assertGreaterThan(
|
||||
0,
|
||||
$crawler->filter('dd:contains("January 25, 2015")')->count(),
|
||||
'Missing element dd:contains("January 25, 2015")'
|
||||
);
|
||||
self::assertGreaterThan(
|
||||
$this->assertGreaterThan(
|
||||
0,
|
||||
$crawler->filter('dd:contains("Foo")')->count(),
|
||||
'Missing element dd:contains("Foo")'
|
||||
@@ -188,14 +182,14 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$form = $button->form();
|
||||
|
||||
$client->submit($form);
|
||||
self::assertTrue($client->getResponse()->isRedirect(sprintf(
|
||||
$this->assertTrue($client->getResponse()->isRedirect(sprintf(
|
||||
'/en/person/%d/activity/',
|
||||
$person->getId()
|
||||
)));
|
||||
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
self::assertNotContains('January 25, 2015', $crawler->text());
|
||||
$this->assertNotContains('January 25, 2015', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +200,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function createFakeUser()
|
||||
{
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
$em = $container->get('doctrine.orm.entity_manager');
|
||||
|
||||
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
|
||||
@@ -248,7 +242,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
|
||||
private function getActivitiesForPerson(\Chill\PersonBundle\Entity\Person $person)
|
||||
{
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$activities = $em->getRepository('ChillActivityBundle:Activity')
|
||||
@@ -269,7 +263,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getAuthenticatedClient($username = 'center a_social')
|
||||
{
|
||||
return self::createClient([], [
|
||||
return static::createClient([], [
|
||||
'PHP_AUTH_USER' => $username,
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
]);
|
||||
@@ -280,7 +274,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getPersonFromFixtures()
|
||||
{
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')
|
||||
@@ -304,14 +298,14 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomActivityReason(array $excludeIds = [])
|
||||
{
|
||||
$reasons = self::$kernel->getContainer()
|
||||
$reasons = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillActivityBundle:ActivityReason')
|
||||
->findAll();
|
||||
|
||||
$reason = $reasons[array_rand($reasons)];
|
||||
|
||||
if (in_array($reason->getId(), $excludeIds, true)) {
|
||||
if (in_array($reason->getId(), $excludeIds)) {
|
||||
return $this->getRandomActivityReason($excludeIds);
|
||||
}
|
||||
|
||||
@@ -323,7 +317,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomActivityType()
|
||||
{
|
||||
$types = self::$kernel->getContainer()
|
||||
$types = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillActivityBundle:ActivityType')
|
||||
->findAll();
|
||||
@@ -339,7 +333,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomScope($username, $centerName)
|
||||
{
|
||||
$user = self::$kernel->getContainer()
|
||||
$user = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillMainBundle:User')
|
||||
->findOneByUsername($username);
|
||||
@@ -349,20 +343,20 @@ final class ActivityControllerTest extends WebTestCase
|
||||
. 'does not exists in database. Did you add fixtures ?');
|
||||
}
|
||||
|
||||
$center = self::$kernel->getContainer()
|
||||
$center = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillMainBundle:Center')
|
||||
->findOneByName($centerName);
|
||||
|
||||
// get scope reachable by both role UPDATE and DELETE
|
||||
$reachableScopesUpdate = self::$kernel->getContainer()
|
||||
$reachableScopesUpdate = static::$kernel->getContainer()
|
||||
->get('chill.main.security.authorization.helper')
|
||||
->getReachableScopes(
|
||||
$user,
|
||||
new Role('CHILL_ACTIVITY_UPDATE'),
|
||||
$center
|
||||
);
|
||||
$reachableScopesDelete = self::$kernel->getContainer()
|
||||
$reachableScopesDelete = static::$kernel->getContainer()
|
||||
->get('chill.main.security.authorization.helper')
|
||||
->getReachableScopes(
|
||||
$user,
|
||||
@@ -370,8 +364,8 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$center
|
||||
);
|
||||
$reachableScopesId = array_intersect(
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
);
|
||||
|
||||
if (count($reachableScopesId) === 0) {
|
||||
@@ -380,7 +374,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
}
|
||||
|
||||
foreach ($reachableScopesUpdate as $scope) {
|
||||
if (in_array($scope->getId(), $reachableScopesId, true)) {
|
||||
if (in_array($scope->getId(), $reachableScopesId)) {
|
||||
$reachableScopes[] = $scope;
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityReasonCategoryControllerTest extends WebTestCase
|
||||
class ActivityReasonCategoryControllerTest extends WebTestCase
|
||||
{
|
||||
public function testToWrite()
|
||||
{
|
||||
self::markTestSkipped();
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityReasonControllerTest extends WebTestCase
|
||||
class ActivityReasonControllerTest extends WebTestCase
|
||||
{
|
||||
public function testToWrite()
|
||||
{
|
||||
self::markTestSkipped();
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -19,11 +15,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityTypeControllerTest extends WebTestCase
|
||||
class ActivityTypeControllerTest extends WebTestCase
|
||||
{
|
||||
public function testToWrite()
|
||||
{
|
||||
self::markTestSkipped();
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
|
||||
|
||||
@@ -61,11 +57,11 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
|
||||
|
||||
@@ -60,11 +56,11 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||
class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
|
||||
|
||||
@@ -60,11 +56,11 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CountActivityTest extends AbstractExportTest
|
||||
class CountActivityTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $export;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
$this->export = $container->get('chill.activity.export.count_activity');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
@@ -19,18 +15,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ListActivityTest extends AbstractExportTest
|
||||
class ListActivityTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\ActivityBundle\Export\Export\ListActivity
|
||||
*/
|
||||
private $export;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
$this->export = $container->get('chill.activity.export.list_activity');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
@@ -21,18 +17,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class StatActivityDurationSumTest extends AbstractExportTest
|
||||
class StatActivityDurationSumTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
|
||||
*/
|
||||
private $export;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
$this->export = $container->get('chill.activity.export.sum_activity_duration');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Filter;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
@@ -20,18 +16,18 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->filter = $container->get('chill.activity.export.reason_filter');
|
||||
|
||||
@@ -52,11 +48,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$reasons = $em->createQuery('SELECT reason '
|
||||
@@ -73,11 +69,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
|
@@ -1,38 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Filter;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use DateTime;
|
||||
use function array_slice;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
/**
|
||||
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
static::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->filter = $container->get('chill.activity.export.'
|
||||
. 'person_having_an_activity_between_date_filter');
|
||||
@@ -73,11 +68,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
@@ -102,11 +97,11 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
*/
|
||||
private function getActivityReasons()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
return self::$kernel->getContainer()
|
||||
return static::$kernel->getContainer()
|
||||
->get('chill_activity.repository.reason')
|
||||
->findAll();
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Form;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
@@ -25,7 +21,7 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityTypeTest extends KernelTestCase
|
||||
class ActivityTypeTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Chill\MainBundle\Entity\Center
|
||||
@@ -47,7 +43,7 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
@@ -93,9 +89,9 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
|
||||
$form->submit([]);
|
||||
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertTrue($form->isValid());
|
||||
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertTrue($form->isValid());
|
||||
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||
}
|
||||
|
||||
public function testFormSubmitting()
|
||||
@@ -118,25 +114,25 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
|
||||
// var_dump($form->getErrors());
|
||||
|
||||
self::assertTrue($form->isSynchronized(), 'Test the form is synchronized');
|
||||
self::assertTrue($form->isValid(), 'test the form is valid');
|
||||
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||
$this->assertTrue($form->isSynchronized(), 'Test the form is synchronized');
|
||||
$this->assertTrue($form->isValid(), 'test the form is valid');
|
||||
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
|
||||
|
||||
// test the activity
|
||||
/** @var Activity $activity */
|
||||
/* @var $activity Activity */
|
||||
$activity = $form->getData()['activity'];
|
||||
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
'09-03-2015',
|
||||
$activity->getDate()->format('d-m-Y'),
|
||||
'Test the date is correct'
|
||||
);
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
'00:05',
|
||||
$activity->getDurationTime()->format('H:i'),
|
||||
'Test the formatted hour is correct'
|
||||
);
|
||||
self::assertTrue($activity->getAttendee());
|
||||
$this->assertEquals(true, $activity->getAttendee());
|
||||
// $this->assertEquals('blabla', $activity->getRemark());
|
||||
}
|
||||
|
||||
@@ -170,14 +166,14 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
'attendee' => true,
|
||||
]]);
|
||||
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertTrue($form->isValid());
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertTrue($form->isValid());
|
||||
|
||||
// test the activity
|
||||
/** @var Activity $activity */
|
||||
/* @var $activity Activity */
|
||||
$activity = $form->getData()['activity'];
|
||||
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
'00:01',
|
||||
$activity->getDurationTime()->format('H:i'),
|
||||
'Test the formatted hour is correct'
|
||||
@@ -186,14 +182,14 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
// test the view : we want to be sure that the entry with 60 seconds exists
|
||||
$view = $form->createView();
|
||||
|
||||
self::assertTrue(isset($view['activity']['durationTime']));
|
||||
$this->assertTrue(isset($view['activity']['durationTime']));
|
||||
|
||||
// map all the values in an array
|
||||
$values = array_map(
|
||||
static function ($choice) { return $choice->value; },
|
||||
function ($choice) { return $choice->value; },
|
||||
$view['activity']['durationTime']->vars['choices']
|
||||
);
|
||||
|
||||
self::assertContains(60, $values);
|
||||
$this->assertContains(60, $values);
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Form\Type;
|
||||
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
||||
@@ -24,14 +20,14 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class TranslatableActivityReasonTest extends TypeTestCase
|
||||
class TranslatableActivityReasonTest extends TypeTestCase
|
||||
{
|
||||
/**
|
||||
* @var Prophecy\Prophet
|
||||
*/
|
||||
private static $prophet;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
@@ -42,7 +38,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
|
||||
$this->getTranslatableStringHelper()
|
||||
);
|
||||
|
||||
self::markTestSkipped('See issue 651');
|
||||
$this->markTestSkipped('See issue 651');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +81,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase
|
||||
$request->getLocale()->willReturn($fallbackLocale);
|
||||
|
||||
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
|
||||
$requestStack->getCurrentRequest()->will(static function () use ($request) {
|
||||
$requestStack->getCurrentRequest()->will(function () use ($request) {
|
||||
return $request;
|
||||
});
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Form\Type;
|
||||
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
|
||||
@@ -21,7 +17,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class TranslatableActivityTypeTest extends KernelTestCase
|
||||
class TranslatableActivityTypeTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Component\Form\FormBuilderInterface
|
||||
@@ -33,7 +29,7 @@ final class TranslatableActivityTypeTest extends KernelTestCase
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
@@ -63,13 +59,13 @@ final class TranslatableActivityTypeTest extends KernelTestCase
|
||||
'type' => $type->getId(),
|
||||
]);
|
||||
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertInstanceOf(
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertInstanceOf(
|
||||
\Chill\ActivityBundle\Entity\ActivityType::class,
|
||||
$form->getData()['type'],
|
||||
'The data is an instance of Chill\\ActivityBundle\\Entity\\ActivityType'
|
||||
);
|
||||
self::assertEquals($type->getId(), $form->getData()['type']->getId());
|
||||
$this->assertEquals($type->getId(), $form->getData()['type']->getId());
|
||||
|
||||
// test the ordering of the types in the form
|
||||
// since 2016-11-14 the types are not alphabetically ordered, skipping
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Security\Authorization;
|
||||
|
||||
use Chill\ActivityBundle\Test\PrepareActivityTrait;
|
||||
@@ -28,7 +24,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ActivityVoterTest extends KernelTestCase
|
||||
class ActivityVoterTest extends KernelTestCase
|
||||
{
|
||||
use PrepareActivityTrait;
|
||||
use PrepareCenterTrait;
|
||||
@@ -46,10 +42,10 @@ final class ActivityVoterTest extends KernelTestCase
|
||||
*/
|
||||
protected $voter;
|
||||
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->voter = self::$kernel->getContainer()
|
||||
static::bootKernel();
|
||||
$this->voter = static::$kernel->getContainer()
|
||||
->get('chill.activity.security.authorization.activity_voter');
|
||||
$this->prophet = new \Prophecy\Prophet();
|
||||
}
|
||||
@@ -115,7 +111,7 @@ final class ActivityVoterTest extends KernelTestCase
|
||||
$scope = $this->prepareScope(1, 'default');
|
||||
$activity = $this->prepareActivity($scope, $person);
|
||||
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
VoterInterface::ACCESS_DENIED,
|
||||
$this->voter->vote($token, $activity, ['CHILL_ACTIVITY_SEE']),
|
||||
'assert that a null user is not allowed to see'
|
||||
@@ -140,7 +136,7 @@ final class ActivityVoterTest extends KernelTestCase
|
||||
$token = $this->prepareToken($user);
|
||||
$activity = $this->prepareActivity($scope, $this->preparePerson($center));
|
||||
|
||||
self::assertEquals(
|
||||
$this->assertEquals(
|
||||
$expectedResult,
|
||||
$this->voter->vote($token, $activity, [$attribute]),
|
||||
$message
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Timeline;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -19,10 +15,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class TimelineProviderTest extends WebTestCase
|
||||
class TimelineProviderTest extends WebTestCase
|
||||
{
|
||||
public function testAnActivityIsShownOnTimeline()
|
||||
{
|
||||
self::markTestSkipped('we have to write fixtures before writing this tests');
|
||||
$this->markTestSkipped('we have to write fixtures before writing this tests');
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\ActivityBundle\Timeline;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
@@ -24,8 +20,6 @@ use RuntimeException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Provide activity for inclusion in timeline.
|
||||
*/
|
||||
@@ -64,9 +58,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
$this->user = $storage->getToken()->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchQuery($context, array $args)
|
||||
{
|
||||
$this->checkContext($context);
|
||||
@@ -89,9 +80,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEntities(array $ids)
|
||||
{
|
||||
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
||||
@@ -106,9 +94,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEntityTemplate($entity, $context, array $args)
|
||||
{
|
||||
$this->checkContext($context);
|
||||
@@ -123,9 +108,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supportsType($type)
|
||||
{
|
||||
return 'activity' === $type;
|
||||
@@ -189,7 +171,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
$reachablesScopesId = array_map(
|
||||
static function (Scope $scope) {
|
||||
function (Scope $scope) {
|
||||
return $scope->getId();
|
||||
},
|
||||
$this->helper->getReachableScopes(
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@@ -24,7 +20,7 @@ class Version20150701091248 extends AbstractMigration
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0C59BB1592');
|
||||
$this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2');
|
||||
@@ -42,7 +38,7 @@ class Version20150701091248 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@@ -24,7 +20,7 @@ class Version20150702093317 extends AbstractMigration
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN name;');
|
||||
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;');
|
||||
@@ -37,7 +33,7 @@ class Version20150702093317 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;');
|
||||
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@@ -24,7 +20,7 @@ class Version20150704091347 extends AbstractMigration
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark SET NOT NULL;');
|
||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
|
||||
@@ -33,7 +29,7 @@ class Version20150704091347 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark DROP NOT NULL;');
|
||||
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@@ -27,7 +23,7 @@ class Version20160222103457 extends AbstractMigration
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
@@ -39,7 +35,7 @@ class Version20160222103457 extends AbstractMigration
|
||||
|
||||
// try to keep at least on activity reason...
|
||||
$this->addSql(
|
||||
'UPDATE activity
|
||||
'UPDATE activity
|
||||
SET reason_id=rid
|
||||
FROM (
|
||||
SELECT activity_id AS aid, MIN(activityreason_id) AS rid
|
||||
@@ -54,7 +50,7 @@ class Version20160222103457 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf(
|
||||
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
|
||||
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.'
|
||||
);
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Calculator;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
||||
|
@@ -1,22 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Calculator;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
||||
use OutOfBoundsException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
|
||||
class CalculatorManager
|
||||
{
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Calculator;
|
||||
|
||||
class CalculatorResult
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\DependencyInjection\Compiler\CalculatorCompilerPass;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Config;
|
||||
|
||||
class ConfigRepository
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Entity\AbstractElement;
|
||||
@@ -24,8 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
use function get_class;
|
||||
|
||||
abstract class AbstractElementController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -117,7 +111,7 @@ abstract class AbstractElementController extends Controller
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($form->isSubmitted() and $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->flush();
|
||||
|
||||
@@ -141,7 +135,7 @@ abstract class AbstractElementController extends Controller
|
||||
*/
|
||||
protected function _new(Person $person, Request $request, $template, $flashMessageOnSuccess)
|
||||
{
|
||||
/** @var \Chill\AMLI\BudgetBundle\Entity\AbstractElement $element */
|
||||
/* @var $element \Chill\AMLI\BudgetBundle\Entity\AbstractElement */
|
||||
$element = $this->createNewElement()
|
||||
->setPerson($person);
|
||||
|
||||
@@ -152,7 +146,7 @@ abstract class AbstractElementController extends Controller
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($form->isSubmitted() and $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($element);
|
||||
$em->flush();
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Entity\Charge;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Calculator\CalculatorManager;
|
||||
@@ -25,7 +21,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
use function count;
|
||||
use function array_merge;
|
||||
|
||||
class ElementController extends Controller
|
||||
{
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\Controller;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Entity\Resource;
|
||||
|
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\AMLI\BudgetBundle\DependencyInjection;
|
||||
|
||||
use Chill\AMLI\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
||||
@@ -27,9 +23,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
*/
|
||||
class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
@@ -54,7 +47,7 @@ class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInte
|
||||
$this->prependRoutes($container);
|
||||
}
|
||||
|
||||
/** (non-PHPdoc).
|
||||
/* (non-PHPdoc)
|
||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||
*/
|
||||
public function prependRoutes(ContainerBuilder $container)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user