mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 09:05:01 +00:00
Compare commits
2 Commits
dune-risky
...
_31_interf
Author | SHA1 | Date | |
---|---|---|---|
bc1f624e14 | |||
f73d3bf320 |
64
.env
64
.env
@@ -1,64 +0,0 @@
|
|||||||
##
|
|
||||||
## Manually dump .env files in .env.local.php with
|
|
||||||
## `$ composer symfony:dump-env prod`
|
|
||||||
##
|
|
||||||
|
|
||||||
## Project environment
|
|
||||||
APP_ENV=dev
|
|
||||||
|
|
||||||
## Enable debug
|
|
||||||
APP_DEBUG=true
|
|
||||||
|
|
||||||
## Locale
|
|
||||||
LOCALE=fr
|
|
||||||
|
|
||||||
## Framework secret
|
|
||||||
APP_SECRET=ThisTokenIsNotSoSecretChangeIt
|
|
||||||
|
|
||||||
## Symfony/swiftmailer
|
|
||||||
MAILER_TRANSPORT=smtp
|
|
||||||
MAILER_HOST=smtp
|
|
||||||
MAILER_PORT=1025
|
|
||||||
MAILER_CRYPT=
|
|
||||||
MAILER_AUTH=
|
|
||||||
MAILER_USER=
|
|
||||||
MAILER_PASSWORD=
|
|
||||||
MAILER_URL=${MAILER_TRANSPORT}://${MAILER_HOST}:${MAILER_PORT}?encryption=${MAILER_CRYPT}&auth_mode=${MAILER_AUTH}&username=${MAILER_USER}&password=${MAILER_PASSWORD}
|
|
||||||
|
|
||||||
## Notifications
|
|
||||||
NOTIFICATION_HOST=localhost:8001
|
|
||||||
NOTIFICATION_FROM_EMAIL=admin@chill.social
|
|
||||||
NOTIFICATION_FROM_NAME=Chill
|
|
||||||
|
|
||||||
## Gelf
|
|
||||||
GELF_HOST=gelf
|
|
||||||
GELF_PORT=12201
|
|
||||||
|
|
||||||
## OVH OpenStack Storage User/Role
|
|
||||||
OS_USERNAME=
|
|
||||||
OS_PASSWORD=
|
|
||||||
OS_TENANT_ID=
|
|
||||||
OS_REGION_NAME=GRA
|
|
||||||
OS_AUTH_URL=https://auth.cloud.ovh.net/v2.0/
|
|
||||||
|
|
||||||
## OVH OpenStack Storage Container
|
|
||||||
ASYNC_UPLOAD_TEMP_URL_KEY=
|
|
||||||
ASYNC_UPLOAD_TEMP_URL_BASE_PATH=
|
|
||||||
ASYNC_UPLOAD_TEMP_URL_CONTAINER=
|
|
||||||
|
|
||||||
## Redis Cache
|
|
||||||
REDIS_HOST=redis
|
|
||||||
REDIS_PORT=6379
|
|
||||||
REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}
|
|
||||||
|
|
||||||
## Twilio
|
|
||||||
TWILIO_SID=~
|
|
||||||
TWILIO_SECRET=~
|
|
||||||
|
|
||||||
## DOCKER IMAGES REGISTRY
|
|
||||||
#IMAGE_PHP=
|
|
||||||
#IMAGE_NGINX=
|
|
||||||
|
|
||||||
## DOCKER IMAGES VERSION
|
|
||||||
#VERSION=test
|
|
||||||
VERSION=prod
|
|
@@ -1,6 +0,0 @@
|
|||||||
# variables for .env environement
|
|
||||||
# those variables suits for gitlab-ci
|
|
||||||
# Run tests from root to adapt your own environment
|
|
||||||
KERNEL_CLASS='App\Kernel'
|
|
||||||
APP_SECRET='$ecretf0rt3st'
|
|
||||||
DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres?serverVersion=12&charset=utf8
|
|
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,22 +1,4 @@
|
|||||||
.composer/*
|
.composer/*
|
||||||
composer.phar
|
composer.phar
|
||||||
composer.lock
|
|
||||||
docs/build/
|
docs/build/
|
||||||
.php_cs.cache
|
|
||||||
|
|
||||||
###> symfony/framework-bundle ###
|
|
||||||
/.env.local
|
|
||||||
/.env.local.php
|
|
||||||
/.env.*.local
|
|
||||||
/config/secrets/prod/prod.decrypt.private.php
|
|
||||||
/public/bundles/
|
|
||||||
/var/
|
|
||||||
/vendor/
|
|
||||||
/bin/
|
|
||||||
###< symfony/framework-bundle ###
|
|
||||||
|
|
||||||
###> phpunit/phpunit ###
|
|
||||||
/phpunit.xml
|
|
||||||
.phpunit.result.cache
|
|
||||||
###< phpunit/phpunit ###
|
|
||||||
|
|
||||||
|
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
|
|
||||||
|
|
||||||
# Select what we should cache between builds
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- tests/app/vendor/
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
# add extensions to postgres
|
|
||||||
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
|
||||||
# Install and run Composer
|
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
|
||||||
- php composer.phar install
|
|
||||||
- php tests/app/bin/console doctrine:migrations:migrate -n
|
|
||||||
- php tests/app/bin/console doctrine:fixtures:load -n
|
|
||||||
|
|
||||||
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
|
||||||
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
|
|
||||||
services:
|
|
||||||
- name: postgres:12
|
|
||||||
alias: db
|
|
||||||
- name: redis
|
|
||||||
alias: redis
|
|
||||||
|
|
||||||
# Set any variables we need
|
|
||||||
variables:
|
|
||||||
# Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
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:
|
|
||||||
script:
|
|
||||||
- bin/phpunit --colors=never
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
|||||||
[submodule "_exts/sphinx-php"]
|
[submodule "_exts/sphinx-php"]
|
||||||
path = _exts/sphinx-php
|
path = _exts/sphinx-php
|
||||||
url = https://github.com/fabpot/sphinx-php.git
|
url = https://github.com/fabpot/sphinx-php.git
|
||||||
[submodule "tests/app"]
|
|
||||||
path = tests/app
|
|
||||||
url = https://gitlab.com/Chill-projet/chill-app.git
|
|
||||||
|
@@ -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
|
|
@@ -19,11 +19,6 @@
|
|||||||
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle"
|
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"App\\": "tests/app/src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"require": {
|
"require": {
|
||||||
"champs-libres/async-uploader-bundle": "dev-sf4",
|
"champs-libres/async-uploader-bundle": "dev-sf4",
|
||||||
"graylog2/gelf-php": "^1.5",
|
"graylog2/gelf-php": "^1.5",
|
||||||
@@ -72,17 +67,6 @@
|
|||||||
"symfony/stopwatch": "^5.1",
|
"symfony/stopwatch": "^5.1",
|
||||||
"symfony/web-profiler-bundle": "^5.0",
|
"symfony/web-profiler-bundle": "^5.0",
|
||||||
"symfony/var-dumper": "4.*",
|
"symfony/var-dumper": "4.*",
|
||||||
"symfony/debug-bundle": "^5.1",
|
"symfony/debug-bundle": "^5.1"
|
||||||
"symfony/phpunit-bridge": "^5.2"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"auto-scripts": {
|
|
||||||
"cache:clear": "symfony-cmd",
|
|
||||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"vendor-dir": "tests/app/vendor",
|
|
||||||
"bin-dir": "bin"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,19 +10,10 @@ Compilation into HTML
|
|||||||
|
|
||||||
To compile this documentation :
|
To compile this documentation :
|
||||||
|
|
||||||
1. Install [sphinx-doc](http://sphinx-doc.org)
|
1. Install [sphinx-doc](http://sphinx-doc.org) (eg. pip install sphinx & pip install sphinx_rtd_theme)
|
||||||
``` bash
|
|
||||||
$ virtualenv .venv # creation of the virtual env (only the first time)
|
|
||||||
$ source .venv/bin/activate # activate the virtual env
|
|
||||||
(.venv) $ pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
2. Install submodules : $ git submodule update --init;
|
2. Install submodules : $ git submodule update --init;
|
||||||
3. run `make html` from the root directory
|
3. run `make html` from the root directory
|
||||||
4. The base file is located on build/html/index.html
|
4. The base file is located on build/html/index.html
|
||||||
``` bash
|
|
||||||
$ cd build/html
|
|
||||||
$ python -m http.server 8888 # will serve the site on the port 8888
|
|
||||||
```
|
|
||||||
|
|
||||||
Contribute
|
Contribute
|
||||||
===========
|
===========
|
||||||
|
@@ -29,7 +29,7 @@ As Chill rely on the `symfony <http://symfony.com>`_ framework, reading the fram
|
|||||||
Timelines <timelines.rst>
|
Timelines <timelines.rst>
|
||||||
Exports <exports.rst>
|
Exports <exports.rst>
|
||||||
Embeddable comments <embeddable-comments.rst>
|
Embeddable comments <embeddable-comments.rst>
|
||||||
Run tests <run-tests.rst>
|
Testing <make-test-working.rst>
|
||||||
Useful snippets <useful-snippets.rst>
|
Useful snippets <useful-snippets.rst>
|
||||||
manual/index.rst
|
manual/index.rst
|
||||||
Assets <assets.rst>
|
Assets <assets.rst>
|
||||||
|
231
docs/source/development/make-test-working.rst
Normal file
231
docs/source/development/make-test-working.rst
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
.. 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".
|
||||||
|
|
||||||
|
Make tests working
|
||||||
|
******************
|
||||||
|
|
||||||
|
Unit and functional tests are important to ensure that bundle may be deployed securely.
|
||||||
|
|
||||||
|
In reason of the Chill architecture, test should be runnable from the bundle's directory and works correctly: this will allow continuous integration tools to run tests automatically.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Integration tools (i.e. `travis-ci <https://travis-ci.org>`_) works like this :
|
||||||
|
|
||||||
|
* they clone the bundle repository in a virtual machine, using git
|
||||||
|
* they optionnaly run `composer` to download and install depedencies
|
||||||
|
* they optionnaly run other command to prepare a database, insert fixtures, ...
|
||||||
|
* they run test
|
||||||
|
|
||||||
|
On the developer's machine test should be runnable with two or three commands **runned from the bundle directory** :
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ composer install --dev
|
||||||
|
$ // command to insert fixtures, ...
|
||||||
|
$ phpunit
|
||||||
|
|
||||||
|
This chapter has been inspired by `this useful blog post <http://blog.kevingomez.fr/2013/01/09/functional-testing-standalone-symfony2-bundles/>`_.
|
||||||
|
|
||||||
|
Bootstrap phpunit for a standalone bundle
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
Unit tests should run after achieving this step.
|
||||||
|
|
||||||
|
|
||||||
|
phpunit.xml
|
||||||
|
-----------
|
||||||
|
|
||||||
|
A `phpunit.xml.dist` file should be present at the bundle root.
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
|
||||||
|
<!-- the file "./Tests/boostrap.php" will be created on the next step -->
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="ChillMain test suite">
|
||||||
|
<directory suffix="Test.php">./Tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory>./</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory>./Resources</directory>
|
||||||
|
<directory>./Tests</directory>
|
||||||
|
<directory>./vendor</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
||||||
|
|
||||||
|
|
||||||
|
bootstrap.php
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A file `boostrap.php`, located in the `Tests` directory, will allow phpunit to resolve class autoloading :
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
|
||||||
|
throw new \LogicException('Could not find autoload.php in vendor/. Did you run "composer install --dev"?');
|
||||||
|
}
|
||||||
|
|
||||||
|
require $autoloadFile;
|
||||||
|
|
||||||
|
|
||||||
|
composer.json
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The `composer.json` file **located at the bundle's root** should contains all depencies needed to run test (and to execute bundle functions).
|
||||||
|
|
||||||
|
Ensure that all dependencies are included in the `require` and `require-dev` sections.
|
||||||
|
|
||||||
|
|
||||||
|
Functional tests
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to access services, database, and run functional tests, you will have to bootstrap a symfony app, with the minimal configuration. Three files are required :
|
||||||
|
|
||||||
|
* a `config_test.yml` file (eventually with a `config.yml`);
|
||||||
|
* a `routing.yml` file
|
||||||
|
* an `AppKernel.php` file
|
||||||
|
|
||||||
|
Adapt phpunit.xml
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
You should add reference to the new application within `phpunit.xml.dist`. The directive `<php>` should be added like this, if your `AppKernel.php` file is located in `Tests/Fixtures/App` directory:
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="ChillMain test suite">
|
||||||
|
<directory suffix="Test.php">./Tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory>./</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory>./Resources</directory>
|
||||||
|
<directory>./Tests</directory>
|
||||||
|
<directory>./vendor</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
<!-- the lines we added -->
|
||||||
|
<php>
|
||||||
|
<server name="KERNEL_DIR" value="./Tests/Fixtures/App/" />
|
||||||
|
</php>
|
||||||
|
</phpunit>
|
||||||
|
|
||||||
|
AppKernel.php
|
||||||
|
-------------
|
||||||
|
|
||||||
|
This file boostrap the app. It contains three functions. This is the file used in the ChillMain bundle :
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
|
||||||
|
class AppKernel extends Kernel
|
||||||
|
{
|
||||||
|
public function registerBundles()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||||
|
new Chill\MainBundle\ChillMainBundle(),
|
||||||
|
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||||
|
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||||
|
new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
||||||
|
#add here all the required bundle (some bundle are not required)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||||
|
{
|
||||||
|
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCacheDir()
|
||||||
|
{
|
||||||
|
return sys_get_temp_dir().'/ChillMainBundle/cache';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLogDir()
|
||||||
|
{
|
||||||
|
return sys_get_temp_dir().'/ChillMainBundle/logs';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_test.yml
|
||||||
|
---------------
|
||||||
|
|
||||||
|
There are only few parameters required for the config file. This is a basic version for ChillMain :
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# config/config_test.yml
|
||||||
|
imports:
|
||||||
|
- { resource: config.yml } #here we import a config.yml file, this is not required
|
||||||
|
|
||||||
|
framework:
|
||||||
|
test: ~
|
||||||
|
session:
|
||||||
|
storage_id: session.storage.filesystem
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# config/config.yml
|
||||||
|
framework:
|
||||||
|
secret: Not very secret
|
||||||
|
router: { resource: "%kernel.root_dir%/config/routing.yml" }
|
||||||
|
form: true
|
||||||
|
csrf_protection: true
|
||||||
|
session: ~
|
||||||
|
default_locale: fr
|
||||||
|
translator: { fallback: fr }
|
||||||
|
profiler: { only_exceptions: false }
|
||||||
|
templating: #required for assetic. Remove if not needed
|
||||||
|
engines: ['twig']
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
You must adapt config.yml file according to your required bundle. Some options will be missing, other may be removed...
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
If you would like to tests different environments, with differents configuration, you could create differents config_XXX.yml files.
|
||||||
|
|
||||||
|
routing.yml
|
||||||
|
------------
|
||||||
|
|
||||||
|
You should add there all routing information needed for your bundle.
|
||||||
|
|
||||||
|
.. code-block: yaml
|
||||||
|
|
||||||
|
chill_main_bundle:
|
||||||
|
resource: "@CLChillMainBundle/Resources/config/routing.yml"
|
||||||
|
|
||||||
|
That's it. Tests should pass.
|
@@ -1,68 +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".
|
|
||||||
|
|
||||||
Run tests
|
|
||||||
*********
|
|
||||||
|
|
||||||
In reason of the Chill architecture, test should be runnable from the bundle's directory and works correctly: this will allow continuous integration tools to run tests automatically.
|
|
||||||
|
|
||||||
From chill app
|
|
||||||
==============
|
|
||||||
|
|
||||||
This is the most convenient method for developer: run test for chill bundle from the main app.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# run into a container
|
|
||||||
docker-compose exec --user $(id -u) php bash
|
|
||||||
# execute all tests suites
|
|
||||||
bin/phpunit
|
|
||||||
# .. or execute a single test
|
|
||||||
bin/phpunit vendor/chill-project/chill-bundles/src/Bundle/ChillMainBundle/Tests/path/to/FileTest.php
|
|
||||||
|
|
||||||
You can also run tests in a single command:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
docker-compose exec --user $(id -u) php bin/phpunit
|
|
||||||
|
|
||||||
|
|
||||||
Tests from a bundle (chill-bundles)
|
|
||||||
-----------------------------------
|
|
||||||
|
|
||||||
Those tests needs the whole symfony app to execute Application Tests (which test html page).
|
|
||||||
|
|
||||||
For ease, the app is cloned using a :code:`git submodule`, which clone the main app into :code:`tests/app`, and tests are bootstrapped to this app. The dependencies are also installed into `tests/app/vendor` to ensure compliance with relative path from this symfony application.
|
|
||||||
|
|
||||||
You may boostrap the tests fro the chill bundle this way:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# ensure to be located into the environement (provided by docker suits well)
|
|
||||||
docker-compose exec --user $(id -u) php bash
|
|
||||||
# go to chill subdirectory
|
|
||||||
cd vendor/chill-project/chill-bundles
|
|
||||||
# install submodule
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
# install composer and dependencies
|
|
||||||
curl -sS https://getcomposer.org/installer | php
|
|
||||||
# run tests
|
|
||||||
bin/phpunit
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
If you are on a fresh install, you will need to migrate database schema.
|
|
||||||
|
|
||||||
The path to console tool must be adapted to the app. To load migration and add fixtures, one can execute the following commands:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
tests/app/bin/console doctrine:migrations:migrate
|
|
||||||
tests/app/bin/console doctrine:fixtures:load
|
|
||||||
|
|
@@ -97,7 +97,7 @@ The has the following signature :
|
|||||||
*
|
*
|
||||||
* @param string $context
|
* @param string $context
|
||||||
* @param mixed[] $args the argument to the context.
|
* @param mixed[] $args the argument to the context.
|
||||||
* @return TimelineSingleQuery
|
* @return string[]
|
||||||
* @throw \LogicException if the context is not supported
|
* @throw \LogicException if the context is not supported
|
||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args);
|
public function fetchQuery($context, array $args);
|
||||||
@@ -163,16 +163,18 @@ The has the following signature :
|
|||||||
The `fetchQuery` function
|
The `fetchQuery` function
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The fetchQuery function help to build the UNION query to gather events. This function should return an instance of :code:`TimelineSingleQuery`. For you convenience, this object may be build using an associative array with the following keys:
|
The fetchQuery function help to build the UNION query to gather events. This function should return an associative array MUST have the following key :
|
||||||
|
|
||||||
* `id` : the name of the id column
|
* `id` : the name of the id column
|
||||||
* `type`: a string to indicate the type
|
* `type`: a string to indicate the type
|
||||||
* `date`: the name of the datetime column, used to order entities by date
|
* `date`: the name of the datetime column, used to order entities by date
|
||||||
* `FROM`: the FROM clause. May contains JOIN instructions
|
* `FROM` (in capital) : the FROM clause. May contains JOIN instructions
|
||||||
* `WHERE`: the WHERE clause;
|
|
||||||
* `parameters`: the parameters to pass to the query
|
|
||||||
|
|
||||||
The parameters should be replaced into the query by :code:`?`. They will be replaced into the query using prepared statements.
|
Those key are optional:
|
||||||
|
|
||||||
|
* `WHERE` (in capital) : the WHERE clause.
|
||||||
|
|
||||||
|
Where relevant, the data must be quoted to avoid SQL injection.
|
||||||
|
|
||||||
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
||||||
|
|
||||||
@@ -184,15 +186,6 @@ For instance, if the context is `'person'`, the args will be this array :
|
|||||||
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
||||||
);
|
);
|
||||||
|
|
||||||
For the context :code:`center`, the args will be:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
array(
|
|
||||||
'centers' => [ ] // an array of \Chill\MainBundle\Entity\Center entities
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -206,12 +199,13 @@ Example of an implementation :
|
|||||||
namespace Chill\ReportBundle\Timeline;
|
namespace Chill\ReportBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide report for inclusion in timeline
|
* Provide report for inclusion in timeline
|
||||||
*
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class TimelineReportProvider implements TimelineProviderInterface
|
class TimelineReportProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
@@ -233,17 +227,16 @@ Example of an implementation :
|
|||||||
|
|
||||||
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
return array(
|
||||||
'id' => $metadata->getColumnName('id'),
|
'id' => $metadata->getColumnName('id'),
|
||||||
'type' => 'report',
|
'type' => 'report',
|
||||||
'date' => $metadata->getColumnName('date'),
|
'date' => $metadata->getColumnName('date'),
|
||||||
'FROM' => $metadata->getTableName(),
|
'FROM' => $metadata->getTableName(),
|
||||||
'WHERE' => sprintf('%s = ?',
|
'WHERE' => sprintf('%s = %d',
|
||||||
$metadata
|
$metadata
|
||||||
->getAssociationMapping('person')['joinColumns'][0]['name'])
|
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
||||||
)
|
$args['person']->getId())
|
||||||
'parameters' => [ $args['person']->getId() ]
|
);
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//....
|
//....
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
|
||||||
backupGlobals="false"
|
|
||||||
colors="true"
|
|
||||||
bootstrap="tests/app/tests/bootstrap.php"
|
|
||||||
>
|
|
||||||
<php>
|
|
||||||
<ini name="error_reporting" value="-1" />
|
|
||||||
<server name="APP_ENV" value="test" force="true" />
|
|
||||||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
|
|
||||||
<server name="SHELL_VERBOSITY" value="-1" />
|
|
||||||
</php>
|
|
||||||
|
|
||||||
<testsuites>
|
|
||||||
<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>
|
|
||||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
|
||||||
</listeners>
|
|
||||||
|
|
||||||
<!-- Run `composer require symfony/panther` before enabling this extension -->
|
|
||||||
<!--
|
|
||||||
<extensions>
|
|
||||||
<extension class="Symfony\Component\Panther\ServerExtension" />
|
|
||||||
</extensions>
|
|
||||||
-->
|
|
||||||
</phpunit>
|
|
@@ -38,7 +38,7 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
|||||||
* Class Activity
|
* Class Activity
|
||||||
*
|
*
|
||||||
* @package Chill\ActivityBundle\Entity
|
* @package Chill\ActivityBundle\Entity
|
||||||
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="activity")
|
* @ORM\Table(name="activity")
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
* @UserCircleConsistency(
|
* @UserCircleConsistency(
|
||||||
|
@@ -1,169 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@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\Repository;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ActivityBundle\Repository\ActivityRepository;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Doctrine\ORM\Query\Expr\Orx;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
|
|
||||||
|
|
||||||
final class ActivityACLAwareRepository
|
|
||||||
{
|
|
||||||
private AuthorizationHelper $authorizationHelper;
|
|
||||||
|
|
||||||
private TokenStorageInterface $tokenStorage;
|
|
||||||
|
|
||||||
private ActivityRepository $repository;
|
|
||||||
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
AuthorizationHelper $authorizationHelper,
|
|
||||||
TokenStorageInterface $tokenStorage,
|
|
||||||
ActivityRepository $repository,
|
|
||||||
EntityManagerInterface $em
|
|
||||||
) {
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->repository = $repository;
|
|
||||||
$this->em = $em;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function queryTimelineIndexer(string $context, array $args = []): array
|
|
||||||
{
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
|
|
||||||
$from = $this->getFromClauseCenter($args);
|
|
||||||
[$where, $parameters] = $this->getWhereClause($context, $args);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'id' => $metadataActivity->getTableName()
|
|
||||||
.'.'.$metadataActivity->getColumnName('id'),
|
|
||||||
'type' => 'activity',
|
|
||||||
'date' => $metadataActivity->getTableName()
|
|
||||||
.'.'.$metadataActivity->getColumnName('date'),
|
|
||||||
'FROM' => $from,
|
|
||||||
'WHERE' => $where,
|
|
||||||
'parameters' => $parameters
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getFromClauseCenter(array $args): string
|
|
||||||
{
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
|
||||||
|
|
||||||
return $metadataActivity->getTableName().' JOIN '
|
|
||||||
.$metadataPerson->getTableName().' ON '
|
|
||||||
.$metadataPerson->getTableName().'.'.
|
|
||||||
$associationMapping['joinColumns'][0]['referencedColumnName']
|
|
||||||
.' = '
|
|
||||||
.$associationMapping['joinColumns'][0]['name']
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getWhereClause(string $context, array $args): array
|
|
||||||
{
|
|
||||||
$where = '';
|
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$activityToPerson = $metadataActivity->getAssociationMapping('person')['joinColumns'][0]['name'];
|
|
||||||
$activityToScope = $metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'];
|
|
||||||
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
|
||||||
|
|
||||||
|
|
||||||
// acls:
|
|
||||||
$role = new Role(ActivityVoter::SEE);
|
|
||||||
$reachableCenters = $this->authorizationHelper->getReachableCenters($this->tokenStorage->getToken()->getUser(),
|
|
||||||
$role);
|
|
||||||
|
|
||||||
if (count($reachableCenters) === 0) {
|
|
||||||
// insert a dummy condition
|
|
||||||
return 'FALSE = TRUE';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context === 'person') {
|
|
||||||
// we start with activities having the person_id linked to person
|
|
||||||
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
|
||||||
$parameters[] = $person->getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
// we add acl (reachable center and scopes)
|
|
||||||
$where .= '('; // first loop for the for centers
|
|
||||||
$centersI = 0; // like centers#i
|
|
||||||
foreach ($reachableCenters as $center) {
|
|
||||||
// we pass if not in centers
|
|
||||||
if (!\in_array($center, $args['centers'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// we get all the reachable scopes for this center
|
|
||||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
|
||||||
// we get the ids for those scopes
|
|
||||||
$reachablesScopesId = array_map(
|
|
||||||
function(Scope $scope) { return $scope->getId(); },
|
|
||||||
$reachableScopes
|
|
||||||
);
|
|
||||||
|
|
||||||
// if not the first center
|
|
||||||
if ($centersI > 0) {
|
|
||||||
$where .= ') OR (';
|
|
||||||
}
|
|
||||||
|
|
||||||
// condition for the center
|
|
||||||
$where .= sprintf(' %s.%s = ? ', $metadataPerson->getTableName(), $personToCenter);
|
|
||||||
$parameters[] = $center->getId();
|
|
||||||
|
|
||||||
// begin loop for scopes
|
|
||||||
$where .= ' AND (';
|
|
||||||
$scopesI = 0; //like scope#i
|
|
||||||
|
|
||||||
foreach ($reachablesScopesId as $scopeId) {
|
|
||||||
if ($scopesI > 0) {
|
|
||||||
$where .= ' OR ';
|
|
||||||
}
|
|
||||||
$where .= sprintf(' %s.%s = ? ', $metadataActivity->getTableName(), $activityToScope);
|
|
||||||
$parameters[] = $scopeId;
|
|
||||||
$scopesI ++;
|
|
||||||
}
|
|
||||||
// close loop for scopes
|
|
||||||
$where .= ') ';
|
|
||||||
$centersI++;
|
|
||||||
}
|
|
||||||
// close loop for centers
|
|
||||||
$where .= ')';
|
|
||||||
|
|
||||||
return [$where, $parameters];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@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\Repository;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method AccompanyingPeriodParticipation[] findAll()
|
|
||||||
* @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class ActivityRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, Activity::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,11 +1,11 @@
|
|||||||
{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %}
|
{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3>{{ activity.date|format_date('long') }}<span class="activity"> / {{ 'Activity'|trans }}</span>{% if 'person' != context %} / {{ activity.person|chill_entity_render_box({'addLink': true}) }}{% endif %}</h3>
|
<h3>{{ activity.date|format_date('long') }}<span class="activity"> / {{ 'Activity'|trans }}</span></h3>
|
||||||
<div class="statement">
|
<div class="statement">
|
||||||
<span class="statement">{{ '%user% has done an %activity_type%'|trans(
|
<span class="statement">{{ '%user% has done an %activity_type%'|trans(
|
||||||
{
|
{
|
||||||
'%user%' : activity.user,
|
'%user%' : user,
|
||||||
'%activity_type%': activity.type.name|localize_translatable_string,
|
'%activity_type%': activity.type.name|localize_translatable_string,
|
||||||
'%date%' : activity.date|format_date('long') }
|
'%date%' : activity.date|format_date('long') }
|
||||||
) }}</span>
|
) }}</span>
|
||||||
@@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_show', { 'person_id': activity.person.id, 'id': activity.id} ) }}" class="sc-button bt-view">
|
<a href="{{ path('chill_activity_activity_show', { 'person_id': person.id, 'id': activity.id} ) }}" class="sc-button bt-view">
|
||||||
{{ 'Show the activity'|trans }}
|
{{ 'Show the activity'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_edit', { 'person_id': activity.person.id, 'id': activity.id} ) }}" class="sc-button bt-edit">
|
<a href="{{ path('chill_activity_activity_edit', { 'person_id': person.id, 'id': activity.id} ) }}" class="sc-button bt-edit">
|
||||||
{{ 'Edit the activity'|trans }}
|
{{ 'Edit the activity'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
namespace Chill\ActivityBundle\Timeline;
|
namespace Chill\ActivityBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
@@ -29,13 +28,13 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide activity for inclusion in timeline
|
* Provide activity for inclusion in timeline
|
||||||
*
|
*
|
||||||
*/
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
|
*/
|
||||||
class TimelineActivityProvider implements TimelineProviderInterface
|
class TimelineActivityProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -57,10 +56,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected ActivityACLAwareRepository $aclAwareRepository;
|
|
||||||
|
|
||||||
private const SUPPORTED_CONTEXTS = [ 'center', 'person'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimelineActivityProvider constructor.
|
* TimelineActivityProvider constructor.
|
||||||
*
|
*
|
||||||
@@ -71,13 +66,11 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $em,
|
EntityManager $em,
|
||||||
AuthorizationHelper $helper,
|
AuthorizationHelper $helper,
|
||||||
TokenStorageInterface $storage,
|
TokenStorageInterface $storage
|
||||||
ActivityACLAwareRepository $aclAwareRepository
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
$this->aclAwareRepository = $aclAwareRepository;
|
|
||||||
|
|
||||||
if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
|
if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
|
||||||
{
|
{
|
||||||
@@ -93,69 +86,67 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
if ('center' === $context) {
|
$this->checkContext($context);
|
||||||
return TimelineSingleQuery::fromArray($this->aclAwareRepository
|
|
||||||
->queryTimelineIndexer($context, $args));
|
|
||||||
}
|
|
||||||
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
$metadataActivity = $this->em->getClassMetadata('ChillActivityBundle:Activity');
|
||||||
|
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||||
|
|
||||||
[$where, $parameters] = $this->getWhereClauseForPerson($args['person']);
|
return array(
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
|
||||||
'id' => $metadataActivity->getTableName()
|
'id' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('id'),
|
.'.'.$metadataActivity->getColumnName('id'),
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'date' => $metadataActivity->getTableName()
|
'date' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('date'),
|
.'.'.$metadataActivity->getColumnName('date'),
|
||||||
'FROM' => $this->getFromClausePerson($args['person']),
|
'FROM' => $this->getFromClause($metadataActivity, $metadataPerson),
|
||||||
'WHERE' => $where,
|
'WHERE' => $this->getWhereClause($metadataActivity, $metadataPerson,
|
||||||
'parameters' => $parameters
|
$args['person'])
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getWhereClauseForPerson(Person $person)
|
private function getWhereClause(ClassMetadata $metadataActivity,
|
||||||
|
ClassMetadata $metadataPerson, Person $person)
|
||||||
{
|
{
|
||||||
$parameters = [];
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
|
||||||
$role = new Role('CHILL_ACTIVITY_SEE');
|
$role = new Role('CHILL_ACTIVITY_SEE');
|
||||||
$reachableScopes = $this->helper->getReachableScopes($this->user,
|
$reachableCenters = $this->helper->getReachableCenters($this->user,
|
||||||
$role, $person->getCenter());
|
$role);
|
||||||
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
$scopes_ids = [];
|
|
||||||
|
|
||||||
// first parameter: activity.person_id
|
if (count($reachableCenters) === 0) {
|
||||||
$parameters[] = $person->getId();
|
return 'FALSE = TRUE';
|
||||||
|
|
||||||
// loop on reachable scopes
|
|
||||||
foreach ($reachableScopes as $scope) {
|
|
||||||
if (\in_array($scope->getId(), $scopes_ids)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$scopes_ids[] = '?';
|
|
||||||
$parameters[] = $scope->getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
// we start with activities having the person_id linked to person
|
||||||
\strtr(
|
// (currently only context "person" is supported)
|
||||||
$whereClause,
|
$whereClause = sprintf('%s = %d',
|
||||||
[
|
$associationMapping['joinColumns'][0]['name'],
|
||||||
'{activity.person_id}' => $associationMapping['joinColumns'][0]['name'],
|
$person->getId());
|
||||||
'{activity.scope_id}' => $metadataActivity->getTableName().'.'.
|
|
||||||
|
// we add acl (reachable center and scopes)
|
||||||
|
$centerAndScopeLines = array();
|
||||||
|
foreach ($reachableCenters as $center) {
|
||||||
|
$reachablesScopesId = array_map(
|
||||||
|
function(Scope $scope) { return $scope->getId(); },
|
||||||
|
$this->helper->getReachableScopes($this->user, $role,
|
||||||
|
$person->getCenter())
|
||||||
|
);
|
||||||
|
|
||||||
|
$centerAndScopeLines[] = sprintf('(%s = %d AND %s IN (%s))',
|
||||||
|
$metadataPerson->getTableName().'.'.
|
||||||
|
$metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'],
|
||||||
|
$center->getId(),
|
||||||
|
$metadataActivity->getTableName().'.'.
|
||||||
$metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'],
|
$metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'],
|
||||||
'{scopes_ids}' => \implode(", ", $scopes_ids)
|
implode(',', $reachablesScopesId));
|
||||||
,
|
|
||||||
]
|
}
|
||||||
),
|
$whereClause .= ' AND ('.implode(' OR ', $centerAndScopeLines).')';
|
||||||
$parameters
|
|
||||||
];
|
return $whereClause;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFromClausePerson()
|
private function getFromClause(ClassMetadata $metadataActivity,
|
||||||
|
ClassMetadata $metadataPerson)
|
||||||
{
|
{
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
|
|
||||||
return $metadataActivity->getTableName().' JOIN '
|
return $metadataActivity->getTableName().' JOIN '
|
||||||
@@ -173,7 +164,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function getEntities(array $ids)
|
public function getEntities(array $ids)
|
||||||
{
|
{
|
||||||
$activities = $this->em->getRepository(Activity::class)
|
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
||||||
->findBy(array('id' => $ids));
|
->findBy(array('id' => $ids));
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
@@ -192,13 +183,14 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
{
|
{
|
||||||
$this->checkContext($context);
|
$this->checkContext($context);
|
||||||
|
|
||||||
return [
|
return array(
|
||||||
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
||||||
'template_data' => [
|
'template_data' => array(
|
||||||
'activity' => $entity,
|
'activity' => $entity,
|
||||||
'context' => $context
|
'person' => $args['person'],
|
||||||
]
|
'user' => $entity->getUser()
|
||||||
];
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +210,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
private function checkContext($context)
|
private function checkContext($context)
|
||||||
{
|
{
|
||||||
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
|
if ($context !== 'person') {
|
||||||
throw new \LogicException("The context '$context' is not "
|
throw new \LogicException("The context '$context' is not "
|
||||||
. "supported. Currently only 'person' is supported");
|
. "supported. Currently only 'person' is supported");
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,6 @@ services:
|
|||||||
- '@doctrine.orm.entity_manager'
|
- '@doctrine.orm.entity_manager'
|
||||||
- '@chill.main.security.authorization.helper'
|
- '@chill.main.security.authorization.helper'
|
||||||
- '@security.token_storage'
|
- '@security.token_storage'
|
||||||
- '@Chill\ActivityBundle\Repository\ActivityACLAwareRepository'
|
|
||||||
public: true
|
public: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.timeline, context: 'person' }
|
- { name: chill.timeline, context: 'person' }
|
||||||
- { name: chill.timeline, context: 'center' }
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
services:
|
services:
|
||||||
chill_activity.repository.activity_type:
|
chill_activity.repository.activity_type:
|
||||||
class: Doctrine\ORM\EntityRepository
|
class: Doctrine\ORM\EntityRepository
|
||||||
@@ -17,16 +16,3 @@ services:
|
|||||||
factory: ['@doctrine.orm.entity_manager', getRepository]
|
factory: ['@doctrine.orm.entity_manager', getRepository]
|
||||||
arguments:
|
arguments:
|
||||||
- 'Chill\ActivityBundle\Entity\ActivityReasonCategory'
|
- 'Chill\ActivityBundle\Entity\ActivityReasonCategory'
|
||||||
|
|
||||||
Chill\ActivityBundle\Repository\ActivityRepository:
|
|
||||||
tags: [doctrine.repository_service]
|
|
||||||
arguments:
|
|
||||||
- '@Doctrine\Persistence\ManagerRegistry'
|
|
||||||
|
|
||||||
Chill\ActivityBundle\Repository\ActivityACLAwareRepository:
|
|
||||||
arguments:
|
|
||||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
|
||||||
$repository: '@Chill\ActivityBundle\Repository\ActivityRepository'
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
|
|
||||||
|
@@ -22,12 +22,13 @@ class ChoiceWithOtherType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
|
||||||
//add an 'other' entry in choices array
|
//add an 'other' entry in choices array
|
||||||
$options['choices'][$this->otherValueLabel] = '_other';
|
$options['choices'][$this->otherValueLabel] = '_other';
|
||||||
//ChoiceWithOther must always be expanded
|
//ChoiceWithOther must always be expanded
|
||||||
$options['expanded'] = true;
|
$options['expanded'] = true;
|
||||||
// adding a default value for choice
|
// adding a default value for choice
|
||||||
$options['empty_data'] = $options['multiple'] ? [] : null;
|
$options['empty_data'] = null;
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('_other', TextType::class, array('required' => false))
|
->add('_other', TextType::class, array('required' => false))
|
||||||
|
@@ -23,7 +23,6 @@ namespace Chill\EventBundle\Timeline;
|
|||||||
use Chill\EventBundle\Entity\Event;
|
use Chill\EventBundle\Entity\Event;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
@@ -89,14 +88,13 @@ class TimelineEventProvider implements TimelineProviderInterface
|
|||||||
$metadataParticipation = $this->em->getClassMetadata('ChillEventBundle:Participation');
|
$metadataParticipation = $this->em->getClassMetadata('ChillEventBundle:Participation');
|
||||||
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||||
|
|
||||||
$query = TimelineSingleQuery::fromArray([
|
$query = array(
|
||||||
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
|
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
|
||||||
'type' => 'event',
|
'type' => 'event',
|
||||||
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
|
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
|
||||||
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
|
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
|
||||||
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']),
|
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person'])
|
||||||
'parameters' => []
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 Champs-Libres Coopérative <info@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\MainBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Chill\MainBundle\Timeline\TimelineBuilder;
|
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
|
||||||
|
|
||||||
class TimelineCenterController extends AbstractController
|
|
||||||
{
|
|
||||||
|
|
||||||
protected TimelineBuilder $timelineBuilder;
|
|
||||||
|
|
||||||
protected PaginatorFactory $paginatorFactory;
|
|
||||||
|
|
||||||
private Security $security;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
TimelineBuilder $timelineBuilder,
|
|
||||||
PaginatorFactory $paginatorFactory,
|
|
||||||
Security $security
|
|
||||||
) {
|
|
||||||
$this->timelineBuilder = $timelineBuilder;
|
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
|
||||||
$this->security = $security;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{_locale}/center/timeline",
|
|
||||||
* name="chill_center_timeline",
|
|
||||||
* methods={"GET"}
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function centerAction(Request $request)
|
|
||||||
{
|
|
||||||
// collect reachable center for each group
|
|
||||||
$user = $this->security->getUser();
|
|
||||||
$centers = [];
|
|
||||||
foreach ($user->getGroupCenters() as $group) {
|
|
||||||
$centers[] = $group->getCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 === count($centers)) {
|
|
||||||
throw $this->createNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$nbItems = $this->timelineBuilder->countItems('center',
|
|
||||||
[ 'centers' => $centers ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$paginator = $this->paginatorFactory->create($nbItems);
|
|
||||||
|
|
||||||
return $this->render('@ChillMain/Timeline/index.html.twig', array
|
|
||||||
(
|
|
||||||
'timeline' => $this->timelineBuilder->getTimelineHTML(
|
|
||||||
'center',
|
|
||||||
[ 'centers' => $centers ],
|
|
||||||
$paginator->getCurrentPage()->getFirstItemNumber(),
|
|
||||||
$paginator->getItemsPerPage()
|
|
||||||
),
|
|
||||||
'nb_items' => $nbItems,
|
|
||||||
'paginator' => $paginator
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -131,7 +131,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
$loader->load('services/timeline.yaml');
|
$loader->load('services/timeline.yaml');
|
||||||
$loader->load('services/search.yaml');
|
$loader->load('services/search.yaml');
|
||||||
$loader->load('services/serializer.yaml');
|
|
||||||
|
|
||||||
$this->configureCruds($container, $config['cruds'], $loader);
|
$this->configureCruds($container, $config['cruds'], $loader);
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Chill\MainBundle\Form\Type\Select2ChoiceType;
|
use Chill\MainBundle\Form\Type\Select2ChoiceType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends choice to allow adding select2 library on widget
|
* Extends choice to allow adding select2 library on widget
|
||||||
@@ -42,26 +41,15 @@ class Select2CountryType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $translatableStringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ObjectManager
|
* @var ObjectManager
|
||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
||||||
RequestStack $requestStack,
|
|
||||||
ObjectManager $em,
|
|
||||||
TranslatableStringHelper $translatableStringHelper
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
@@ -87,7 +75,7 @@ class Select2CountryType extends AbstractType
|
|||||||
$choices = array();
|
$choices = array();
|
||||||
|
|
||||||
foreach ($countries as $c) {
|
foreach ($countries as $c) {
|
||||||
$choices[$c->getId()] = $this->translatableStringHelper->localize($c->getName());
|
$choices[$c->getId()] = $c->getName()[$locale];
|
||||||
}
|
}
|
||||||
|
|
||||||
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||||
|
@@ -27,7 +27,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Chill\MainBundle\Form\Type\Select2ChoiceType;
|
use Chill\MainBundle\Form\Type\Select2ChoiceType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends choice to allow adding select2 library on widget for languages (multiple)
|
* Extends choice to allow adding select2 library on widget for languages (multiple)
|
||||||
@@ -44,21 +43,10 @@ class Select2LanguageType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
|
|
||||||
/**
|
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
||||||
*
|
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $translatableStringHelper;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
RequestStack $requestStack,
|
|
||||||
ObjectManager $em,
|
|
||||||
TranslatableStringHelper $translatableStringHelper
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
@@ -84,7 +72,7 @@ class Select2LanguageType extends AbstractType
|
|||||||
$choices = array();
|
$choices = array();
|
||||||
|
|
||||||
foreach ($languages as $l) {
|
foreach ($languages as $l) {
|
||||||
$choices[$l->getId()] = $this->translatableStringHelper->localize($l->getName());
|
$choices[$l->getId()] = $l->getName()[$locale];
|
||||||
}
|
}
|
||||||
|
|
||||||
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||||
|
@@ -104,7 +104,7 @@ class Mailer
|
|||||||
* @param \User $to
|
* @param \User $to
|
||||||
* @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ]
|
* @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ]
|
||||||
* @param array $bodies The bodies. An array where keys are the contentType and values the bodies
|
* @param array $bodies The bodies. An array where keys are the contentType and values the bodies
|
||||||
* @param callable $callback a callback to customize the message (add attachment, etc.)
|
* @param \callable $callback a callback to customize the message (add attachment, etc.)
|
||||||
*/
|
*/
|
||||||
public function sendNotification(
|
public function sendNotification(
|
||||||
$recipient,
|
$recipient,
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
<div class="timeline">
|
|
||||||
{% for result in results %}
|
|
||||||
<div class="timeline-item {% if loop.index0 is even %}even{% else %}odd{% endif %}">
|
|
||||||
{% include result.template with result.template_data %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
@@ -1,15 +1,7 @@
|
|||||||
{% extends "@ChillMain/layout.html.twig" %}
|
<div class="timeline">
|
||||||
|
{% for result in results %}
|
||||||
{% block content %}
|
<div class="timeline-item {% if loop.index0 is even %}even{% else %}odd{% endif %}">
|
||||||
<div id="container content">
|
{% include result.template with result.template_data %}
|
||||||
<div class="grid-8 centered">
|
|
||||||
<h1>{{ 'Global timeline'|trans }}</h1>
|
|
||||||
|
|
||||||
{{ timeline|raw }}
|
|
||||||
|
|
||||||
{% if nb_items > paginator.getItemsPerPage %}
|
|
||||||
{{ chill_pagination(paginator) }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endfor %}
|
||||||
{% endblock content %}
|
</div>
|
||||||
|
@@ -69,14 +69,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'order' => 0
|
'order' => 0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Global timeline'), [
|
|
||||||
'route' => 'chill_center_timeline',
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 10
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
||||||
$menu->addChild($this->translator->trans('Export Menu'), [
|
$menu->addChild($this->translator->trans('Export Menu'), [
|
||||||
'route' => 'chill_main_export_index'
|
'route' => 'chill_main_export_index'
|
||||||
|
@@ -204,7 +204,7 @@ class SearchProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getResultByName($pattern, $name, $start = 0, $limit = 50,
|
public function getResultByName($pattern, $name, $start = 0, $limit = 50,
|
||||||
array $options = array(), $format = 'html')
|
array $options = array(), $format)
|
||||||
{
|
{
|
||||||
$terms = $this->parse($pattern);
|
$terms = $this->parse($pattern);
|
||||||
$search = $this->getByName($name);
|
$search = $this->getByName($name);
|
||||||
|
@@ -110,6 +110,8 @@ class AuthorizationHelper
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$role = ($attribute instanceof Role) ? $attribute : new Role($attribute);
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
//filter on center
|
//filter on center
|
||||||
if ($groupCenter->getCenter()->getId() === $entity->getCenter()->getId()) {
|
if ($groupCenter->getCenter()->getId() === $entity->getCenter()->getId()) {
|
||||||
@@ -117,7 +119,8 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role allow to reach the required role
|
//check that the role allow to reach the required role
|
||||||
if ($this->isRoleReached($attribute, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))){
|
||||||
//if yes, we have a right on something...
|
//if yes, we have a right on something...
|
||||||
// perform check on scope if necessary
|
// perform check on scope if necessary
|
||||||
if ($entity instanceof HasScopeInterface) {
|
if ($entity instanceof HasScopeInterface) {
|
||||||
@@ -146,15 +149,12 @@ class AuthorizationHelper
|
|||||||
* and optionnaly Scope
|
* and optionnaly Scope
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string|Role $role
|
* @param Role $role
|
||||||
* @param null|Scope $scope
|
* @param null|Scope $scope
|
||||||
* @return Center[]
|
* @return Center[]
|
||||||
*/
|
*/
|
||||||
public function getReachableCenters(User $user, $role, Scope $scope = null)
|
public function getReachableCenters(User $user, Role $role, Scope $scope = null)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
$centers = array();
|
$centers = array();
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
@@ -162,7 +162,8 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role is in the reachable roles
|
//check that the role is in the reachable roles
|
||||||
if ($this->isRoleReached($role, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))) {
|
||||||
if ($scope === null) {
|
if ($scope === null) {
|
||||||
$centers[] = $groupCenter->getCenter();
|
$centers[] = $groupCenter->getCenter();
|
||||||
break 1;
|
break 1;
|
||||||
@@ -180,30 +181,6 @@ class AuthorizationHelper
|
|||||||
return $centers;
|
return $centers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter an array of centers, return only center which are reachable
|
|
||||||
*
|
|
||||||
* @param User $user The user
|
|
||||||
* @param array $centers a list of centers which are going to be filtered
|
|
||||||
* @param string|Center $role
|
|
||||||
*/
|
|
||||||
public function filterReachableCenters(User $user, array $centers, $role): array
|
|
||||||
{
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($centers as $center) {
|
|
||||||
if ($this->userCanReachCenter($user, $center, $role)) {
|
|
||||||
$results[] = $center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all reachable scope for a given user, center and role
|
* Return all reachable scope for a given user, center and role
|
||||||
*
|
*
|
||||||
@@ -214,12 +191,8 @@ class AuthorizationHelper
|
|||||||
* @param Center $center
|
* @param Center $center
|
||||||
* @return Scope[]
|
* @return Scope[]
|
||||||
*/
|
*/
|
||||||
public function getReachableScopes(User $user, $role, Center $center)
|
public function getReachableScopes(User $user, Role $role, Center $center)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->getReachableCircles($user, $role, $center);
|
return $this->getReachableCircles($user, $role, $center);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,15 +200,12 @@ class AuthorizationHelper
|
|||||||
* Return all reachable circle for a given user, center and role
|
* Return all reachable circle for a given user, center and role
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string|Role $role
|
* @param Role $role
|
||||||
* @param Center $center
|
* @param Center $center
|
||||||
* @return Scope[]
|
* @return Scope[]
|
||||||
*/
|
*/
|
||||||
public function getReachableCircles(User $user, $role, Center $center)
|
public function getReachableCircles(User $user, Role $role, Center $center)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
$scopes = array();
|
$scopes = array();
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
@@ -245,7 +215,9 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role is in the reachable roles
|
//check that the role is in the reachable roles
|
||||||
if ($this->isRoleReached($role, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))) {
|
||||||
|
|
||||||
$scopes[] = $roleScope->getScope();
|
$scopes[] = $roleScope->getScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,10 +269,10 @@ class AuthorizationHelper
|
|||||||
* @param Role $parentRole The role which should give access to $childRole
|
* @param Role $parentRole The role which should give access to $childRole
|
||||||
* @return boolean true if the child role is granted by parent role
|
* @return boolean true if the child role is granted by parent role
|
||||||
*/
|
*/
|
||||||
protected function isRoleReached($childRole, $parentRole)
|
protected function isRoleReached(Role $childRole, Role $parentRole)
|
||||||
{
|
{
|
||||||
$reachableRoles = $this->roleHierarchy
|
$reachableRoles = $this->roleHierarchy
|
||||||
->getReachableRoleNames([$parentRole]);
|
->getReachableRoles([$parentRole]);
|
||||||
|
|
||||||
return in_array($childRole, $reachableRoles);
|
return in_array($childRole, $reachableRoles);
|
||||||
}
|
}
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, <http://www.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\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class CenterNormalizer implements NormalizerInterface
|
|
||||||
{
|
|
||||||
public function normalize($center, string $format = null, array $context = array())
|
|
||||||
{
|
|
||||||
/** @var Center $center */
|
|
||||||
return [
|
|
||||||
'id' => $center->getId(),
|
|
||||||
'name' => $center->getName()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, string $format = null): bool
|
|
||||||
{
|
|
||||||
return $data instanceof Center;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, <http://www.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\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
class DateNormalizer implements NormalizerInterface
|
|
||||||
{
|
|
||||||
public function normalize($date, string $format = null, array $context = array())
|
|
||||||
{
|
|
||||||
/** @var \DateTimeInterface $date */
|
|
||||||
return [
|
|
||||||
'datetime' => $date->format(\DateTimeInterface::ISO8601),
|
|
||||||
'u' => $date->getTimestamp()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, string $format = null): bool
|
|
||||||
{
|
|
||||||
return $data instanceof \DateTimeInterface;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, <http://www.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\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class UserNormalizer implements NormalizerInterface
|
|
||||||
{
|
|
||||||
public function normalize($user, string $format = null, array $context = array())
|
|
||||||
{
|
|
||||||
/** @var User $user */
|
|
||||||
return [
|
|
||||||
'id' => $user->getId(),
|
|
||||||
'username' => $user->getUsername()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, string $format = null): bool
|
|
||||||
{
|
|
||||||
return $data instanceof User;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -34,7 +34,7 @@ trait PrepareClientTrait
|
|||||||
* @return \Symfony\Component\BrowserKit\Client
|
* @return \Symfony\Component\BrowserKit\Client
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function getClientAuthenticated(
|
public function getClient(
|
||||||
$username = 'center a_social',
|
$username = 'center a_social',
|
||||||
$password = 'password'
|
$password = 'password'
|
||||||
) {
|
) {
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class DefaultControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
public function testIndex()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,15 @@ class LoginControllerTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
public function testLogin()
|
public function testLogin()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = static::createClient(array(
|
||||||
|
'framework' => array(
|
||||||
|
'default_locale' => 'en',
|
||||||
|
'translator' => array(
|
||||||
|
'fallback' => 'en'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
));
|
||||||
|
|
||||||
//load login page and submit form
|
//load login page and submit form
|
||||||
$crawler = $client->request('GET', '/login');
|
$crawler = $client->request('GET', '/login');
|
||||||
@@ -37,14 +45,14 @@ class LoginControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$this->assertRegExp('/center a_social/', $client->getResponse()
|
$this->assertRegExp('/center a_social/', $client->getResponse()
|
||||||
->getContent());
|
->getContent());
|
||||||
$logoutLinkFilter = $crawler->filter('a:contains("Se déconnecter")');
|
$logoutLinkFilter = $crawler->filter('a:contains("Logout")');
|
||||||
|
|
||||||
//check there is > 0 logout link
|
//check there is > 0 logout link
|
||||||
$this->assertGreaterThan(0, $logoutLinkFilter->count(), 'check that a logout link is present');
|
$this->assertGreaterThan(0, $logoutLinkFilter->count(), 'check that a logout link is present');
|
||||||
|
|
||||||
//click on logout link
|
//click on logout link
|
||||||
$client->followRedirects(false);
|
$client->followRedirects(false);
|
||||||
$client->click($crawler->selectLink('Se déconnecter')->link());
|
$client->click($crawler->selectLink('Logout')->link());
|
||||||
|
|
||||||
$this->assertTrue($client->getResponse()->isRedirect());
|
$this->assertTrue($client->getResponse()->isRedirect());
|
||||||
$client->followRedirect(); #redirect to login page
|
$client->followRedirect(); #redirect to login page
|
||||||
|
@@ -32,6 +32,20 @@ use Chill\MainBundle\Search\SearchInterface;
|
|||||||
*/
|
*/
|
||||||
class SearchControllerTest extends WebTestCase
|
class SearchControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
static::bootKernel();
|
||||||
|
|
||||||
|
//add a default service
|
||||||
|
$this->addSearchService(
|
||||||
|
$this->createDefaultSearchService('<p>I am default</p>', 10), 'default'
|
||||||
|
);
|
||||||
|
//add a domain service
|
||||||
|
$this->addSearchService(
|
||||||
|
$this->createDefaultSearchService('<p>I am domain bar</p>', 20), 'bar'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the behaviour when no domain is provided in the search pattern :
|
* Test the behaviour when no domain is provided in the search pattern :
|
||||||
@@ -91,6 +105,29 @@ class SearchControllerTest extends WebTestCase
|
|||||||
$this->assertTrue($client->getResponse()->isNotFound());
|
$this->assertTrue($client->getResponse()->isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testSearchWithinSpecificSearchName()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
//add a search service which will be supported
|
||||||
|
$this->addSearchService(
|
||||||
|
$this->createNonDefaultDomainSearchService("<p>I am domain foo</p>", 100, TRUE), 'foo'
|
||||||
|
);
|
||||||
|
|
||||||
|
$client = $this->getAuthenticatedClient();
|
||||||
|
$crawler = $client->request('GET', '/fr/search',
|
||||||
|
array('q' => '@foo default search', 'name' => 'foo'));
|
||||||
|
|
||||||
|
//$this->markTestSkipped();
|
||||||
|
$this->assertEquals(0, $crawler->filter('p:contains("I am default")')->count(),
|
||||||
|
"The mocked default results are not shown");
|
||||||
|
$this->assertEquals(0, $crawler->filter('p:contains("I am domain bar")')->count(),
|
||||||
|
"The mocked non-default results are not shown");
|
||||||
|
$this->assertEquals(1, $crawler->filter('p:contains("I am domain foo")')->count(),
|
||||||
|
"The mocked nnon default results for foo are shown");
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
private function getAuthenticatedClient()
|
private function getAuthenticatedClient()
|
||||||
{
|
{
|
||||||
return static::createClient(array(), array(
|
return static::createClient(array(), array(
|
||||||
|
@@ -37,12 +37,11 @@ class UserControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$username = 'Test_user'. uniqid();
|
$username = 'Test_user'. uniqid();
|
||||||
$password = 'Password1234!';
|
$password = 'Password1234!';
|
||||||
dump($crawler->text());
|
|
||||||
// Fill in the form and submit it
|
// Fill in the form and submit it
|
||||||
$form = $crawler->selectButton('Créer')->form(array(
|
$form = $crawler->selectButton('Créer')->form(array(
|
||||||
'chill_mainbundle_user[username]' => $username,
|
'chill_mainbundle_user[username]' => $username,
|
||||||
'chill_mainbundle_user[plainPassword][first]' => $password,
|
'chill_mainbundle_user[plainPassword][password][first]' => $password,
|
||||||
'chill_mainbundle_user[plainPassword][second]' => $password
|
'chill_mainbundle_user[plainPassword][password][second]' => $password
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->client->submit($form);
|
$this->client->submit($form);
|
||||||
@@ -120,8 +119,8 @@ class UserControllerTest extends WebTestCase
|
|||||||
$crawler = $this->client->click($link);
|
$crawler = $this->client->click($link);
|
||||||
|
|
||||||
$form = $crawler->selectButton('Changer le mot de passe')->form(array(
|
$form = $crawler->selectButton('Changer le mot de passe')->form(array(
|
||||||
'chill_mainbundle_user_password[new_password][first]' => $newPassword,
|
'chill_mainbundle_user_password[password][first]' => $newPassword,
|
||||||
'chill_mainbundle_user_password[new_password][second]' => $newPassword,
|
'chill_mainbundle_user_password[password][second]' => $newPassword,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->client->submit($form);
|
$this->client->submit($form);
|
||||||
|
@@ -0,0 +1,179 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
* Copyright (C) 2015 Champs-Libres Coopérative <info@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\MainBundle\Tests\DependencyInjection;
|
||||||
|
|
||||||
|
use Chill\MainBundle\DependencyInjection\ConfigConsistencyCompilerPass;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of ConfigConsistencyCompilerPassTest
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
|
class ConfigConsistencyCompilerPassTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var \Chill\MainBundle\DependencyInjection\ConfigConsistencyCompilerPass
|
||||||
|
*/
|
||||||
|
private $configConsistencyCompilerPass;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->configConsistencyCompilerPass = new ConfigConsistencyCompilerPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that everything is fine is configuration is correct
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testLanguagesArePresent()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this ->configConsistencyCompilerPass
|
||||||
|
->process(
|
||||||
|
$this->mockContainer(
|
||||||
|
$this->mockTranslatorDefinition(array('fr')),
|
||||||
|
array('fr', 'nl')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertTrue(TRUE, 'the config consistency can process');
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$this->assertTrue(FALSE,
|
||||||
|
'the config consistency can process');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that everything is fine is configuration is correct
|
||||||
|
* if multiple fallback languages are present
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMultiplesLanguagesArePresent()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this ->configConsistencyCompilerPass
|
||||||
|
->process(
|
||||||
|
$this->mockContainer(
|
||||||
|
$this->mockTranslatorDefinition(array('fr', 'nl')),
|
||||||
|
array('fr', 'nl', 'en')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertTrue(TRUE, 'the config consistency can process');
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$this->assertTrue(FALSE,
|
||||||
|
'the config consistency can process');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that a runtime exception is throw if the available language does
|
||||||
|
* not contains the fallback locale
|
||||||
|
*
|
||||||
|
* @expectedException \RuntimeException
|
||||||
|
* @expectedExceptionMessageRegExp /The chill_main.available_languages parameter does not contains fallback locales./
|
||||||
|
*/
|
||||||
|
public function testLanguageNotPresent()
|
||||||
|
{
|
||||||
|
$container = $this->mockContainer(
|
||||||
|
$this->mockTranslatorDefinition(array('en')), array('fr')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->configConsistencyCompilerPass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that a logic exception is thrown if the setFallbackLocale
|
||||||
|
* method is not defined in translator definition
|
||||||
|
*
|
||||||
|
* @expectedException \LogicException
|
||||||
|
*/
|
||||||
|
public function testSetFallbackNotDefined()
|
||||||
|
{
|
||||||
|
$container = $this->mockContainer(
|
||||||
|
$this->mockTranslatorDefinition(NULL), array('fr')
|
||||||
|
);
|
||||||
|
$this->configConsistencyCompilerPass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ContainerBuilder
|
||||||
|
*/
|
||||||
|
private function mockContainer($definition, $availableLanguages)
|
||||||
|
{
|
||||||
|
$container = $this
|
||||||
|
->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$container->method('getParameter')
|
||||||
|
->will($this->returnCallback(
|
||||||
|
function($parameter) use ($availableLanguages) {
|
||||||
|
if ($parameter === 'chill_main.available_languages') {
|
||||||
|
return $availableLanguages;
|
||||||
|
} else {
|
||||||
|
throw new \LogicException("the parameter '$parameter' "
|
||||||
|
. "is not defined in stub test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
$container->method('findDefinition')
|
||||||
|
->will($this->returnCallback(
|
||||||
|
function($id) use ($definition) {
|
||||||
|
if (in_array($id, array('translator', 'translator.default'))) {
|
||||||
|
return $definition;
|
||||||
|
} else {
|
||||||
|
throw new \LogicException("the id $id is not defined in test");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
return $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $languages
|
||||||
|
* @return 'Symfony\Component\DependencyInjection\Definition'
|
||||||
|
*/
|
||||||
|
private function mockTranslatorDefinition(array $languages = NULL)
|
||||||
|
{
|
||||||
|
$definition = $this
|
||||||
|
->getMockBuilder('Symfony\Component\DependencyInjection\Definition')
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
if (NULL !== $languages) {
|
||||||
|
$definition->method('getMethodCalls')
|
||||||
|
->willReturn(array(
|
||||||
|
['setFallbackLocales', array($languages)]
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$definition->method('getMethodCalls')
|
||||||
|
->willReturn(array(['nothing', array()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $definition;
|
||||||
|
}
|
||||||
|
}
|
@@ -45,6 +45,11 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
use \Chill\MainBundle\Test\PrepareUserTrait;
|
use \Chill\MainBundle\Test\PrepareUserTrait;
|
||||||
use \Chill\MainBundle\Test\PrepareScopeTrait;
|
use \Chill\MainBundle\Test\PrepareScopeTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
|
*/
|
||||||
|
private $container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -60,6 +65,8 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
|
||||||
|
$this->container = self::$kernel->getContainer();
|
||||||
|
|
||||||
$this->prophet = new \Prophecy\Prophet;
|
$this->prophet = new \Prophecy\Prophet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +97,7 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
\Symfony\Component\Security\Core\User\UserInterface $user = null
|
\Symfony\Component\Security\Core\User\UserInterface $user = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$localUser = $user === NULL ? self::$container->get('doctrine.orm.entity_manager')
|
$localUser = $user === NULL ? $this->container->get('doctrine.orm.entity_manager')
|
||||||
->getRepository('ChillMainBundle:User')
|
->getRepository('ChillMainBundle:User')
|
||||||
->findOneBy(array('username' => 'center a_social')) :
|
->findOneBy(array('username' => 'center a_social')) :
|
||||||
$user;
|
$user;
|
||||||
@@ -99,10 +106,10 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
$tokenStorage->setToken($token);
|
$tokenStorage->setToken($token);
|
||||||
|
|
||||||
return new ExportManager(
|
return new ExportManager(
|
||||||
$logger === NULL ? self::$container->get('logger') : $logger,
|
$logger === NULL ? $this->container->get('logger') : $logger,
|
||||||
$em === NULL ? self::$container->get('doctrine.orm.entity_manager') : $em,
|
$em === NULL ? $this->container->get('doctrine.orm.entity_manager') : $em,
|
||||||
$authorizationChecker === NULL ? self::$container->get('security.authorization_checker') : $authorizationChecker,
|
$authorizationChecker === NULL ? $this->container->get('security.authorization_checker') : $authorizationChecker,
|
||||||
$authorizationHelper === NULL ? self::$container->get('chill.main.security.authorization.helper') : $authorizationHelper,
|
$authorizationHelper === NULL ? $this->container->get('chill.main.security.authorization.helper') : $authorizationHelper,
|
||||||
$tokenStorage)
|
$tokenStorage)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -537,7 +544,7 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
|
|
||||||
$export = $this->prophet->prophesize();
|
$export = $this->prophet->prophesize();
|
||||||
$export->willImplement(ExportInterface::class);
|
$export->willImplement(ExportInterface::class);
|
||||||
$em = self::$container->get('doctrine.orm.entity_manager');
|
$em = $this->container->get('doctrine.orm.entity_manager');
|
||||||
$export->initiateQuery(
|
$export->initiateQuery(
|
||||||
Argument::is(array('foo')),
|
Argument::is(array('foo')),
|
||||||
Argument::Type('array'),
|
Argument::Type('array'),
|
||||||
@@ -620,13 +627,12 @@ class ExportManagerTest extends KernelTestCase
|
|||||||
|
|
||||||
//add formatter interface
|
//add formatter interface
|
||||||
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
|
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
|
||||||
self::$container->get('translator'), $exportManager);
|
$this->container->get('translator'), $exportManager);
|
||||||
$exportManager->addFormatter($formatter, 'spreadsheet');
|
$exportManager->addFormatter($formatter, 'spreadsheet');
|
||||||
|
|
||||||
//ob_start();
|
//ob_start();
|
||||||
$response = $exportManager->generate(
|
$response = $exportManager->generate('dummy',
|
||||||
'dummy',
|
array(PickCenterType::CENTERS_IDENTIFIERS => array($center)),
|
||||||
array($center),
|
|
||||||
array(
|
array(
|
||||||
ExportType::FILTER_KEY => array(
|
ExportType::FILTER_KEY => array(
|
||||||
'filter_foo' => array(
|
'filter_foo' => array(
|
||||||
|
@@ -54,20 +54,13 @@ class PageTest extends KernelTestCase
|
|||||||
$number = 1,
|
$number = 1,
|
||||||
$itemPerPage = 10,
|
$itemPerPage = 10,
|
||||||
$route = 'route',
|
$route = 'route',
|
||||||
array $routeParameters = array(),
|
array $routeParameters = array()
|
||||||
$totalItems = 100
|
|
||||||
) {
|
) {
|
||||||
$urlGenerator = $this->prophet->prophesize();
|
$urlGenerator = $this->prophet->prophesize();
|
||||||
$urlGenerator->willImplement(UrlGeneratorInterface::class);
|
$urlGenerator->willImplement(UrlGeneratorInterface::class);
|
||||||
|
|
||||||
return new Page(
|
return new Page($number, $itemPerPage, $urlGenerator->reveal(), $route,
|
||||||
$number,
|
$routeParameters);
|
||||||
$itemPerPage,
|
|
||||||
$urlGenerator->reveal(),
|
|
||||||
$route,
|
|
||||||
$routeParameters,
|
|
||||||
$totalItems
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPageNumber() {
|
public function testPageNumber() {
|
||||||
|
@@ -21,10 +21,9 @@ namespace Chill\MainBundle\Test\Search;
|
|||||||
|
|
||||||
use Chill\MainBundle\Search\SearchProvider;
|
use Chill\MainBundle\Search\SearchProvider;
|
||||||
use Chill\MainBundle\Search\SearchInterface;
|
use Chill\MainBundle\Search\SearchInterface;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
|
|
||||||
class SearchProviderTest extends TestCase
|
class SearchProviderTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -50,7 +50,7 @@ class AuthorizationHelperTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
private function getAuthorizationHelper()
|
private function getAuthorizationHelper()
|
||||||
{
|
{
|
||||||
return static::$container
|
return static::$kernel->getContainer()
|
||||||
->get('chill.main.security.authorization.helper')
|
->get('chill.main.security.authorization.helper')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,8 @@ class TokenManagerTest extends KernelTestCase
|
|||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
|
||||||
$logger = self::$container
|
$logger = self::$kernel
|
||||||
|
->getContainer()
|
||||||
->get('logger');
|
->get('logger');
|
||||||
|
|
||||||
$this->tokenManager = new TokenManager('secret', $logger);
|
$this->tokenManager = new TokenManager('secret', $logger);
|
||||||
|
@@ -36,19 +36,53 @@ class ChillMenuTwigFunctionTest extends KernelTestCase
|
|||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
self::bootKernel(array('environment' => 'test'));
|
self::bootKernel(array('environment' => 'test'));
|
||||||
static::$templating = static::$container
|
static::$templating = static::$kernel
|
||||||
->get('templating');
|
->getContainer()->get('templating');
|
||||||
$pathToBundle = static::$container->getParameter('kernel.bundles_metadata')['ChillMainBundle']['path'];
|
|
||||||
//load templates in Tests/Resources/views
|
//load templates in Tests/Resources/views
|
||||||
static::$container->get('twig.loader')
|
static::$kernel->getContainer()->get('twig.loader')
|
||||||
->addPath($pathToBundle.'/Resources/test/views/', $namespace = 'tests');
|
->addPath(static::$kernel->getContainer()->getParameter('kernel.root_dir')
|
||||||
|
.'/Resources/views/', $namespace = 'tests');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNormalMenu()
|
public function testNormalMenu()
|
||||||
{
|
{
|
||||||
$content = static::$templating->render('@tests/menus/normalMenu.html.twig');
|
$content = static::$templating->render('@tests/menus/normalMenu.html.twig');
|
||||||
$this->assertContains('ul', $content,
|
$crawler = new Crawler($content);
|
||||||
"test that the file contains an ul tag"
|
|
||||||
);
|
$ul = $crawler->filter('ul')->getNode(0);
|
||||||
|
$this->assertEquals( 'ul', $ul->tagName);
|
||||||
|
|
||||||
|
$lis = $crawler->filter('ul')->children();
|
||||||
|
$this->assertEquals(3, count($lis));
|
||||||
|
|
||||||
|
$lis->each(function(Crawler $node, $i) {
|
||||||
|
$this->assertEquals('li', $node->getNode(0)->tagName);
|
||||||
|
|
||||||
|
$a = $node->children()->getNode(0);
|
||||||
|
$this->assertEquals('a', $a->tagName);
|
||||||
|
switch($i) {
|
||||||
|
case 0:
|
||||||
|
$this->assertEquals('/dummy?param=fake', $a->getAttribute('href'));
|
||||||
|
$this->assertEquals('active', $a->getAttribute('class'));
|
||||||
|
$this->assertEquals('test0', $a->nodeValue);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$this->assertEquals('/dummy1?param=fake', $a->getAttribute('href'));
|
||||||
|
$this->assertEmpty($a->getAttribute('class'));
|
||||||
|
$this->assertEquals('test1', $a->nodeValue);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$this->assertEquals('/dummy2/fake', $a->getAttribute('href'));
|
||||||
|
$this->assertEmpty($a->getAttribute('class'));
|
||||||
|
$this->assertEquals('test2', $a->nodeValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMenuOverrideTemplate()
|
||||||
|
{
|
||||||
|
$this->markTestSkipped("this hacks seems not working now");
|
||||||
|
$content = static::$templating->render('@tests/menus/overrideTemplate.html.twig');
|
||||||
|
$this->assertEquals('fake template', $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class MenuComposerTest extends KernelTestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
self::bootKernel(array('environment' => 'test'));
|
self::bootKernel(array('environment' => 'test'));
|
||||||
$this->menuComposer = static::$container
|
$this->menuComposer = static::$kernel->getContainer()
|
||||||
->get('chill.main.menu_composer');
|
->get('chill.main.menu_composer');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,5 +42,50 @@ class MenuComposerTest extends KernelTestCase
|
|||||||
$routes = $this->menuComposer->getRoutesFor('dummy0');
|
$routes = $this->menuComposer->getRoutesFor('dummy0');
|
||||||
|
|
||||||
$this->assertInternalType('array', $routes);
|
$this->assertInternalType('array', $routes);
|
||||||
|
$this->assertCount(3, $routes);
|
||||||
|
//check that the keys are sorted
|
||||||
|
$orders = array_keys($routes);
|
||||||
|
foreach ($orders as $key => $order){
|
||||||
|
if (array_key_exists($key + 1, $orders)) {
|
||||||
|
$this->assertGreaterThan($order, $orders[$key + 1],
|
||||||
|
'Failing to assert that routes are ordered');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check that the array are identical, order is not important :
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
50 => array(
|
||||||
|
'key' => 'chill_main_dummy_0',
|
||||||
|
'label' => 'test0',
|
||||||
|
'otherkey' => 'othervalue'
|
||||||
|
),
|
||||||
|
51 => array(
|
||||||
|
'key' => 'chill_main_dummy_1',
|
||||||
|
'label' => 'test1',
|
||||||
|
'helper'=> 'great helper'
|
||||||
|
),
|
||||||
|
52 => array(
|
||||||
|
'key' => 'chill_main_dummy_2',
|
||||||
|
'label' => 'test2'
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($expected as $order => $route ){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//compare arrays
|
||||||
|
foreach($expected as $order => $route) {
|
||||||
|
//check the key are the one expected
|
||||||
|
$this->assertTrue(isset($routes[$order]));
|
||||||
|
|
||||||
|
if (isset($routes[$order])){ #avoid an exception if routes with order does not exists
|
||||||
|
//sort arrays. Order matters for phpunit::assertSame
|
||||||
|
ksort($route);
|
||||||
|
ksort($routes[$order]);
|
||||||
|
$this->assertSame($route, $routes[$order]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,11 +23,11 @@ use Doctrine\ORM\Query\ResultSetMapping;
|
|||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Doctrine\ORM\NativeQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build timeline
|
* Build timeline
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class TimelineBuilder implements ContainerAwareInterface
|
class TimelineBuilder implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
@@ -78,14 +78,14 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function getTimelineHTML($context, array $args, $firstItem = 0, $number = 20)
|
public function getTimelineHTML($context, array $args, $firstItem = 0, $number = 20)
|
||||||
{
|
{
|
||||||
list($union, $parameters) = $this->buildUnionQuery($context, $args);
|
$union = $this->buildUnionQuery($context, $args);
|
||||||
|
|
||||||
//add ORDER BY clause and LIMIT
|
//add ORDER BY clause and LIMIT
|
||||||
$query = $union . sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d',
|
$query = $union . sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d',
|
||||||
$number, $firstItem);
|
$number, $firstItem);
|
||||||
|
|
||||||
// run query and handle results
|
// run query and handle results
|
||||||
$fetched = $this->runUnionQuery($query, $parameters);
|
$fetched = $this->runUnionQuery($query);
|
||||||
$entitiesByKey = $this->getEntities($fetched, $context);
|
$entitiesByKey = $this->getEntities($fetched, $context);
|
||||||
|
|
||||||
return $this->render($fetched, $entitiesByKey, $context, $args);
|
return $this->render($fetched, $entitiesByKey, $context, $args);
|
||||||
@@ -100,18 +100,16 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function countItems($context, array $args)
|
public function countItems($context, array $args)
|
||||||
{
|
{
|
||||||
|
$union = $this->buildUnionQuery($context, $args);
|
||||||
|
|
||||||
|
// embed the union query inside a count query
|
||||||
|
$count = sprintf('SELECT COUNT(sq.id) AS total FROM (%s) as sq', $union);
|
||||||
|
|
||||||
$rsm = (new ResultSetMapping())
|
$rsm = (new ResultSetMapping())
|
||||||
->addScalarResult('total', 'total', Type::INTEGER);
|
->addScalarResult('total', 'total', Type::INTEGER);
|
||||||
|
|
||||||
list($select, $parameters) = $this->buildUnionQuery($context, $args);
|
return $this->em->createNativeQuery($count, $rsm)
|
||||||
|
->getSingleScalarResult();
|
||||||
// embed the union query inside a count query
|
|
||||||
$countQuery = sprintf('SELECT COUNT(sq.id) AS total FROM (%s) as sq', $select);
|
|
||||||
|
|
||||||
$nq = $this->em->createNativeQuery($countQuery, $rsm);
|
|
||||||
$nq->setParameters($parameters);
|
|
||||||
|
|
||||||
return $nq->getSingleScalarResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,59 +154,40 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*
|
*
|
||||||
* @uses self::buildSelectQuery to build individual SELECT queries
|
* @uses self::buildSelectQuery to build individual SELECT queries
|
||||||
*
|
*
|
||||||
|
* @param string $context
|
||||||
|
* @param mixed $args
|
||||||
|
* @param int $page
|
||||||
|
* @param int $number
|
||||||
|
* @return string
|
||||||
* @throws \LogicException if no builder have been defined for this context
|
* @throws \LogicException if no builder have been defined for this context
|
||||||
* @return array, where first element is the query, the second one an array with the parameters
|
|
||||||
*/
|
*/
|
||||||
private function buildUnionQuery(string $context, array $args): array
|
private function buildUnionQuery($context, array $args)
|
||||||
{
|
{
|
||||||
//append SELECT queries with UNION keyword between them
|
//append SELECT queries with UNION keyword between them
|
||||||
$union = '';
|
$union = '';
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
foreach($this->getProvidersByContext($context) as $provider) {
|
foreach($this->getProvidersByContext($context) as $provider) {
|
||||||
$data = $provider->fetchQuery($context, $args);
|
$select = $this->buildSelectQuery($provider, $context, $args);
|
||||||
list($select, $selectParameters) = $this->buildSelectQuery($data);
|
$append = ($union === '') ? $select : ' UNION '.$select;
|
||||||
$append = empty($union) ? $select : ' UNION '.$select;
|
|
||||||
$union .= $append;
|
$union .= $append;
|
||||||
$parameters = array_merge($parameters, $selectParameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$union, $parameters];
|
return $union;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hack to replace the arbitrary "AS" statement in DQL
|
|
||||||
* into proper SQL query
|
|
||||||
* TODO remove
|
|
||||||
private function replaceASInDQL(string $dql): string
|
|
||||||
{
|
|
||||||
$pattern = '/^(SELECT\s+[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s{0,},\s{0,}[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s{0,},\s{0,}[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s+FROM.*)/';
|
|
||||||
$replacements = '${1} AS id ${3} AS type ${5} AS date ${7}';
|
|
||||||
|
|
||||||
$s = \preg_replace($pattern, $replacements, $dql, 1);
|
|
||||||
|
|
||||||
if (NULL === $s) {
|
|
||||||
throw new \RuntimeException('Could not replace the "AS" statement produced by '.
|
|
||||||
'DQL with normal SQL AS: '.$dql);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the SQL SELECT query as a string,
|
* return the SQL SELECT query as a string,
|
||||||
*
|
*
|
||||||
* @return array: first parameter is the sql string, second an array with parameters
|
* @uses TimelineProfiderInterface::fetchQuery use the fetchQuery function
|
||||||
|
* @param \Chill\MainBundle\Timeline\TimelineProviderInterface $provider
|
||||||
|
* @param string $context
|
||||||
|
* @param mixed[] $args
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function buildSelectQuery($data): array
|
private function buildSelectQuery(TimelineProviderInterface $provider, $context, array $args)
|
||||||
{
|
{
|
||||||
return [$data->buildSql(), $data->getParameters()];
|
$data = $provider->fetchQuery($context, $args);
|
||||||
|
|
||||||
// dead code
|
return sprintf(
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$sql = sprintf(
|
|
||||||
'SELECT %s AS id, '
|
'SELECT %s AS id, '
|
||||||
. '%s AS "date", '
|
. '%s AS "date", '
|
||||||
. "'%s' AS type "
|
. "'%s' AS type "
|
||||||
@@ -218,19 +197,16 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
$data['date'],
|
$data['date'],
|
||||||
$data['type'],
|
$data['type'],
|
||||||
$data['FROM'],
|
$data['FROM'],
|
||||||
is_string($data['WHERE']) ? $data['WHERE'] : $data['WHERE'][0]
|
$data['WHERE']);
|
||||||
);
|
|
||||||
|
|
||||||
return [$sql, $data['WHERE'][1]];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run the UNION query and return result as an array
|
* run the UNION query and return result as an array
|
||||||
*
|
*
|
||||||
* @return array an array with the results
|
* @param string $query
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function runUnionQuery(string $query, array $parameters): array
|
private function runUnionQuery($query)
|
||||||
{
|
{
|
||||||
$resultSetMapping = (new ResultSetMapping())
|
$resultSetMapping = (new ResultSetMapping())
|
||||||
->addScalarResult('id', 'id')
|
->addScalarResult('id', 'id')
|
||||||
@@ -238,7 +214,6 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
->addScalarResult('date', 'date');
|
->addScalarResult('date', 'date');
|
||||||
|
|
||||||
return $this->em->createNativeQuery($query, $resultSetMapping)
|
return $this->em->createNativeQuery($query, $resultSetMapping)
|
||||||
->setParameters($parameters)
|
|
||||||
->getArrayResult();
|
->getArrayResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +274,7 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->container->get('templating')
|
return $this->container->get('templating')
|
||||||
->render('@ChillMain/Timeline/chain_timelines.html.twig', array(
|
->render('@ChillMain/Timeline/index.html.twig', array(
|
||||||
'results' => $timelineEntries
|
'results' => $timelineEntries
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@@ -1,155 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Timeline;
|
|
||||||
|
|
||||||
|
|
||||||
class TimelineSingleQuery
|
|
||||||
{
|
|
||||||
private ?string $id;
|
|
||||||
|
|
||||||
private ?string $date;
|
|
||||||
|
|
||||||
private ?string $key;
|
|
||||||
|
|
||||||
private ?string $from;
|
|
||||||
|
|
||||||
private ?string $where;
|
|
||||||
|
|
||||||
private array $parameters = [];
|
|
||||||
|
|
||||||
private bool $distinct = false;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
string $id = null,
|
|
||||||
string $date = null,
|
|
||||||
string $key = null,
|
|
||||||
string $from = null,
|
|
||||||
string $where = null,
|
|
||||||
array $parameters = []
|
|
||||||
) {
|
|
||||||
$this->id = $id;
|
|
||||||
$this->date = $date;
|
|
||||||
$this->key = $key;
|
|
||||||
$this->from = $from;
|
|
||||||
$this->where = $where;
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function fromArray(array $a)
|
|
||||||
{
|
|
||||||
return new TimelineSingleQuery(
|
|
||||||
$a['id'] ?? null,
|
|
||||||
$a['date'] ?? null,
|
|
||||||
$a['type'] ?? $a['key'] ?? null,
|
|
||||||
$a['FROM'] ?? $a['from'] ?? null,
|
|
||||||
$a['WHERE'] ?? $a['where'] ?? null,
|
|
||||||
$a['parameters'] ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): string
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setId(string $id): self
|
|
||||||
{
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): string
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDate(string $date): self
|
|
||||||
{
|
|
||||||
$this->date = $date;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getKey(): string
|
|
||||||
{
|
|
||||||
return $this->key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setKey(string $key): self
|
|
||||||
{
|
|
||||||
$this->key = $key;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFrom(): string
|
|
||||||
{
|
|
||||||
return $this->from;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFrom(string $from): self
|
|
||||||
{
|
|
||||||
$this->from = $from;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWhere(): string
|
|
||||||
{
|
|
||||||
return $this->where;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWhere(string $where): self
|
|
||||||
{
|
|
||||||
$this->where = $where;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParameters(): array
|
|
||||||
{
|
|
||||||
return $this->parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParameters(array $parameters): self
|
|
||||||
{
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDistinct(bool $distinct): self
|
|
||||||
{
|
|
||||||
$this->distinct = $distinct;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDistinct(): bool
|
|
||||||
{
|
|
||||||
return $this->distinct;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildSql(): string
|
|
||||||
{
|
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$sql = \strtr(
|
|
||||||
'SELECT {distinct} {id} AS id, '
|
|
||||||
. '{date} AS "date", '
|
|
||||||
. "'{key}' AS type "
|
|
||||||
. 'FROM {from} '
|
|
||||||
. 'WHERE {where}',
|
|
||||||
[
|
|
||||||
'{distinct}' => $this->distinct ? 'DISTINCT' : '',
|
|
||||||
'{id}' => $this->getId(),
|
|
||||||
'{date}' => $this->getDate(),
|
|
||||||
'{key}' => $this->getKey(),
|
|
||||||
'{from}' => $this->getFrom(),
|
|
||||||
'{where}' => $this->getWhere(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +1,3 @@
|
|||||||
chill_main_controllers:
|
|
||||||
resource: '../Controller/'
|
|
||||||
type: annotation
|
|
||||||
|
|
||||||
chill_main_admin_permissionsgroup:
|
chill_main_admin_permissionsgroup:
|
||||||
resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml"
|
resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml"
|
||||||
prefix: "{_locale}/admin/permissionsgroup"
|
prefix: "{_locale}/admin/permissionsgroup"
|
||||||
@@ -90,3 +86,7 @@ login_check:
|
|||||||
|
|
||||||
logout:
|
logout:
|
||||||
path: /logout
|
path: /logout
|
||||||
|
|
||||||
|
chill_main_test:
|
||||||
|
path: /{_locale}/main/test
|
||||||
|
controller: Chill\MainBundle\Controller\DefaultController::testAction
|
||||||
|
@@ -23,7 +23,6 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- "@request_stack"
|
- "@request_stack"
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
- "@chill.main.helper.translatable_string"
|
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: select2_chill_country }
|
- { name: form.type, alias: select2_chill_country }
|
||||||
|
|
||||||
@@ -32,7 +31,6 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- "@request_stack"
|
- "@request_stack"
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
- "@chill.main.helper.translatable_string"
|
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: select2_chill_language }
|
- { name: form.type, alias: select2_chill_language }
|
||||||
|
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
services:
|
|
||||||
Chill\MainBundle\Serializer\Normalizer\CenterNormalizer:
|
|
||||||
tags:
|
|
||||||
- { name: 'serializer.normalizer', priority: 64 }
|
|
||||||
|
|
||||||
Chill\MainBundle\Serializer\Normalizer\DateNormalizer:
|
|
||||||
tags:
|
|
||||||
- { name: 'serializer.normalizer', priority: 64 }
|
|
||||||
|
|
||||||
Chill\MainBundle\Serializer\Normalizer\UserNormalizer:
|
|
||||||
tags:
|
|
||||||
- { name: 'serializer.normalizer', priority: 64 }
|
|
@@ -5,6 +5,3 @@ services:
|
|||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
calls:
|
calls:
|
||||||
- [ setContainer, ["@service_container"]]
|
- [ setContainer, ["@service_container"]]
|
||||||
# alias:
|
|
||||||
Chill\MainBundle\Timeline\TimelineBuilder: '@chill_main.timeline_builder'
|
|
||||||
|
|
||||||
|
@@ -46,11 +46,6 @@ Back to the list: Retour à la liste
|
|||||||
#interval
|
#interval
|
||||||
Years: Années
|
Years: Années
|
||||||
|
|
||||||
# misc date
|
|
||||||
Since %date%: Depuis le %date%
|
|
||||||
since %date%: depuis le %date%
|
|
||||||
Until %date%: Jusqu'au %date%
|
|
||||||
until %date%: jusqu'au %date%
|
|
||||||
#elements used in software
|
#elements used in software
|
||||||
centers: centres
|
centers: centres
|
||||||
Centers: Centres
|
Centers: Centres
|
||||||
@@ -83,9 +78,6 @@ Results %start%-%end% of %total%: Résultats %start%-%end% sur %total%
|
|||||||
See all results: Voir tous les résultats
|
See all results: Voir tous les résultats
|
||||||
Advanced search: Recherche avancée
|
Advanced search: Recherche avancée
|
||||||
|
|
||||||
# timeline
|
|
||||||
Global timeline: Historique global
|
|
||||||
|
|
||||||
#admin
|
#admin
|
||||||
Create: Créer
|
Create: Créer
|
||||||
show: voir
|
show: voir
|
||||||
|
@@ -4,21 +4,17 @@ namespace Chill\PersonBundle\Controller;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||||
|
use Symfony\Component\Serializer\Serializer;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccompanyingCourseController
|
* Class AccompanyingCourseController
|
||||||
@@ -27,21 +23,6 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|||||||
*/
|
*/
|
||||||
class AccompanyingCourseController extends Controller
|
class AccompanyingCourseController extends Controller
|
||||||
{
|
{
|
||||||
protected SerializerInterface $serializer;
|
|
||||||
|
|
||||||
protected EventDispatcherInterface $dispatcher;
|
|
||||||
|
|
||||||
protected ValidatorInterface $validator;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
SerializerInterface $serializer,
|
|
||||||
EventDispatcherInterface $dispatcher,
|
|
||||||
ValidatorInterface $validator
|
|
||||||
) {
|
|
||||||
$this->serializer = $serializer;
|
|
||||||
$this->dispatcher = $dispatcher;
|
|
||||||
$this->validator = $validator;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Homepage of Accompanying Course section
|
* Homepage of Accompanying Course section
|
||||||
*
|
*
|
||||||
@@ -87,75 +68,54 @@ class AccompanyingCourseController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get API Data for showing endpoint
|
* Sérialise temporairement quelques données pour donner à manger au composant vuejs
|
||||||
*
|
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{_locale}/person/api/1.0/accompanying-course/{accompanying_period_id}/show.{_format}",
|
* "/{_locale}/api/parcours/{accompanying_period_id}/show",
|
||||||
* name="chill_person_accompanying_course_api_show"
|
* name="chill_person_accompanying_course_api_show")
|
||||||
* )
|
|
||||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||||
|
* @param SerializerInterface $serializer
|
||||||
*/
|
*/
|
||||||
public function showAPI(AccompanyingPeriod $accompanyingCourse, $_format): Response
|
public function showAPI(AccompanyingPeriod $accompanyingCourse): Response
|
||||||
{
|
{
|
||||||
// TODO check ACL on AccompanyingPeriod
|
$persons = [];
|
||||||
|
foreach ($accompanyingCourse->getParticipations() as $k => $participation ) {
|
||||||
$this->dispatcher->dispatch(
|
/**
|
||||||
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT,
|
* @var AccompanyingPeriodParticipation $participation
|
||||||
new AccompanyingPeriodPrivacyEvent($accompanyingCourse, [
|
* @var Person $person
|
||||||
'action' => 'showApi'
|
*/
|
||||||
])
|
$person = $participation->getPerson();
|
||||||
);
|
$persons[$k] = [
|
||||||
|
'firstname' => $person->getFirstName(),
|
||||||
switch ($_format) {
|
'lastname' => $person->getLastName(),
|
||||||
case 'json':
|
'email' => $person->getEmail(),
|
||||||
return $this->json($accompanyingCourse);
|
'phone' => $person->getPhonenumber(),
|
||||||
default:
|
'startdate' => ($participation->getStartDate()) ? $participation->getStartDate()->format('Y-m-d') : null,
|
||||||
throw new BadRequestException('Unsupported format');
|
'enddate' => ($participation->getEndDate()) ? $participation->getEndDate()->format('Y-m-d') : null
|
||||||
}
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$data = [
|
||||||
|
'id' => $accompanyingCourse->getId(),
|
||||||
|
'remark' => $accompanyingCourse->getRemark(),
|
||||||
|
'closing_motive' => $accompanyingCourse->getClosingMotive() ? $accompanyingCourse->getClosingMotive()->getName()['fr'] : null,
|
||||||
|
'opening_date' => ($accompanyingCourse->getOpeningDate()) ? $accompanyingCourse->getOpeningDate()->format('Y-m-d') : null,
|
||||||
|
'closing_date' => ($accompanyingCourse->getClosingDate()) ? $accompanyingCourse->getClosingDate()->format('Y-m-d') : null,
|
||||||
|
'persons' => $persons
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get API Data for showing endpoint
|
$normalizer = [new ObjectNormalizer()];
|
||||||
|
$encoder = [new JsonEncoder()];
|
||||||
|
|
||||||
|
$serializer = new Serializer($normalizer, $encoder);
|
||||||
|
$serialized = $serializer->serialize($data,'json', []);
|
||||||
*
|
*
|
||||||
* @Route(
|
|
||||||
* "/{_locale}/person/api/1.0/accompanying-course/{accompanying_period_id}/participation.{_format}",
|
|
||||||
* name="chill_person_accompanying_course_api_add_participation",
|
|
||||||
* methods={"POST"},
|
|
||||||
* format="json",
|
|
||||||
* requirements={
|
|
||||||
* "_format": "json",
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
|
||||||
*/
|
*/
|
||||||
public function addParticipationAPI(Request $request, AccompanyingPeriod $accompanyingCourse, $_format): Response
|
$serialized = \json_encode($data);
|
||||||
{
|
$response = new Response($serialized);
|
||||||
switch ($_format) {
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
case 'json':
|
return $response;
|
||||||
$person = $this->serializer->deserialize($request->getContent(), Person::class, $_format, [
|
|
||||||
|
|
||||||
]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new BadRequestException('Unsupported format');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL === $person) {
|
|
||||||
throw new BadRequestException('person id not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO add acl
|
|
||||||
$accompanyingCourse->addPerson($person);
|
|
||||||
$errors = $this->validator->validate($accompanyingCourse);
|
|
||||||
|
|
||||||
if ($errors->count() > 0) {
|
|
||||||
// only format accepted
|
|
||||||
return $this->json($errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
return new JsonResponse();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015-2021 Champs-Libres Coopérative <info@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\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
|
|
||||||
|
|
||||||
class ApiPersonController extends Controller
|
|
||||||
{
|
|
||||||
public function viewAction($id, $_format)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -39,16 +39,22 @@ use Chill\MainBundle\Search\SearchProvider;
|
|||||||
use Chill\PersonBundle\Repository\PersonRepository;
|
use Chill\PersonBundle\Repository\PersonRepository;
|
||||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
|
|
||||||
final class PersonController extends AbstractController
|
/**
|
||||||
|
* Class PersonController
|
||||||
|
*
|
||||||
|
* @package Chill\PersonBundle\Controller
|
||||||
|
*/
|
||||||
|
class PersonController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var SimilarPersonMatcher
|
* @var SimilarPersonMatcher
|
||||||
*/
|
*/
|
||||||
protected $similarPersonMatcher;
|
protected $similarPersonMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
@@ -59,20 +65,17 @@ final class PersonController extends AbstractController
|
|||||||
protected $eventDispatcher;
|
protected $eventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var PersonRepository;
|
* @var PersonRepository;
|
||||||
*/
|
*/
|
||||||
protected $personRepository;
|
protected $personRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var ConfigPersonAltNamesHelper
|
* @var ConfigPersonAltNamesHelper
|
||||||
*/
|
*/
|
||||||
protected $configPersonAltNameHelper;
|
protected $configPersonAltNameHelper;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EntityManagerInterface
|
|
||||||
*/
|
|
||||||
private $em;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Psr\Log\LoggerInterface
|
* @var \Psr\Log\LoggerInterface
|
||||||
*/
|
*/
|
||||||
@@ -90,8 +93,7 @@ final class PersonController extends AbstractController
|
|||||||
PersonRepository $personRepository,
|
PersonRepository $personRepository,
|
||||||
ConfigPersonAltNamesHelper $configPersonAltNameHelper,
|
ConfigPersonAltNamesHelper $configPersonAltNameHelper,
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
ValidatorInterface $validator,
|
ValidatorInterface $validator
|
||||||
EntityManagerInterface $em
|
|
||||||
) {
|
) {
|
||||||
$this->similarPersonMatcher = $similarPersonMatcher;
|
$this->similarPersonMatcher = $similarPersonMatcher;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
@@ -100,14 +102,14 @@ final class PersonController extends AbstractController
|
|||||||
$this->personRepository = $personRepository;
|
$this->personRepository = $personRepository;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->em = $em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCFGroup()
|
public function getCFGroup()
|
||||||
{
|
{
|
||||||
$cFGroup = null;
|
$cFGroup = null;
|
||||||
|
|
||||||
$cFDefaultGroup = $this->em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup")
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$cFDefaultGroup = $em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup")
|
||||||
->findOneByEntity("Chill\PersonBundle\Entity\Person");
|
->findOneByEntity("Chill\PersonBundle\Entity\Person");
|
||||||
|
|
||||||
if($cFDefaultGroup) {
|
if($cFDefaultGroup) {
|
||||||
@@ -196,7 +198,8 @@ final class PersonController extends AbstractController
|
|||||||
->trans('The person data has been updated')
|
->trans('The person data has been updated')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->em->flush();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
$url = $this->generateUrl('chill_person_view', array(
|
$url = $this->generateUrl('chill_person_view', array(
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
@@ -340,8 +343,6 @@ final class PersonController extends AbstractController
|
|||||||
$this->logger->info('Person created without errors');
|
$this->logger->info('Person created without errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($person);
|
|
||||||
|
|
||||||
$alternatePersons = $this->similarPersonMatcher
|
$alternatePersons = $this->similarPersonMatcher
|
||||||
->matchPerson($person);
|
->matchPerson($person);
|
||||||
|
|
||||||
@@ -390,9 +391,11 @@ final class PersonController extends AbstractController
|
|||||||
'You are not allowed to create this person');
|
'You are not allowed to create this person');
|
||||||
|
|
||||||
if ($errors->count() === 0) {
|
if ($errors->count() === 0) {
|
||||||
$this->em->persist($person);
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$this->em->flush();
|
$em->persist($person);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_person_general_edit',
|
return $this->redirect($this->generateUrl('chill_person_general_edit',
|
||||||
array('person_id' => $person->getId())));
|
array('person_id' => $person->getId())));
|
||||||
|
@@ -27,17 +27,32 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Chill\MainBundle\Timeline\TimelineBuilder;
|
use Chill\MainBundle\Timeline\TimelineBuilder;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TimelinePersonController
|
||||||
|
*
|
||||||
|
* @package Chill\PersonBundle\Controller
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class TimelinePersonController extends AbstractController
|
class TimelinePersonController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
protected EventDispatcherInterface $eventDispatcher;
|
/**
|
||||||
|
* @var EventDispatcherInterface
|
||||||
|
*/
|
||||||
|
protected $eventDispatcher;
|
||||||
|
|
||||||
protected TimelineBuilder $timelineBuilder;
|
/**
|
||||||
|
*
|
||||||
|
* @var TimelineBuilder
|
||||||
|
*/
|
||||||
|
protected $timelineBuilder;
|
||||||
|
|
||||||
protected PaginatorFactory $paginatorFactory;
|
/**
|
||||||
|
*
|
||||||
|
* @var PaginatorFactory
|
||||||
|
*/
|
||||||
|
protected $paginatorFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimelinePersonController constructor.
|
* TimelinePersonController constructor.
|
||||||
@@ -47,13 +62,11 @@ class TimelinePersonController extends AbstractController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
TimelineBuilder $timelineBuilder,
|
TimelineBuilder $timelineBuilder,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory
|
||||||
AuthorizationHelper $authorizationHelper
|
|
||||||
) {
|
) {
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->timelineBuilder = $timelineBuilder;
|
$this->timelineBuilder = $timelineBuilder;
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -75,7 +75,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/repository.yaml');
|
$loader->load('services/repository.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
$loader->load('services/serializer.yaml');
|
|
||||||
|
|
||||||
// load service advanced search only if configure
|
// load service advanced search only if configure
|
||||||
if ($config['search']['search_by_phone'] != 'never') {
|
if ($config['search']['search_by_phone'] != 'never') {
|
||||||
|
@@ -42,37 +42,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
*/
|
*/
|
||||||
class AccompanyingPeriod
|
class AccompanyingPeriod
|
||||||
{
|
{
|
||||||
/**
|
const INTENSITY = ['occasional', 'regular'];
|
||||||
* Mark an accompanying period as "occasional"
|
|
||||||
*
|
|
||||||
* used in INTENSITY
|
|
||||||
*/
|
|
||||||
public const INTENSITY_OCCASIONAL = 'occasional';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark an accompanying period as "regular"
|
|
||||||
*
|
|
||||||
* used in INTENSITY
|
|
||||||
*/
|
|
||||||
public const INTENSITY_REGULAR = 'regular';
|
|
||||||
|
|
||||||
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark an accompanying period as "draft".
|
|
||||||
*
|
|
||||||
* This means that the accompanying period is not yet
|
|
||||||
* confirmed by the creator
|
|
||||||
*/
|
|
||||||
public const STEP_DRAFT = 'DRAFT';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark an accompanying period as "confirmed".
|
|
||||||
*
|
|
||||||
* This means that the accompanying period **is**
|
|
||||||
* confirmed by the creator
|
|
||||||
*/
|
|
||||||
public const STEP_CONFIRMED = 'CONFIRMED';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var integer
|
||||||
@@ -147,7 +117,7 @@ class AccompanyingPeriod
|
|||||||
* @var string
|
* @var string
|
||||||
* @ORM\Column(type="string", length=32, nullable=true)
|
* @ORM\Column(type="string", length=32, nullable=true)
|
||||||
*/
|
*/
|
||||||
private $step = self::STEP_DRAFT;
|
private $step = 'DRAFT';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||||
@@ -302,9 +272,13 @@ class AccompanyingPeriod
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRemark(string $remark = null): self
|
public function setRemark(string $remark): self
|
||||||
{
|
{
|
||||||
$this->remark = (string) $remark;
|
if ($remark === null) {
|
||||||
|
$remark = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->remark = $remark;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -625,16 +599,4 @@ class AccompanyingPeriod
|
|||||||
{
|
{
|
||||||
$this->resources->removeElement($resource);
|
$this->resources->removeElement($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all persons which are participating to this course
|
|
||||||
*/
|
|
||||||
public function getPersons(): Collection
|
|
||||||
{
|
|
||||||
return $this->participations->map(
|
|
||||||
function(AccompanyingPeriodParticipation $participation) {
|
|
||||||
return $participation->getPerson();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,309 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=AccompanyingPeriodWorkRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_work")
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriodWork
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="text")
|
|
||||||
*/
|
|
||||||
private $note;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
|
||||||
*/
|
|
||||||
private $accompanyingPeriod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
|
||||||
*/
|
|
||||||
private $socialAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime")
|
|
||||||
*/
|
|
||||||
private $createdAt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
|
||||||
* @ORM\JoinColumn(nullable=false)
|
|
||||||
*/
|
|
||||||
private $createdBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime")
|
|
||||||
*/
|
|
||||||
private $startDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime")
|
|
||||||
*/
|
|
||||||
private $endDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
|
||||||
*
|
|
||||||
* In schema : traitant
|
|
||||||
*/
|
|
||||||
private $handlingThierParty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private $createdAutomatically;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="text")
|
|
||||||
*/
|
|
||||||
private $createdAutomaticallyReason;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork")
|
|
||||||
*/
|
|
||||||
private $goals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
|
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
|
|
||||||
*/
|
|
||||||
private $results;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
|
|
||||||
*
|
|
||||||
* In schema : intervenants
|
|
||||||
*/
|
|
||||||
private $thirdParties;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->goals = new ArrayCollection();
|
|
||||||
$this->results = new ArrayCollection();
|
|
||||||
$this->thirdParties = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNote(): ?string
|
|
||||||
{
|
|
||||||
return $this->note;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNote(string $note): self
|
|
||||||
{
|
|
||||||
$this->note = $note;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
|
||||||
{
|
|
||||||
return $this->accompanyingPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
|
||||||
{
|
|
||||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSocialAction(): ?SocialAction
|
|
||||||
{
|
|
||||||
return $this->socialAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSocialAction(?SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
$this->socialAction = $socialAction;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedAt(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
|
||||||
{
|
|
||||||
$this->createdAt = $createdAt;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedBy(?User $createdBy): self
|
|
||||||
{
|
|
||||||
$this->createdBy = $createdBy;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStartDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setStartDate(\DateTimeInterface $startDate): self
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEndDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEndDate(\DateTimeInterface $endDate): self
|
|
||||||
{
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHandlingThierParty(): ?ThirdParty
|
|
||||||
{
|
|
||||||
return $this->handlingThierParty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHandlingThierParty(?ThirdParty $handlingThierParty): self
|
|
||||||
{
|
|
||||||
$this->handlingThierParty = $handlingThierParty;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedAutomatically(): ?bool
|
|
||||||
{
|
|
||||||
return $this->createdAutomatically;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedAutomatically(bool $createdAutomatically): self
|
|
||||||
{
|
|
||||||
$this->createdAutomatically = $createdAutomatically;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedAutomaticallyReason(): ?string
|
|
||||||
{
|
|
||||||
return $this->createdAutomaticallyReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreatedAutomaticallyReason(string $createdAutomaticallyReason): self
|
|
||||||
{
|
|
||||||
$this->createdAutomaticallyReason = $createdAutomaticallyReason;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|AccompanyingPeriodWorkGoal[]
|
|
||||||
*/
|
|
||||||
public function getGoals(): Collection
|
|
||||||
{
|
|
||||||
return $this->goals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addGoal(AccompanyingPeriodWorkGoal $goal): self
|
|
||||||
{
|
|
||||||
if (!$this->goals->contains($goal)) {
|
|
||||||
$this->goals[] = $goal;
|
|
||||||
$goal->setAccompanyingPeriodWork2($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeGoal(AccompanyingPeriodWorkGoal $goal): self
|
|
||||||
{
|
|
||||||
if ($this->goals->removeElement($goal)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($goal->getAccompanyingPeriodWork2() === $this) {
|
|
||||||
$goal->setAccompanyingPeriodWork2(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Result[]
|
|
||||||
*/
|
|
||||||
public function getResults(): Collection
|
|
||||||
{
|
|
||||||
return $this->results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addResult(Result $result): self
|
|
||||||
{
|
|
||||||
if (!$this->results->contains($result)) {
|
|
||||||
$this->results[] = $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeResult(Result $result): self
|
|
||||||
{
|
|
||||||
$this->results->removeElement($result);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|ThirdParty[]
|
|
||||||
*/
|
|
||||||
public function getThirdParties(): Collection
|
|
||||||
{
|
|
||||||
return $this->thirdParties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addThirdParty(ThirdParty $thirdParty): self
|
|
||||||
{
|
|
||||||
if (!$this->thirdParties->contains($thirdParty)) {
|
|
||||||
$this->thirdParties[] = $thirdParty;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeThirdParty(ThirdParty $thirdParty): self
|
|
||||||
{
|
|
||||||
$this->thirdParties->removeElement($thirdParty);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkGoalRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=AccompanyingPeriodWorkGoalRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriodWorkGoal
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="text")
|
|
||||||
*/
|
|
||||||
private $note;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="goals")
|
|
||||||
*/
|
|
||||||
private $accompanyingPeriodWork;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
|
||||||
*/
|
|
||||||
private $goal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
|
||||||
*/
|
|
||||||
private $results;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->results = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNote(): ?string
|
|
||||||
{
|
|
||||||
return $this->note;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNote(string $note): self
|
|
||||||
{
|
|
||||||
$this->note = $note;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
|
|
||||||
{
|
|
||||||
return $this->accompanyingPeriodWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self
|
|
||||||
{
|
|
||||||
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getGoal(): ?Goal
|
|
||||||
{
|
|
||||||
return $this->goal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setGoal(?Goal $goal): self
|
|
||||||
{
|
|
||||||
$this->goal = $goal;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Result[]
|
|
||||||
*/
|
|
||||||
public function getResults(): Collection
|
|
||||||
{
|
|
||||||
return $this->results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addResult(Result $result): self
|
|
||||||
{
|
|
||||||
if (!$this->results->contains($result)) {
|
|
||||||
$this->results[] = $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeResult(Result $result): self
|
|
||||||
{
|
|
||||||
$this->results->removeElement($result);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -47,7 +47,7 @@ class ClosingMotive
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json_array")
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ class Origin
|
|||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="string", length=255)
|
||||||
*/
|
*/
|
||||||
private $label;
|
private $label;
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ class AccompanyingPeriodParticipation
|
|||||||
private $person;
|
private $person;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations")
|
||||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||||
*/
|
*/
|
||||||
private $accompanyingPeriod;
|
private $accompanyingPeriod;
|
||||||
|
@@ -22,17 +22,15 @@ namespace Chill\PersonBundle\Entity;
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use ArrayIterator;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Criteria;
|
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1010,28 +1008,32 @@ class Person implements HasCenterInterface
|
|||||||
/**
|
/**
|
||||||
* By default, the addresses are ordered by date, descending (the most
|
* By default, the addresses are ordered by date, descending (the most
|
||||||
* recent first)
|
* recent first)
|
||||||
|
*
|
||||||
|
* @return \Chill\MainBundle\Entity\Address[]
|
||||||
*/
|
*/
|
||||||
public function getAddresses(): Collection
|
public function getAddresses()
|
||||||
{
|
{
|
||||||
return $this->addresses;
|
return $this->addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastAddress(DateTime $from = null)
|
/**
|
||||||
|
* @param \DateTime|null $date
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getLastAddress(\DateTime $date = null)
|
||||||
{
|
{
|
||||||
$from ??= new DateTime('now');
|
if ($date === null) {
|
||||||
|
$date = new \DateTime('now');
|
||||||
|
}
|
||||||
|
|
||||||
/** @var ArrayIterator $addressesIterator */
|
$addresses = $this->getAddresses();
|
||||||
$addressesIterator = $this->getAddresses()
|
|
||||||
->filter(static fn (Address $address): bool => $address->getValidFrom() <= $from)
|
|
||||||
->getIterator();
|
|
||||||
|
|
||||||
$addressesIterator->uasort(
|
if ($addresses == null) {
|
||||||
static fn (Address $left, Address $right): int => $right->getValidFrom() <=> $left->getValidFrom()
|
|
||||||
);
|
|
||||||
|
|
||||||
return [] === ($addresses = iterator_to_array($addressesIterator)) ?
|
return null;
|
||||||
null :
|
}
|
||||||
current($addresses);
|
|
||||||
|
return $addresses->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,93 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=EvaluationRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_social_work_evaluation")
|
|
||||||
*/
|
|
||||||
class Evaluation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $title = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="dateinterval")
|
|
||||||
*/
|
|
||||||
private $delay;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="dateinterval")
|
|
||||||
*/
|
|
||||||
private $notificationDelay;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
|
||||||
*/
|
|
||||||
private $socialAction;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): array
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(array $title): self
|
|
||||||
{
|
|
||||||
$this->title = $title;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDelay(): ?\DateInterval
|
|
||||||
{
|
|
||||||
return $this->delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDelay(\DateInterval $delay): self
|
|
||||||
{
|
|
||||||
$this->delay = $delay;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNotificationDelay(): ?\DateInterval
|
|
||||||
{
|
|
||||||
return $this->notificationDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNotificationDelay(\DateInterval $notificationDelay): self
|
|
||||||
{
|
|
||||||
$this->notificationDelay = $notificationDelay;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSocialAction(): ?SocialAction
|
|
||||||
{
|
|
||||||
return $this->socialAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSocialAction(?SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
$this->socialAction = $socialAction;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=GoalRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_social_work_goal")
|
|
||||||
*/
|
|
||||||
class Goal
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $title = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true)
|
|
||||||
*/
|
|
||||||
private $desactivationDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="goals")
|
|
||||||
*/
|
|
||||||
private $socialActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="goals")
|
|
||||||
* @ORM\JoinTable(name="chill_person_social_work_goal_result")
|
|
||||||
*/
|
|
||||||
private $results;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->socialActions = new ArrayCollection();
|
|
||||||
$this->results = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): array
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(array $title): self
|
|
||||||
{
|
|
||||||
$this->title = $title;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDesactivationDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->desactivationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
|
||||||
{
|
|
||||||
$this->desactivationDate = $desactivationDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|SocialAction[]
|
|
||||||
*/
|
|
||||||
public function getSocialActions(): Collection
|
|
||||||
{
|
|
||||||
return $this->socialActions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
|
||||||
$this->socialActions[] = $socialAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
$this->socialActions->removeElement($socialAction);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Result[]
|
|
||||||
*/
|
|
||||||
public function getResults(): Collection
|
|
||||||
{
|
|
||||||
return $this->results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addResult(Result $result): self
|
|
||||||
{
|
|
||||||
if (!$this->results->contains($result)) {
|
|
||||||
$this->results[] = $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeResult(Result $result): self
|
|
||||||
{
|
|
||||||
$this->results->removeElement($result);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,187 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=ResultRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_social_work_result")
|
|
||||||
*/
|
|
||||||
class Result
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $title = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true)
|
|
||||||
*/
|
|
||||||
private $desactivationDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="results")
|
|
||||||
*/
|
|
||||||
private $socialActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")
|
|
||||||
*/
|
|
||||||
private $goals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWork::class, mappedBy="results")
|
|
||||||
*/
|
|
||||||
private $accompanyingPeriodWorks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="results")
|
|
||||||
*/
|
|
||||||
private $accompanyingPeriodWorkGoals;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->socialActions = new ArrayCollection();
|
|
||||||
$this->goals = new ArrayCollection();
|
|
||||||
$this->accompanyingPeriodWorks = new ArrayCollection();
|
|
||||||
$this->accompanyingPeriodWorkGoals = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): array
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(array $title): self
|
|
||||||
{
|
|
||||||
$this->title = $title;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDesactivationDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->desactivationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
|
||||||
{
|
|
||||||
$this->desactivationDate = $desactivationDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|SocialAction[]
|
|
||||||
*/
|
|
||||||
public function getSocialActions(): Collection
|
|
||||||
{
|
|
||||||
return $this->socialActions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
|
||||||
$this->socialActions[] = $socialAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
$this->socialActions->removeElement($socialAction);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Goal[]
|
|
||||||
*/
|
|
||||||
public function getGoals(): Collection
|
|
||||||
{
|
|
||||||
return $this->goals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addGoal(Goal $goal): self
|
|
||||||
{
|
|
||||||
if (!$this->goals->contains($goal)) {
|
|
||||||
$this->goals[] = $goal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeGoal(Goal $goal): self
|
|
||||||
{
|
|
||||||
$this->goals->removeElement($goal);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|AccompanyingPeriodWork[]
|
|
||||||
*/
|
|
||||||
public function getAccompanyingPeriodWorks(): Collection
|
|
||||||
{
|
|
||||||
return $this->accompanyingPeriodWorks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAccompanyingPeriodWork(AccompanyingPeriodWork $accompanyingPeriod): self
|
|
||||||
{
|
|
||||||
if (!$this->accompanyingPeriodWorks->contains($accompanyingPeriod)) {
|
|
||||||
$this->accompanyingPeriodWorks[] = $accompanyingPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAccompanyingPeriodWork(AccompanyingPeriodWork $accompanyingPeriod): self
|
|
||||||
{
|
|
||||||
$this->accompanyingPeriodWorks->removeElement($accompanyingPeriod);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|AccompanyingPeriodWorkGoal[]
|
|
||||||
*/
|
|
||||||
public function getAccompanyingPeriodWorkGoals(): Collection
|
|
||||||
{
|
|
||||||
return $this->accompanyingPeriodWorkGoals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAccompanyingPeriodWorkGoal(AccompanyingPeriodWorkGoal $accompanyingPeriodWorkGoal): self
|
|
||||||
{
|
|
||||||
if (!$this->accompanyingPeriodWorkGoals->contains($accompanyingPeriodWorkGoal)) {
|
|
||||||
$this->accompanyingPeriodWorkGoals[] = $accompanyingPeriodWorkGoal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAccompanyingPeriodWorkGoal(AccompanyingPeriodWorkGoal $accompanyingPeriodWorkGoal): self
|
|
||||||
{
|
|
||||||
$this->accompanyingPeriodWorkGoals->removeElement($accompanyingPeriodWorkGoal);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,214 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=SocialActionRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_social_action")
|
|
||||||
*/
|
|
||||||
class SocialAction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true)
|
|
||||||
*/
|
|
||||||
private $desactivationDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="socialActions")
|
|
||||||
*/
|
|
||||||
private $issue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children")
|
|
||||||
*/
|
|
||||||
private $parent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
|
|
||||||
*/
|
|
||||||
private $children;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="dateinterval")
|
|
||||||
*/
|
|
||||||
private $defaultNotificationDelay;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $title = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Goal::class, inversedBy="socialActions")
|
|
||||||
* @ORM\JoinTable(name="chill_person_social_action_goal")
|
|
||||||
*/
|
|
||||||
private $goals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="socialActions")
|
|
||||||
* @ORM\JoinTable(name="chill_person_social_action_result")
|
|
||||||
*/
|
|
||||||
private $results;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->children = new ArrayCollection();
|
|
||||||
$this->goals = new ArrayCollection();
|
|
||||||
$this->results = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDesactivationDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->desactivationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
|
||||||
{
|
|
||||||
$this->desactivationDate = $desactivationDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIssue(): ?SocialIssue
|
|
||||||
{
|
|
||||||
return $this->issue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIssue(?SocialIssue $issue): self
|
|
||||||
{
|
|
||||||
$this->issue = $issue;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParent(): ?self
|
|
||||||
{
|
|
||||||
return $this->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParent(?self $parent): self
|
|
||||||
{
|
|
||||||
$this->parent = $parent;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|self[]
|
|
||||||
*/
|
|
||||||
public function getChildren(): Collection
|
|
||||||
{
|
|
||||||
return $this->children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addChild(self $child): self
|
|
||||||
{
|
|
||||||
if (!$this->children->contains($child)) {
|
|
||||||
$this->children[] = $child;
|
|
||||||
$child->setParent($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeChild(self $child): self
|
|
||||||
{
|
|
||||||
if ($this->children->removeElement($child)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($child->getParent() === $this) {
|
|
||||||
$child->setParent(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDefaultNotificationDelay(): ?\DateInterval
|
|
||||||
{
|
|
||||||
return $this->defaultNotificationDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDefaultNotificationDelay(\DateInterval $defaultNotificationDelay): self
|
|
||||||
{
|
|
||||||
$this->defaultNotificationDelay = $defaultNotificationDelay;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): array
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(array $title): self
|
|
||||||
{
|
|
||||||
$this->title = $title;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Goal[]
|
|
||||||
*/
|
|
||||||
public function getGoals(): Collection
|
|
||||||
{
|
|
||||||
return $this->goals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addGoal(Goal $goal): self
|
|
||||||
{
|
|
||||||
if (!$this->goals->contains($goal)) {
|
|
||||||
$this->goals[] = $goal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeGoal(Goal $goal): self
|
|
||||||
{
|
|
||||||
$this->goals->removeElement($goal);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|Result[]
|
|
||||||
*/
|
|
||||||
public function getResults(): Collection
|
|
||||||
{
|
|
||||||
return $this->results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addResult(Result $result): self
|
|
||||||
{
|
|
||||||
if (!$this->results->contains($result)) {
|
|
||||||
$this->results[] = $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeResult(Result $result): self
|
|
||||||
{
|
|
||||||
$this->results->removeElement($result);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,154 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
||||||
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=SocialIssueRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_social_issue")
|
|
||||||
*/
|
|
||||||
class SocialIssue
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="children")
|
|
||||||
*/
|
|
||||||
private $parent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
|
|
||||||
*/
|
|
||||||
private $children;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true)
|
|
||||||
*/
|
|
||||||
private $desactivationDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $title = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
|
|
||||||
*/
|
|
||||||
private $socialActions;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->children = new ArrayCollection();
|
|
||||||
$this->socialActions = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParent(): ?self
|
|
||||||
{
|
|
||||||
return $this->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParent(?self $parent): self
|
|
||||||
{
|
|
||||||
$this->parent = $parent;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|self[]
|
|
||||||
*/
|
|
||||||
public function getChildren(): Collection
|
|
||||||
{
|
|
||||||
return $this->children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addChild(self $child): self
|
|
||||||
{
|
|
||||||
if (!$this->children->contains($child)) {
|
|
||||||
$this->children[] = $child;
|
|
||||||
$child->setParent($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeChild(self $child): self
|
|
||||||
{
|
|
||||||
if ($this->children->removeElement($child)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($child->getParent() === $this) {
|
|
||||||
$child->setParent(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDesactivationDate(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->desactivationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
|
||||||
{
|
|
||||||
$this->desactivationDate = $desactivationDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): array
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(array $title): self
|
|
||||||
{
|
|
||||||
$this->title = $title;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|SocialAction[]
|
|
||||||
*/
|
|
||||||
public function getSocialActions(): Collection
|
|
||||||
{
|
|
||||||
return $this->socialActions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
|
||||||
$this->socialActions[] = $socialAction;
|
|
||||||
$socialAction->setSocialIssue($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeSocialAction(SocialAction $socialAction): self
|
|
||||||
{
|
|
||||||
if ($this->socialActions->removeElement($socialAction)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($socialAction->getSocialIssue() === $this) {
|
|
||||||
$socialAction->setSocialIssue(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -123,8 +123,7 @@ class PersonType extends AbstractType
|
|||||||
'label' => false,
|
'label' => false,
|
||||||
'delete_empty' => function(PersonPhone $pp = null) {
|
'delete_empty' => function(PersonPhone $pp = null) {
|
||||||
return NULL === $pp || $pp->isEmpty();
|
return NULL === $pp || $pp->isEmpty();
|
||||||
},
|
}
|
||||||
'error_bubbling' => false
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($this->config['email'] === 'visible') {
|
if ($this->config['email'] === 'visible') {
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Privacy;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
|
|
||||||
class AccompanyingPeriodPrivacyEvent extends Event
|
|
||||||
{
|
|
||||||
public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event';
|
|
||||||
|
|
||||||
protected AccompanyingPeriod $period;
|
|
||||||
|
|
||||||
protected array $args;
|
|
||||||
|
|
||||||
public function __construct($period, $args = [])
|
|
||||||
{
|
|
||||||
$this->period = $period;
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPeriod(): AccompanyingPeriod
|
|
||||||
{
|
|
||||||
return $this->period;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getArgs(): array
|
|
||||||
{
|
|
||||||
return $this->args;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,7 +26,6 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
|
||||||
|
|
||||||
class PrivacyEventSubscriber implements EventSubscriberInterface
|
class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
@@ -54,33 +53,14 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
|||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return array(PrivacyEvent::PERSON_PRIVACY_EVENT => array(
|
||||||
PrivacyEvent::PERSON_PRIVACY_EVENT => [
|
array('onPrivacyEvent')
|
||||||
['onPrivacyEvent']
|
));
|
||||||
],
|
|
||||||
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT => [
|
|
||||||
['onAccompanyingPeriodPrivacyEvent']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onAccompanyingPeriodPrivacyEvent(AccompanyingPeriodPrivacyEvent $event)
|
|
||||||
{
|
|
||||||
$involved = $this->getInvolved();
|
|
||||||
$involved['period_id'] = $event->getPeriod()->getId();
|
|
||||||
$involved['persons'] = $event->getPeriod()->getPersons()
|
|
||||||
->map(function(Person $p) { return $p->getId(); })
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$this->logger->notice(
|
|
||||||
"[Privacy Event] An accompanying period has been viewed",
|
|
||||||
array_merge($involved, $event->getArgs())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPrivacyEvent(PrivacyEvent $event)
|
public function onPrivacyEvent(PrivacyEvent $event)
|
||||||
{
|
{
|
||||||
$persons = [];
|
$persons = array();
|
||||||
|
|
||||||
if ($event->hasPersons() === true) {
|
if ($event->hasPersons() === true) {
|
||||||
foreach ($event->getPersons() as $person) {
|
foreach ($event->getPersons() as $person) {
|
||||||
@@ -88,8 +68,11 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$involved = $this->getInvolved();
|
$involved = array(
|
||||||
$involved['person_id'] = $event->getPerson()->getId();
|
'by_user' => $this->token->getToken()->getUser()->getUsername(),
|
||||||
|
'by_user_id' => $this->token->getToken()->getUser()->getId(),
|
||||||
|
'person_id' => $event->getPerson()->getId(),
|
||||||
|
);
|
||||||
|
|
||||||
if ($event->hasPersons()) {
|
if ($event->hasPersons()) {
|
||||||
$involved['persons'] = \array_map(
|
$involved['persons'] = \array_map(
|
||||||
@@ -103,12 +86,4 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
|||||||
array_merge($involved, $event->getArgs())
|
array_merge($involved, $event->getArgs())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getInvolved(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'by_user' => $this->token->getToken()->getUser()->getUsername(),
|
|
||||||
'by_user_id' => $this->token->getToken()->getUser()->getId(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method AccompanyingPeriodWorkGoal|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method AccompanyingPeriodWorkGoal|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method AccompanyingPeriodWorkGoal[] findAll()
|
|
||||||
* @method AccompanyingPeriodWorkGoal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriodWorkGoalRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, AccompanyingPeriodWorkGoal::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method AccompanyingPeriodWork|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method AccompanyingPeriodWork|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method AccompanyingPeriodWork[] findAll()
|
|
||||||
* @method AccompanyingPeriodWork[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriodWorkRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, AccompanyingPeriodWork::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -23,7 +23,6 @@
|
|||||||
namespace Chill\PersonBundle\Repository;
|
namespace Chill\PersonBundle\Repository;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
@@ -39,4 +38,5 @@ class AccompanyingPeriodRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($registry, AccompanyingPeriod::class);
|
parent::__construct($registry, AccompanyingPeriod::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method Evaluation|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Evaluation|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Evaluation[] findAll()
|
|
||||||
* @method Evaluation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class EvaluationRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, Evaluation::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method Goal|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Goal|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Goal[] findAll()
|
|
||||||
* @method Goal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class GoalRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, Goal::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method Result|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Result|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Result[] findAll()
|
|
||||||
* @method Result[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class ResultRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, Result::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method SocialAction|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method SocialAction|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method SocialAction[] findAll()
|
|
||||||
* @method SocialAction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class SocialActionRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, SocialAction::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\SocialWork;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method SocialIssue|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method SocialIssue|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method SocialIssue[] findAll()
|
|
||||||
* @method SocialIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class SocialIssueRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, SocialIssue::class);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<div id="app">
|
||||||
|
<persons_associated></persons_associated>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import persons_associated from './components/PersonsAssociated.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'app',
|
||||||
|
components: {
|
||||||
|
persons_associated,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@@ -1,45 +0,0 @@
|
|||||||
<template>
|
|
||||||
<accompanying-course v-bind:accompanying_course="accompanying_course"/>
|
|
||||||
<persons-associated v-bind:persons_associated="accompanying_course.persons"/>
|
|
||||||
<requestor v-bind:accompanying_course="accompanying_course"/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import AccompanyingCourse from './components/AccompanyingCourse.vue';
|
|
||||||
import PersonsAssociated from './components/PersonsAssociated.vue';
|
|
||||||
import Requestor from './components/Requestor.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'App',
|
|
||||||
components: {
|
|
||||||
AccompanyingCourse,
|
|
||||||
PersonsAssociated,
|
|
||||||
Requestor
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
accompanying_course: {}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
accompanyingCourseId() {
|
|
||||||
return window.accompanyingCourseId;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async getAccompanyingCourse() {
|
|
||||||
let data_;
|
|
||||||
return fetch(`/fr/api/parcours/${accompanyingCourseId}/show`)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
this.$data.accompanying_course = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
await this.getAccompanyingCourse();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
@@ -1,26 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="vue-component">
|
|
||||||
<h3>Parcours</h3>
|
|
||||||
<dl>
|
|
||||||
<dt>id</dt>
|
|
||||||
<dd>{{ accompanying_course.id }}</dd>
|
|
||||||
<dt>opening_date</dt>
|
|
||||||
<dd>{{ accompanying_course.opening_date }}</dd>
|
|
||||||
<dt>closing_date</dt>
|
|
||||||
<dd>{{ accompanying_course.closing_date }}</dd>
|
|
||||||
<dt>remark</dt>
|
|
||||||
<dd>{{ accompanying_course.remark }}</dd>
|
|
||||||
<dt>closing_motive</dt>
|
|
||||||
<dd>{{ accompanying_course.closing_motive }}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'AccompanyingCourse',
|
|
||||||
props: {
|
|
||||||
accompanying_course: Object
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,25 +0,0 @@
|
|||||||
<template>
|
|
||||||
<tr>
|
|
||||||
<td>{{ person.firstname }}</td>
|
|
||||||
<td>{{ person.lastname }}</td>
|
|
||||||
<td>{{ person.startdate }}</td>
|
|
||||||
<td>{{ person.enddate }}</td>
|
|
||||||
<td>
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li><button class="sc-button bt-show"></button></li>
|
|
||||||
<li><button class="sc-button bt-update"></button></li>
|
|
||||||
<li><button class="sc-button bt-delete" @click.prevent="$emit('remove', person)"></button></li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'PersonItem',
|
|
||||||
props: {
|
|
||||||
person: { type: Object, required: true }
|
|
||||||
},
|
|
||||||
emits: ['remove']
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,69 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="vue-component">
|
|
||||||
<h3>Usagers concernés</h3>
|
|
||||||
|
|
||||||
<label>{{ counter }} usagers</label>
|
|
||||||
|
|
||||||
<table class="rounded">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="chill-orange">firstname</th>
|
|
||||||
<th class="chill-orange">lastname</th>
|
|
||||||
<th class="chill-orange">startdate</th>
|
|
||||||
<th class="chill-orange">enddate</th>
|
|
||||||
<th class="chill-orange">actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<person-item
|
|
||||||
v-for="person in persons_associated"
|
|
||||||
v-bind:person="person"
|
|
||||||
v-bind:key="person.id"
|
|
||||||
@remove="removePerson" />
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li><button class="sc-button bt-create" @click="addPerson">Ajouter un usager</button></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import PersonItem from "./PersonItem.vue"
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'PersonsAssociated',
|
|
||||||
components: {
|
|
||||||
PersonItem
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
persons_associated: Array
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
persons: this.persons_associated
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
async counter() {
|
|
||||||
// Pourquoi je peux pas compter un tableau avec length ???!!!
|
|
||||||
return this.persons_associated.length // <= boum !
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addPerson() {
|
|
||||||
this.persons_associated.push({
|
|
||||||
"firstname": "Lisa",
|
|
||||||
"lastname": "Simpson",
|
|
||||||
"startdate": "1975-09-15",
|
|
||||||
"enddate": "2021-04-20"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
removePerson(item) {
|
|
||||||
this.persons_associated = this.persons_associated.filter(person => person !== item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,16 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="vue-component">
|
|
||||||
<h3>Demandeur</h3>
|
|
||||||
{{ accompanying_course.id }}
|
|
||||||
{{ accompanying_course.remark }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'Requestor',
|
|
||||||
props: {
|
|
||||||
accompanying_course: Object
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,8 +0,0 @@
|
|||||||
import App from './App.vue';
|
|
||||||
import { createApp } from 'vue';
|
|
||||||
|
|
||||||
const app = createApp({
|
|
||||||
template: `<app></app>`
|
|
||||||
})
|
|
||||||
.component('app', App)
|
|
||||||
.mount('#accompanying-course');
|
|
@@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
import Vue from 'vue'
|
||||||
|
import VueResource from 'vue-resource'
|
||||||
|
|
||||||
|
Vue.use(VueResource);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
template: '#vue-usagers',
|
||||||
|
delimiters: ['${', '}'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
persons_associated: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
root: 'http://localhost:8001/fr/api'
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addPerson(){
|
||||||
|
this.persons_associated.persons.push({"firstname": "Lisa", "lastname": "Simpson", "startdate": "1975-09-15", "enddate": "2021-04-20" })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
counter() {
|
||||||
|
return this.persons_associated.persons.length;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$resource('parcours/270/show').get().then((response) => {
|
||||||
|
this.persons_associated = response.data
|
||||||
|
}, (response) => {
|
||||||
|
console.log('erreur', response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
import Vue from 'vue'
|
||||||
|
import VueResource from 'vue-resource'
|
||||||
|
|
||||||
|
Vue.use(VueResource)
|
||||||
|
|
||||||
|
export default {
|
||||||
|
template: '#vue-usagers',
|
||||||
|
delimiters: ['${', '}'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
persons_associated: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
root: 'http://localhost:8001/fr/api'
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addPerson(){
|
||||||
|
this.persons_associated.persons.push({"firstname": "Lisa", "lastname": "Simpson", "startdate": "1975-09-15", "enddate": "2021-04-20" })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
counter() {
|
||||||
|
return this.persons_associated.persons.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$resource('parcours/270/show').get().then((response) => {
|
||||||
|
this.persons_associated = response.data
|
||||||
|
}, (response) => {
|
||||||
|
console.log('erreur', response);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,7 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import App from './AccompanyingCourse.vue'
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
el: '#app',
|
||||||
|
render: h => h(App)
|
||||||
|
});
|
@@ -8,12 +8,81 @@
|
|||||||
|
|
||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
<div id="accompanying-course"></div>
|
{#
|
||||||
|
<pre>
|
||||||
|
{{ accompanyingCourse.id }}
|
||||||
|
{{ accompanyingCourse.openingDate|format_date('short') }}
|
||||||
|
{{ accompanyingCourse.closingDate|format_date('short') }}
|
||||||
|
{{ accompanyingCourse.closingMotive|chill_entity_render_box }}
|
||||||
|
{{ accompanyingCourse.remark|raw }}
|
||||||
|
{{ accompanyingCourse.user }}
|
||||||
|
usagers:
|
||||||
|
{% for p in accompanyingCourse.participations %}
|
||||||
|
{{ p.person.id }} | <a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">{{ p.person.fullnamecanonical }}</a> | {{ p.startdate|format_date('short') }} | {{ p.enddate|format_date('short') }}
|
||||||
|
{% endfor %}
|
||||||
|
</pre>
|
||||||
|
{{ dump() }}
|
||||||
|
{% verbatim %}{% endverbatim %}
|
||||||
|
#}
|
||||||
|
|
||||||
|
<div id="app" course-id="{{ accompanyingCourse.id }}"></div>
|
||||||
|
|
||||||
|
<template id="accompanying" type="text/x-template">
|
||||||
|
<div class="vue-component">
|
||||||
|
<persons_associated></persons_associated>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template id="vue-usagers" type="text/x-template">
|
||||||
|
<div class="vue-component">
|
||||||
|
<h3>Usagers concernés</h3>
|
||||||
|
<dl>
|
||||||
|
<dt>id</dt>
|
||||||
|
<dd>${ persons_associated.id }</dd>
|
||||||
|
<dt>opening_date</dt>
|
||||||
|
<dd>${ persons_associated.opening_date }</dd>
|
||||||
|
<dt>closing_date</dt>
|
||||||
|
<dd>${ persons_associated.closing_date }</dd>
|
||||||
|
<dt>remarkzzzzz</dt>
|
||||||
|
<dd>${ persons_associated.remark }</dd>
|
||||||
|
<dt>closing_motive</dt>
|
||||||
|
<dd>${ persons_associated.closing_motive }</dd>
|
||||||
|
</dl>
|
||||||
|
<label>${counter} usagers concernés</label>
|
||||||
|
<table class="rounded">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="chill-orange">firstname</th>
|
||||||
|
<th class="chill-orange">lastname</th>
|
||||||
|
<th class="chill-orange">startdate</th>
|
||||||
|
<th class="chill-orange">enddate</th>
|
||||||
|
<th class="chill-orange">actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="person in persons_associated.persons">
|
||||||
|
<td>${ person.firstname }</td>
|
||||||
|
<td>${ person.lastname }</td>
|
||||||
|
<td>${ person.startdate }</td>
|
||||||
|
<td>${ person.enddate }</td>
|
||||||
|
<td>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li><a class="sc-button bt-show"></a></li>
|
||||||
|
<li><a class="sc-button bt-update"></a></li>
|
||||||
|
<li><a class="sc-button bt-delete"></a></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<button class="sc-button bt-create" @click="addPerson">Add Person</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
{{ encore_entry_script_tags('accompanying_course') }}
|
{{ encore_entry_script_tags('accompanying_course') }}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
<span class="chill-entity chill-entity__person">
|
|
||||||
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
|
|
||||||
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
|
|
||||||
<span class="chill-entity__person__first-name">{{ person.firstName }}</span>
|
|
||||||
<span class="chill-entity__person__last-name">{{ person.lastName }}</span>
|
|
||||||
{%- if addAltNames -%}
|
|
||||||
{%- for n in person.altNames -%}
|
|
||||||
{%- if loop.first -%}({% else %} {%- endif -%}
|
|
||||||
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
|
|
||||||
{{ n.label }}
|
|
||||||
</span>
|
|
||||||
{%- if loop.last %}) {% endif -%}
|
|
||||||
{%- endfor -%}
|
|
||||||
{%- endif -%}
|
|
||||||
{%- if showLink is defined -%}</a>{%- endif -%}</span>
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user