Compare commits

..

6 Commits

Author SHA1 Message Date
148221cdc7 fix namespace of 'self' 2021-04-27 23:21:15 +02:00
58047faac6 force type for connection parameter 2021-04-27 23:20:49 +02:00
40dda65006 fix import namespacees 2021-04-27 23:20:25 +02:00
Pol Dellaiera
054a28ecf4 refactor: Update source code based on PHP conventions. 2021-04-26 17:18:38 +02:00
Pol Dellaiera
6b2eda0f94 chore: Add/update static files. 2021-04-26 15:44:37 +02:00
Pol Dellaiera
1359f1ba58 chore: Update composer.json 2021-04-26 14:02:26 +02:00
878 changed files with 6863 additions and 10118 deletions

1
.gitignore vendored
View File

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

View File

@@ -30,10 +30,6 @@ 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:

View File

@@ -1,71 +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);
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 Normal file
View File

@@ -0,0 +1,25 @@
<?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);

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -16,7 +20,7 @@ use Doctrine\ORM\Query\Expr;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
{
// add specific role for this filter
public function addRole()

View File

@@ -1,12 +1,16 @@
<?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;
@@ -89,7 +93,7 @@ class CountPerson implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
// we gather all center the user choose.
$centers = array_map(function ($el) {
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);

View File

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

View File

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

View File

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

View File

@@ -1,17 +1,21 @@
<?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 ItemController extends Controller
class example extends Controller
{
public function yourAction()
{
@@ -36,13 +40,12 @@ class ItemController extends Controller
// use the paginator to get the number of items to display
->setMaxResults($paginator->getItemsPerPage());
return $this
->render(
'ChillMyBundle:Item:list.html.twig',
[
'items' => $items,
'paginator' => $paginator,
]
);
return $this->render(
'ChillMyBundle:Item:list.html.twig',
[
'items' => $items,
'paginator' => $paginator,
]
);
}
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -25,7 +29,7 @@ class ConsultationController extends Controller
*/
public function listAction($id)
{
/* @var $person \Chill\PersonBundle\Entity\Person */
/** @var \Chill\PersonBundle\Entity\Person $person */
$person = $this->get('chill.person.repository.person')
->find($id);
@@ -35,7 +39,7 @@ class ConsultationController extends Controller
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
/* @var $authorizationHelper \Chill\MainBundle\Security\Authorization\AuthorizationHelper */
/** @var \Chill\MainBundle\Security\Authorization\AuthorizationHelper $authorizationHelper */
$authorizationHelper = $this->get('chill.main.security.'
. 'authorization.helper');

View File

@@ -1,12 +1,18 @@
<?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;
@@ -17,7 +23,7 @@ namespace Chill\MainBundle\DependencyInjection;
/**
* Configure the main bundle.
*/
class Configuration implements ConfigurationInterface
class ChillMainConfiguration implements ConfigurationInterface
{
use AddWidgetConfigurationTrait;
@@ -27,7 +33,7 @@ class Configuration implements ConfigurationInterface
private $containerBuilder;
public function __construct(
array $widgetFactories = [],
array $widgetFactories,
ContainerBuilder $containerBuilder
) {
// we register here widget factories (see below)
@@ -36,6 +42,9 @@ class Configuration implements ConfigurationInterface
$this->containerBuilder = $containerBuilder;
}
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
@@ -53,7 +62,8 @@ class Configuration implements ConfigurationInterface
->end() // end of widgets/children
->end() // end of widgets
->end() // end of root/children
->end(); // end of root
->end() // end of root
;
return $treeBuilder;
}

View File

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

View File

@@ -1,12 +1,18 @@
<?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;
@@ -16,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* add configuration for the person_list widget.
*/
class PersonListWidgetFactory extends AbstractWidgetFactory
class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
{
/*
* append the option to the configuration
@@ -36,8 +42,8 @@ class PersonListWidgetFactory 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[]
*/
@@ -59,8 +65,8 @@ class PersonListWidgetFactory extends AbstractWidgetFactory
return 'chill_person.widget.person_list';
}
/*
* return the widget alias
/**
* return the widget alias.
*
* @return string
*/

View File

@@ -1,12 +1,18 @@
<?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;
@@ -27,7 +33,7 @@ use Twig_Environment;
*
* The configuration is defined by `PersonListWidgetFactory`
*/
class PersonListWidget implements WidgetInterface
class ChillPersonAddAPersonWidget implements WidgetInterface
{
/**
* the authorization helper.

View File

@@ -1,12 +1,18 @@
<?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;
@@ -20,6 +26,9 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillPersonExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
// ...

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -21,9 +25,6 @@ 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
{
/**
@@ -127,7 +128,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();
@@ -151,7 +152,7 @@ class ActivityController extends AbstractController
'comment' => $activity->getComment()->getComment(),
'scope_id' => $activity->getScope()->getId(),
'reasons_ids' => $activity->getReasons()
->map(function ($ar) {
->map(static function ($ar) {
return $ar->getId();
})
->toArray(),

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,9 +19,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* ActivityReasonCategory controller.
*/
class ActivityReasonCategoryController extends AbstractController
{
/**

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,9 +19,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* ActivityReason controller.
*/
class ActivityReasonController extends AbstractController
{
/**

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,9 +19,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ActivityTypeController.
*/
class ActivityTypeController extends AbstractController
{
/**

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -18,10 +22,12 @@ 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 OrderedFixtureInterface, ContainerAwareInterface
class LoadActivity extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
{
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
@@ -47,7 +53,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
->findAll();
foreach ($persons as $person) {
$activityNbr = rand(0, 3);
$activityNbr = mt_rand(0, 3);
for ($i = 0; $i < $activityNbr; ++$i) {
echo 'Creating an activity type for : ' . $person . "\n";
@@ -71,7 +77,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
$usedId = [];
for ($i = 0; rand(0, 4) > $i; ++$i) {
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
$reason = $this->getRandomActivityReason($usedId);
$usedId[] = $reason->getId();
$activity->addReason($reason);
@@ -89,7 +95,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
{
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
// we have a reason which should be excluded. Find another...
return $this->getRandomActivityReason($excludingIds);
}

View File

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

View File

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

View File

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

View File

@@ -1,26 +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\DataFixtures\ORM;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
/**
* 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()
@@ -43,10 +44,9 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
}
break;
case 'administrative':
case 'direction':
if (in_array($scope->getName()['en'], ['administrative', 'social'])) {
if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
break 2; // we do not want any power on social or administrative
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,6 +27,9 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillActivityExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
@@ -59,7 +66,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
]);
}
/* (non-PHPdoc)
/** (non-PHPdoc).
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prependRoutes(ContainerBuilder $container)

View File

@@ -1,17 +1,23 @@
<?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.
*
@@ -19,6 +25,9 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_activity');
@@ -55,7 +64,7 @@ class Configuration implements ConfigurationInterface
->info('The number of seconds of this duration. Must be an integer.')
->cannotBeEmpty()
->validate()
->ifTrue(function ($data) {
->ifTrue(static function ($data) {
return !is_int($data);
})->thenInvalid('The value %s is not a valid integer')
->end()

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,8 +27,6 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Activity.
*
* @ORM\Entity
* @ORM\Table(name="activity")
* @ORM\HasLifecycleCallbacks

View File

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

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -22,6 +26,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 ActivityReasonAggregator implements
AggregatorInterface,
ExportElementValidatedInterface
@@ -79,7 +86,7 @@ class ActivityReasonAggregator implements
array_key_exists('activity', $join)
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
or (!array_key_exists('activity', $join))
|| (!array_key_exists('activity', $join))
) {
$qb->add(
'join',
@@ -133,7 +140,6 @@ class ActivityReasonAggregator implements
$this->reasonRepository->findBy(['id' => $values]);
break;
case 'categories':
$this->categoryRepository->findBy(['id' => $values]);
@@ -156,7 +162,7 @@ class ActivityReasonAggregator implements
switch ($data['level']) {
case 'reasons':
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
/** @var \Chill\ActivityBundle\Entity\ActivityReason $r */
$r = $this->reasonRepository->find($value);
return $this->stringHelper->localize($r->getCategory()->getName())
@@ -164,7 +170,6 @@ class ActivityReasonAggregator implements
. $this->stringHelper->localize($r->getName());
break;
case 'categories':
$c = $this->categoryRepository->find($value);

View File

@@ -1,12 +1,16 @@
<?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;
@@ -74,7 +78,7 @@ class ActivityTypeAggregator implements AggregatorInterface
return 'Activity type';
}
/* @var $r \Chill\ActivityBundle\Entity\ActivityType */
/** @var \Chill\ActivityBundle\Entity\ActivityType $r */
$t = $this->typeRepository->find($value);
return $this->stringHelper->localize($t->getName());

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -49,7 +53,7 @@ class CountActivity implements ExportInterface
throw new LogicException("the key {$key} is not used by this export");
}
return function ($value) {
return static function ($value) {
return '_header' === $value ?
'Number of activities'
:
@@ -80,7 +84,7 @@ class CountActivity implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$qb = $this->entityManager->createQueryBuilder();
$centers = array_map(function ($el) {
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);

View File

@@ -1,12 +1,16 @@
<?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;
@@ -25,6 +29,8 @@ 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.
@@ -70,6 +76,9 @@ class ListActivity implements ListInterface
$this->translatableStringHelper = $translatableStringHelper;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('fields', ChoiceType::class, [
@@ -78,7 +87,7 @@ class ListActivity implements ListInterface
'choices' => array_combine($this->fields, $this->fields),
'label' => 'Fields to include in export',
'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) {
'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
@@ -90,6 +99,8 @@ class ListActivity implements ListInterface
}
/**
* {@inheritdoc}
*
* @return type
*/
public function getAllowedFormattersTypes()
@@ -106,7 +117,7 @@ class ListActivity implements ListInterface
{
switch ($key) {
case 'date':
return function ($value) {
return static function ($value) {
if ('_header' === $value) {
return 'date';
}
@@ -115,18 +126,16 @@ class ListActivity implements ListInterface
return $date->format('d-m-Y');
};
case 'attendee':
return function ($value) {
return static function ($value) {
if ('_header' === $value) {
return 'attendee';
}
return $value ? 1 : 0;
};
case 'list_reasons':
/* @var $activityReasonsRepository EntityRepository */
/** @var EntityRepository $activityReasonsRepository */
$activityRepository = $this->entityManager
->getRepository('ChillActivityBundle:Activity');
@@ -146,7 +155,6 @@ class ListActivity implements ListInterface
. '"';
}, $activity->getReasons()->toArray()));
};
case 'circle_name':
return function ($value) {
if ('_header' === $value) {
@@ -156,7 +164,6 @@ class ListActivity implements ListInterface
return $this->translatableStringHelper
->localize(json_decode($value, true));
};
case 'type_name':
return function ($value) {
if ('_header' === $value) {
@@ -168,7 +175,7 @@ class ListActivity implements ListInterface
};
default:
return function ($value) use ($key) {
return static function ($value) use ($key) {
if ('_header' === $value) {
return $key;
}
@@ -200,7 +207,7 @@ class ListActivity implements ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function ($el) {
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
@@ -220,46 +227,39 @@ class ListActivity implements ListInterface
->setParameter('authorized_centers', $centers);
foreach ($this->fields as $f) {
if (in_array($f, $data['fields'])) {
if (in_array($f, $data['fields'], true)) {
switch ($f) {
case 'id':
$qb->addSelect('activity.id AS id');
break;
case 'person_firstname':
$qb->addSelect('person.firstName AS person_firstname');
break;
case 'person_lastname':
$qb->addSelect('person.lastName AS person_lastname');
break;
case 'person_id':
$qb->addSelect('person.id AS person_id');
break;
case 'user_username':
$qb->join('activity.user', 'user');
$qb->addSelect('user.username AS user_username');
break;
case 'circle_name':
$qb->join('activity.scope', 'circle');
$qb->addSelect('circle.name AS circle_name');
break;
case 'type_name':
$qb->join('activity.type', 'type');
$qb->addSelect('type.name AS type_name');
break;
case 'list_reasons':
// this is a trick... The reasons is filled with the
// activity id which will be used to load reasons

View File

@@ -1,12 +1,16 @@
<?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;
@@ -77,7 +81,7 @@ class StatActivityDuration implements ExportInterface
$header = 'Sum of activities duration';
}
return function ($value) use ($header) {
return static function ($value) use ($header) {
return '_header' === $value ?
$header
:
@@ -109,7 +113,7 @@ class StatActivityDuration implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function ($el) {
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder();

View File

@@ -1,12 +1,16 @@
<?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;
@@ -80,7 +84,7 @@ class ActivityDateFilter implements FilterInterface
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/* @var $filterForm \Symfony\Component\Form\FormInterface */
/** @var \Symfony\Component\Form\FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,9 +27,12 @@ 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
FilterInterface,
ExportElementValidatedInterface
ExportElementValidatedInterface,
FilterInterface
{
/**
* The repository for activity reasons.
@@ -64,7 +71,7 @@ class ActivityReasonFilter implements
array_key_exists('activity', $join)
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
)
or (!array_key_exists('activity', $join))
|| (!array_key_exists('activity', $join))
) {
$qb->add(
'join',
@@ -95,10 +102,10 @@ class ActivityReasonFilter implements
$builder->add('reasons', EntityType::class, [
'class' => 'ChillActivityBundle:ActivityReason',
'choice_label' => function (ActivityReason $reason) use ($helper) {
'choice_label' => static function (ActivityReason $reason) use ($helper) {
return $helper->localize($reason->getName());
},
'group_by' => function (ActivityReason $reason) use ($helper) {
'group_by' => static function (ActivityReason $reason) use ($helper) {
return $helper->localize($reason->getCategory()->getName());
},
'multiple' => true,

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,9 +27,11 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class ActivityTypeFilter implements
FilterInterface,
ExportElementValidatedInterface
ExportElementValidatedInterface,
FilterInterface
{
/**
* @var TranslatableStringHelper
@@ -79,7 +85,7 @@ class ActivityTypeFilter implements
$builder->add('types', EntityType::class, [
'class' => ActivityType::class,
'choice_label' => function (ActivityType $type) use ($helper) {
'choice_label' => static function (ActivityType $type) use ($helper) {
return $helper->localize($type->getName());
},
'multiple' => true,

View File

@@ -1,12 +1,16 @@
<?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;
@@ -26,9 +30,11 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
class PersonHavingActivityBetweenDateFilter implements
FilterInterface,
ExportElementValidatedInterface
ExportElementValidatedInterface,
FilterInterface
{
/**
* @var EntityRepository
@@ -145,7 +151,7 @@ class PersonHavingActivityBetweenDateFilter implements
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/* @var $filterForm \Symfony\Component\Form\FormInterface */
/** @var \Symfony\Component\Form\FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -32,6 +36,8 @@ 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
{
/**
@@ -129,7 +135,7 @@ class ActivityType extends AbstractType
$builder->get('durationTime')
->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $formEvent) use (
static function (FormEvent $formEvent) use (
$timeChoices,
$builder,
$durationTimeTransformer,
@@ -138,7 +144,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 $data \DateTime */
/** @var DateTime $data */
$data = $formEvent->getData() === null ?
DateTime::createFromFormat('U', 300) :
$formEvent->getData();
@@ -148,7 +154,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)) {
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
// the data are not in the possible values. add them
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
$form = $builder->create(

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -55,7 +59,7 @@ class TranslatableActivityReason extends AbstractType
return null;
},
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('r')
->where('r.active = true');
},

View File

@@ -1,12 +1,16 @@
<?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;
@@ -37,7 +41,7 @@ class TranslatableActivityReasonCategory extends AbstractType
[
'class' => 'ChillActivityBundle:ActivityReasonCategory',
'choice_label' => 'name[' . $locale . ']',
'query_builder' => function (EntityRepository $er) {
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.active = true');
},

View File

@@ -1,12 +1,16 @@
<?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;
@@ -38,7 +42,7 @@ class TranslatableActivityType extends AbstractType
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
/* @var $qb \Doctrine\ORM\QueryBuilder */
/** @var \Doctrine\ORM\QueryBuilder $qb */
$qb = $options['query_builder'];
if (true === $options['active_only']) {

View File

@@ -1,12 +1,16 @@
<?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;
@@ -46,7 +50,7 @@ class MenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/* @var $person \Chill\PersonBundle\Entity\Person */
/** @var \Chill\PersonBundle\Entity\Person $person */
$person = $parameters['person'];
$user = $this->tokenStorage->getToken()->getUser();
$roleSee = new Role(ActivityVoter::SEE);

View File

@@ -1,12 +1,16 @@
<?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;
@@ -37,7 +41,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
/* @var $person \Chill\PersonBundle\Entity\Person */
/** @var \Chill\PersonBundle\Entity\Person $person */
$person = $parameters['person'];
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -305,22 +309,31 @@ 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) {
@@ -330,13 +343,19 @@ 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.');
@@ -4519,7 +4538,7 @@ class appDevDebugProjectContainer extends Container
$instance->addGlobal('app', $e);
$instance->addGlobal('installation', ['name' => 'Chill']);
$instance->addGlobal('available_languages', [0 => 'fr']);
call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
\call_user_func([new \Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator('F j, Y H:i', '%d days', null, 0, '.', ','), 'configure'], $instance);
return $instance;
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -19,7 +23,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']) || php_sapi_name() === 'cli-server')
|| !(\in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -65,7 +69,7 @@ class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierar
{
if (
$subject instanceof Center
&& in_array($attribute, $this->getAttributes())
&& in_array($attribute, $this->getAttributes(), true)
) {
return true;
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -60,7 +64,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
protected function supports($attribute, $subject)
{
if ($subject instanceof Activity) {
return in_array($attribute, $this->getAttributes());
return in_array($attribute, $this->getAttributes(), true);
}
if ($subject instanceof Person) {
@@ -80,7 +84,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);
return in_array($subject->getCenter(), $centers, true);
}
/* @var $subject Activity */

View File

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

View File

@@ -1,10 +1,31 @@
<?php
/**
* Chill is a software for social workers
* Chill is a software for social workers.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\ActivityBundle\Test;

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,11 +19,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityReasonCategoryControllerTest extends WebTestCase
final class ActivityReasonCategoryControllerTest extends WebTestCase
{
public function testToWrite()
{
$this->markTestSkipped();
self::markTestSkipped();
}
/*

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,11 +19,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityReasonControllerTest extends WebTestCase
final class ActivityReasonControllerTest extends WebTestCase
{
public function testToWrite()
{
$this->markTestSkipped();
self::markTestSkipped();
}
/*

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,11 +19,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class ActivityTypeControllerTest extends WebTestCase
final class ActivityTypeControllerTest extends WebTestCase
{
public function testToWrite()
{
$this->markTestSkipped();
self::markTestSkipped();
}
/*

View File

@@ -1,12 +1,16 @@
<?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;
@@ -17,18 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
final class ActivityReasonAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
*/
private $aggregator;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
@@ -57,11 +61,11 @@ class ActivityReasonAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,12 +1,16 @@
<?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;
@@ -17,18 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
*/
private $aggregator;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
@@ -56,11 +60,11 @@ class ActivityTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,12 +1,16 @@
<?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;
@@ -17,18 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
* @internal
* @coversNothing
*/
class ActivityUserAggregatorTest extends AbstractAggregatorTest
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
*/
private $aggregator;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
@@ -56,11 +60,11 @@ class ActivityUserAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,18 +19,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class CountActivityTest extends AbstractExportTest
final class CountActivityTest extends AbstractExportTest
{
/**
* @var
*/
private $export;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.count_activity');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,18 +19,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class ListActivityTest extends AbstractExportTest
final class ListActivityTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\ListActivity
*/
private $export;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.list_activity');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -17,18 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
* @internal
* @coversNothing
*/
class StatActivityDurationSumTest extends AbstractExportTest
final class StatActivityDurationSumTest extends AbstractExportTest
{
/**
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
*/
private $export;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
$container = self::$kernel->getContainer();
$this->export = $container->get('chill.activity.export.sum_activity_duration');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -16,18 +20,18 @@ use Doctrine\Common\Collections\ArrayCollection;
* @internal
* @coversNothing
*/
class ActivityReasonFilterTest extends AbstractFilterTest
final class ActivityReasonFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
*/
private $filter;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.reason_filter');
@@ -48,11 +52,11 @@ class ActivityReasonFilterTest extends AbstractFilterTest
public function getFormData()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$reasons = $em->createQuery('SELECT reason '
@@ -69,11 +73,11 @@ class ActivityReasonFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [

View File

@@ -1,33 +1,38 @@
<?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
*/
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
{
/**
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
*/
private $filter;
public function setUp()
protected function setUp()
{
static::bootKernel();
self::bootKernel();
$container = static::$kernel->getContainer();
$container = self::$kernel->getContainer();
$this->filter = $container->get('chill.activity.export.'
. 'person_having_an_activity_between_date_filter');
@@ -68,11 +73,11 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
public function getQueryBuilders()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
return [
@@ -97,11 +102,11 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
*/
private function getActivityReasons()
{
if (null === static::$kernel) {
static::bootKernel();
if (null === self::$kernel) {
self::bootKernel();
}
return static::$kernel->getContainer()
return self::$kernel->getContainer()
->get('chill_activity.repository.reason')
->findAll();
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -21,7 +25,7 @@ use Symfony\Component\Security\Core\Role\Role;
* @internal
* @coversNothing
*/
class ActivityTypeTest extends KernelTestCase
final class ActivityTypeTest extends KernelTestCase
{
/**
* @var \Chill\MainBundle\Entity\Center
@@ -43,7 +47,7 @@ class ActivityTypeTest extends KernelTestCase
*/
protected $user;
public function setUp()
protected function setUp()
{
self::bootKernel();
@@ -89,9 +93,9 @@ class ActivityTypeTest extends KernelTestCase
$form->submit([]);
$this->assertTrue($form->isSynchronized());
$this->assertTrue($form->isValid());
$this->assertInstanceOf(Activity::class, $form->getData()['activity']);
self::assertTrue($form->isSynchronized());
self::assertTrue($form->isValid());
self::assertInstanceOf(Activity::class, $form->getData()['activity']);
}
public function testFormSubmitting()
@@ -114,25 +118,25 @@ class ActivityTypeTest extends KernelTestCase
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
// var_dump($form->getErrors());
$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']);
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']);
// test the activity
/* @var $activity Activity */
/** @var Activity $activity */
$activity = $form->getData()['activity'];
$this->assertEquals(
self::assertEquals(
'09-03-2015',
$activity->getDate()->format('d-m-Y'),
'Test the date is correct'
);
$this->assertEquals(
self::assertEquals(
'00:05',
$activity->getDurationTime()->format('H:i'),
'Test the formatted hour is correct'
);
$this->assertEquals(true, $activity->getAttendee());
self::assertTrue($activity->getAttendee());
// $this->assertEquals('blabla', $activity->getRemark());
}
@@ -166,14 +170,14 @@ class ActivityTypeTest extends KernelTestCase
'attendee' => true,
]]);
$this->assertTrue($form->isSynchronized());
$this->assertTrue($form->isValid());
self::assertTrue($form->isSynchronized());
self::assertTrue($form->isValid());
// test the activity
/* @var $activity Activity */
/** @var Activity $activity */
$activity = $form->getData()['activity'];
$this->assertEquals(
self::assertEquals(
'00:01',
$activity->getDurationTime()->format('H:i'),
'Test the formatted hour is correct'
@@ -182,14 +186,14 @@ class ActivityTypeTest extends KernelTestCase
// test the view : we want to be sure that the entry with 60 seconds exists
$view = $form->createView();
$this->assertTrue(isset($view['activity']['durationTime']));
self::assertTrue(isset($view['activity']['durationTime']));
// map all the values in an array
$values = array_map(
function ($choice) { return $choice->value; },
static function ($choice) { return $choice->value; },
$view['activity']['durationTime']->vars['choices']
);
$this->assertContains(60, $values);
self::assertContains(60, $values);
}
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,14 +24,14 @@ use Symfony\Component\Form\Test\TypeTestCase;
* @internal
* @coversNothing
*/
class TranslatableActivityReasonTest extends TypeTestCase
final class TranslatableActivityReasonTest extends TypeTestCase
{
/**
* @var Prophecy\Prophet
*/
private static $prophet;
public function setUp()
protected function setUp()
{
parent::setUp();
}
@@ -38,7 +42,7 @@ class TranslatableActivityReasonTest extends TypeTestCase
$this->getTranslatableStringHelper()
);
$this->markTestSkipped('See issue 651');
self::markTestSkipped('See issue 651');
}
/**
@@ -81,7 +85,7 @@ class TranslatableActivityReasonTest extends TypeTestCase
$request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack');
$requestStack->getCurrentRequest()->will(function () use ($request) {
$requestStack->getCurrentRequest()->will(static function () use ($request) {
return $request;
});

View File

@@ -1,12 +1,16 @@
<?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;
@@ -17,7 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
* @internal
* @coversNothing
*/
class TranslatableActivityTypeTest extends KernelTestCase
final class TranslatableActivityTypeTest extends KernelTestCase
{
/**
* @var \Symfony\Component\Form\FormBuilderInterface
@@ -29,7 +33,7 @@ class TranslatableActivityTypeTest extends KernelTestCase
*/
protected $container;
public function setUp()
protected function setUp()
{
self::bootKernel();
@@ -59,13 +63,13 @@ class TranslatableActivityTypeTest extends KernelTestCase
'type' => $type->getId(),
]);
$this->assertTrue($form->isSynchronized());
$this->assertInstanceOf(
self::assertTrue($form->isSynchronized());
self::assertInstanceOf(
\Chill\ActivityBundle\Entity\ActivityType::class,
$form->getData()['type'],
'The data is an instance of Chill\\ActivityBundle\\Entity\\ActivityType'
);
$this->assertEquals($type->getId(), $form->getData()['type']->getId());
self::assertEquals($type->getId(), $form->getData()['type']->getId());
// test the ordering of the types in the form
// since 2016-11-14 the types are not alphabetically ordered, skipping

View File

@@ -1,12 +1,16 @@
<?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;
@@ -24,7 +28,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
* @internal
* @coversNothing
*/
class ActivityVoterTest extends KernelTestCase
final class ActivityVoterTest extends KernelTestCase
{
use PrepareActivityTrait;
use PrepareCenterTrait;
@@ -42,10 +46,10 @@ class ActivityVoterTest extends KernelTestCase
*/
protected $voter;
public function setUp()
protected function setUp()
{
static::bootKernel();
$this->voter = static::$kernel->getContainer()
self::bootKernel();
$this->voter = self::$kernel->getContainer()
->get('chill.activity.security.authorization.activity_voter');
$this->prophet = new \Prophecy\Prophet();
}
@@ -111,7 +115,7 @@ class ActivityVoterTest extends KernelTestCase
$scope = $this->prepareScope(1, 'default');
$activity = $this->prepareActivity($scope, $person);
$this->assertEquals(
self::assertEquals(
VoterInterface::ACCESS_DENIED,
$this->voter->vote($token, $activity, ['CHILL_ACTIVITY_SEE']),
'assert that a null user is not allowed to see'
@@ -136,7 +140,7 @@ class ActivityVoterTest extends KernelTestCase
$token = $this->prepareToken($user);
$activity = $this->prepareActivity($scope, $this->preparePerson($center));
$this->assertEquals(
self::assertEquals(
$expectedResult,
$this->voter->vote($token, $activity, [$attribute]),
$message

View File

@@ -1,12 +1,16 @@
<?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;
@@ -15,10 +19,10 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class TimelineProviderTest extends WebTestCase
final class TimelineProviderTest extends WebTestCase
{
public function testAnActivityIsShownOnTimeline()
{
$this->markTestSkipped('we have to write fixtures before writing this tests');
self::markTestSkipped('we have to write fixtures before writing this tests');
}
}

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,6 +24,8 @@ 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.
*/
@@ -58,6 +64,9 @@ class TimelineActivityProvider implements TimelineProviderInterface
$this->user = $storage->getToken()->getUser();
}
/**
* {@inheritdoc}
*/
public function fetchQuery($context, array $args)
{
$this->checkContext($context);
@@ -80,6 +89,9 @@ class TimelineActivityProvider implements TimelineProviderInterface
];
}
/**
* {@inheritdoc}
*/
public function getEntities(array $ids)
{
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
@@ -94,6 +106,9 @@ class TimelineActivityProvider implements TimelineProviderInterface
return $result;
}
/**
* {@inheritdoc}
*/
public function getEntityTemplate($entity, $context, array $args)
{
$this->checkContext($context);
@@ -108,6 +123,9 @@ class TimelineActivityProvider implements TimelineProviderInterface
];
}
/**
* {@inheritdoc}
*/
public function supportsType($type)
{
return 'activity' === $type;
@@ -171,7 +189,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
foreach ($reachableCenters as $center) {
$reachablesScopesId = array_map(
function (Scope $scope) {
static function (Scope $scope) {
return $scope->getId();
},
$this->helper->getReachableScopes(

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,7 +24,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');
@@ -38,7 +42,7 @@ class Version20150701091248 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,7 +24,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;');
@@ -33,7 +37,7 @@ class Version20150702093317 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;');
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,7 +24,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;');
@@ -29,7 +33,7 @@ class Version20150704091347 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE Activity ALTER COLUMN remark DROP NOT NULL;');
$this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;');

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,7 +27,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\'.'
);
@@ -35,7 +39,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
@@ -50,7 +54,7 @@ class Version20160222103457 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
$this->connection->getDatabasePlatform()->getName() !== 'postgresql',
'Migration can only be executed safely on \'postgresql\'.'
);

View File

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

View File

@@ -1,10 +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);

View File

@@ -1,10 +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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -20,6 +24,8 @@ 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
{
/**
@@ -111,7 +117,7 @@ abstract class AbstractElementController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() and $form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->flush();
@@ -135,7 +141,7 @@ abstract class AbstractElementController extends Controller
*/
protected function _new(Person $person, Request $request, $template, $flashMessageOnSuccess)
{
/* @var $element \Chill\AMLI\BudgetBundle\Entity\AbstractElement */
/** @var \Chill\AMLI\BudgetBundle\Entity\AbstractElement $element */
$element = $this->createNewElement()
->setPerson($person);
@@ -146,7 +152,7 @@ abstract class AbstractElementController extends Controller
$form->handleRequest($request);
if ($form->isSubmitted() and $form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($element);
$em->flush();

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -21,7 +25,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Translation\TranslatorInterface;
use function array_merge;
use function count;
class ElementController extends Controller
{

View File

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

View File

@@ -1,12 +1,16 @@
<?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;
@@ -23,6 +27,9 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class ChillAMLIBudgetExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
@@ -47,7 +54,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