mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-17 20:24:58 +00:00
Compare commits
8 Commits
rector/rul
...
upgrade/sy
Author | SHA1 | Date | |
---|---|---|---|
13bc9683fb
|
|||
958e2b5cf2
|
|||
f7ed390c96
|
|||
217ce99851
|
|||
efaa01f4f6
|
|||
f04ef9c931
|
|||
9252e92da0
|
|||
4ab4554e63
|
35
.env.test
35
.env.test
@@ -3,3 +3,38 @@
|
|||||||
# Run tests from root to adapt your own environment
|
# Run tests from root to adapt your own environment
|
||||||
KERNEL_CLASS='App\Kernel'
|
KERNEL_CLASS='App\Kernel'
|
||||||
APP_SECRET='$ecretf0rt3st'
|
APP_SECRET='$ecretf0rt3st'
|
||||||
|
|
||||||
|
ADMIN_PASSWORD=admin
|
||||||
|
|
||||||
|
LOCALE=fr
|
||||||
|
REDIS_URL=redis
|
||||||
|
REDIS_PORT=6379
|
||||||
|
REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}
|
||||||
|
|
||||||
|
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
|
||||||
|
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
|
||||||
|
JWT_PASSPHRASE=2a30f6ba26521a2613821da35f28386e
|
||||||
|
|
||||||
|
TWILIO_SID=~
|
||||||
|
TWILIO_SECRET=~
|
||||||
|
DEFAULT_CARRIER_CODE=BE
|
||||||
|
|
||||||
|
ADD_ADDRESS_DEFAULT_COUNTRY=BE
|
||||||
|
|
||||||
|
ADD_ADDRESS_MAP_CENTER_X=50.8443
|
||||||
|
ADD_ADDRESS_MAP_CENTER_Y=4.3523
|
||||||
|
ADD_ADDRESS_MAP_CENTER_Z=15
|
||||||
|
|
||||||
|
SHORT_MESSAGE_DSN=null://null
|
||||||
|
MESSENGER_TRANSPORT_DSN=sync://
|
||||||
|
###< symfony/messenger ###
|
||||||
|
|
||||||
|
###> doctrine/doctrine-bundle ###
|
||||||
|
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
|
||||||
|
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
|
||||||
|
#
|
||||||
|
DATABASE_URL="postgresql://postgres:postgres@db:5432/test?serverVersion=14&charset=utf8"
|
||||||
|
|
||||||
|
ASYNC_UPLOAD_TEMP_URL_KEY=
|
||||||
|
ASYNC_UPLOAD_TEMP_URL_BASE_PATH=
|
||||||
|
ASYNC_UPLOAD_TEMP_URL_CONTAINER=
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
# Select what we should cache between builds
|
# Select what we should cache between builds
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- tests/app/vendor/
|
|
||||||
- .cache
|
- .cache
|
||||||
|
|
||||||
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
||||||
@@ -28,7 +27,7 @@ variables:
|
|||||||
REDIS_PORT: 6379
|
REDIS_PORT: 6379
|
||||||
REDIS_URL: redis://redis:6379
|
REDIS_URL: redis://redis:6379
|
||||||
# change vendor dir to make the app install into tests/apps
|
# change vendor dir to make the app install into tests/apps
|
||||||
COMPOSER_VENDOR_DIR: tests/app/vendor
|
#COMPOSER_VENDOR_DIR: /vendor
|
||||||
DEFAULT_CARRIER_CODE: BE
|
DEFAULT_CARRIER_CODE: BE
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
@@ -49,7 +48,7 @@ build:
|
|||||||
expire_in: 30 min
|
expire_in: 30 min
|
||||||
paths:
|
paths:
|
||||||
- bin
|
- bin
|
||||||
- tests/app/vendor/
|
- vendor/
|
||||||
|
|
||||||
code_style:
|
code_style:
|
||||||
stage: Tests
|
stage: Tests
|
||||||
@@ -63,7 +62,7 @@ code_style:
|
|||||||
expire_in: 30 min
|
expire_in: 30 min
|
||||||
paths:
|
paths:
|
||||||
- bin
|
- bin
|
||||||
- tests/app/vendor/
|
- vendor/
|
||||||
|
|
||||||
phpstan_tests:
|
phpstan_tests:
|
||||||
stage: Tests
|
stage: Tests
|
||||||
@@ -77,7 +76,7 @@ phpstan_tests:
|
|||||||
expire_in: 30 min
|
expire_in: 30 min
|
||||||
paths:
|
paths:
|
||||||
- bin
|
- bin
|
||||||
- tests/app/vendor/
|
- vendor/
|
||||||
|
|
||||||
rector_tests:
|
rector_tests:
|
||||||
stage: Tests
|
stage: Tests
|
||||||
@@ -91,7 +90,7 @@ rector_tests:
|
|||||||
expire_in: 30 min
|
expire_in: 30 min
|
||||||
paths:
|
paths:
|
||||||
- bin
|
- bin
|
||||||
- tests/app/vendor/
|
- vendor/
|
||||||
|
|
||||||
# psalm_tests:
|
# psalm_tests:
|
||||||
# stage: Tests
|
# stage: Tests
|
||||||
@@ -111,13 +110,12 @@ unit_tests:
|
|||||||
# until we fix testes
|
# until we fix testes
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- php tests/app/bin/console doctrine:migrations:migrate -n
|
- php tests/console doctrine:migrations:migrate -n
|
||||||
- php -d memory_limit=2G tests/app/bin/console cache:clear --env=dev
|
- php -d memory_limit=3G tests/console doctrine:fixtures:load -n
|
||||||
- php -d memory_limit=3G tests/app/bin/console doctrine:fixtures:load -n
|
- php -d memory_limit=2G tests/console cache:clear --env=test
|
||||||
- php -d memory_limit=2G tests/app/bin/console cache:clear --env=test
|
|
||||||
- php -d memory_limit=4G bin/phpunit --colors=never
|
- php -d memory_limit=4G bin/phpunit --colors=never
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 30 min
|
expire_in: 30 min
|
||||||
paths:
|
paths:
|
||||||
- bin
|
- bin
|
||||||
- tests/app/vendor/
|
- vendor/
|
||||||
|
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
|
|
||||||
|
@@ -107,7 +107,7 @@
|
|||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "tests/app/src/",
|
"App\\": "tests/",
|
||||||
"Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests",
|
"Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests",
|
||||||
"Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests"
|
"Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests"
|
||||||
}
|
}
|
||||||
@@ -123,12 +123,10 @@
|
|||||||
},
|
},
|
||||||
"bin-dir": "bin",
|
"bin-dir": "bin",
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"sort-packages": true,
|
"sort-packages": true
|
||||||
"vendor-dir": "tests/app/vendor"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"auto-scripts": {
|
"auto-scripts": {
|
||||||
"assets:install %PUBLIC_DIR%": "symfony-cmd",
|
|
||||||
"cache:clear": "symfony-cmd"
|
"cache:clear": "symfony-cmd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="tests/app/vendor/phpunit/phpunit/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
backupGlobals="false"
|
backupGlobals="false"
|
||||||
colors="true"
|
colors="true"
|
||||||
bootstrap="tests/app/tests/bootstrap.php"
|
bootstrap="tests/bootstrap.php"
|
||||||
>
|
>
|
||||||
<php>
|
<php>
|
||||||
<ini name="error_reporting" value="-1" />
|
<ini name="error_reporting" value="-1" />
|
||||||
|
@@ -12,6 +12,8 @@ return static function (RectorConfig $rectorConfig): void {
|
|||||||
__DIR__ . '/src',
|
__DIR__ . '/src',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/testsApp_KernelDevDebugContainer.xml');
|
||||||
|
|
||||||
//$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class);
|
//$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class);
|
||||||
//$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector');
|
//$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector');
|
||||||
|
|
||||||
@@ -21,7 +23,8 @@ return static function (RectorConfig $rectorConfig): void {
|
|||||||
|
|
||||||
//define sets of rules
|
//define sets of rules
|
||||||
$rectorConfig->sets([
|
$rectorConfig->sets([
|
||||||
LevelSetList::UP_TO_PHP_82
|
LevelSetList::UP_TO_PHP_82,
|
||||||
|
\Rector\Symfony\Set\SymfonySetList::SYMFONY_44,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// skip some path...
|
// skip some path...
|
||||||
|
@@ -67,7 +67,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
|||||||
->setPerson($person)
|
->setPerson($person)
|
||||||
->setDate($this->faker->dateTimeThisYear())
|
->setDate($this->faker->dateTimeThisYear())
|
||||||
->setDurationTime($this->faker->dateTime(36000))
|
->setDurationTime($this->faker->dateTime(36000))
|
||||||
->setType($this->getRandomActivityType())
|
->setActivityType($this->getRandomActivityType())
|
||||||
->setScope($this->getRandomScope());
|
->setScope($this->getRandomScope());
|
||||||
|
|
||||||
// ->setAttendee($this->faker->boolean())
|
// ->setAttendee($this->faker->boolean())
|
||||||
|
@@ -672,7 +672,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated use @link{self::setActivityType} instead
|
||||||
*/
|
*/
|
||||||
public function setType(ActivityType $activityType): self
|
public function setType(ActivityType $activityType): self
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,7 @@ final readonly class CategoryRender implements ChillEntityRenderInterface
|
|||||||
|
|
||||||
public const SEPERATOR_KEY = 'default.separator';
|
public const SEPERATOR_KEY = 'default.separator';
|
||||||
|
|
||||||
public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine)
|
public function __construct(private TranslatableStringHelper $translatableStringHelper, private \Twig\Environment $engine)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ use Symfony\Component\Templating\EngineInterface;
|
|||||||
*/
|
*/
|
||||||
final readonly class BudgetElementTypeRender implements ChillEntityRenderInterface
|
final readonly class BudgetElementTypeRender implements ChillEntityRenderInterface
|
||||||
{
|
{
|
||||||
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private EngineInterface $engine)
|
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private \Twig\Environment $engine)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@ class AzureGrantAdminConsentAndAcquireToken extends Command
|
|||||||
parent::__construct('chill:calendar:msgraph-grant-admin-consent');
|
parent::__construct('chill:calendar:msgraph-grant-admin-consent');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
/** @var FormatterHelper $formatter */
|
/** @var FormatterHelper $formatter */
|
||||||
$formatter = $this->getHelper('formatter');
|
$formatter = $this->getHelper('formatter');
|
||||||
|
@@ -35,7 +35,7 @@ class SendShortMessageOnEligibleCalendar extends Command
|
|||||||
return 'chill:calendar:send-short-messages';
|
return 'chill:calendar:send-short-messages';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->messageSender->sendBulkMessageToEligibleCalendars();
|
$this->messageSender->sendBulkMessageToEligibleCalendars();
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ use UnexpectedValueException;
|
|||||||
|
|
||||||
class CalendarDocController
|
class CalendarDocController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EngineInterface $engine, private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator)
|
public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly \Twig\Environment $engine, private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ class RemoteEventConverter
|
|||||||
private readonly DateTimeZone $remoteDateTimeZone;
|
private readonly DateTimeZone $remoteDateTimeZone;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EngineInterface $engine,
|
private readonly \Twig\Environment $engine,
|
||||||
private readonly LocationConverter $locationConverter,
|
private readonly LocationConverter $locationConverter,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
private readonly PersonRenderInterface $personRender,
|
private readonly PersonRenderInterface $personRender,
|
||||||
|
@@ -24,7 +24,7 @@ use Symfony\Component\Templating\EngineInterface;
|
|||||||
|
|
||||||
class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface
|
class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EngineInterface $engine)
|
public function __construct(private readonly \Twig\Environment $engine)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,9 +97,9 @@ final class CalendarTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$calendar = new Calendar();
|
$calendar = new Calendar();
|
||||||
$calendar->setMainUser(new class () extends User {
|
$calendar->setMainUser(new class () extends User {
|
||||||
public function getId()
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return '1';
|
return 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ final class AddressConverterTest extends TestCase
|
|||||||
|
|
||||||
private function buildAddressConverter(): AddressConverter
|
private function buildAddressConverter(): AddressConverter
|
||||||
{
|
{
|
||||||
$engine = $this->prophesize(EngineInterface::class);
|
$engine = $this->prophesize(\Twig\Environment::class);
|
||||||
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||||
$translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided');
|
$translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided');
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ final class DefaultShortMessageForCalendarBuilderTest extends TestCase
|
|||||||
->setMobilenumber($this->phoneNumberUtil->parse('+32470123456', 'BE'))
|
->setMobilenumber($this->phoneNumberUtil->parse('+32470123456', 'BE'))
|
||||||
->setAcceptSMS(false);
|
->setAcceptSMS(false);
|
||||||
|
|
||||||
$engine = $this->prophesize(EngineInterface::class);
|
$engine = $this->prophesize(\Twig\Environment::class);
|
||||||
$engine->render(Argument::exact('@ChillCalendar/CalendarShortMessage/short_message.txt.twig'), Argument::withKey('calendar'))
|
$engine->render(Argument::exact('@ChillCalendar/CalendarShortMessage/short_message.txt.twig'), Argument::withKey('calendar'))
|
||||||
->willReturn('message content')
|
->willReturn('message content')
|
||||||
->shouldBeCalledTimes(1);
|
->shouldBeCalledTimes(1);
|
||||||
|
@@ -85,10 +85,7 @@ class CreateFieldsOnGroupCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
* @return int|void|null
|
|
||||||
*/
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
|
||||||
{
|
{
|
||||||
$helper = $this->getHelperSet()->get('question');
|
$helper = $this->getHelperSet()->get('question');
|
||||||
|
|
||||||
@@ -138,6 +135,7 @@ class CreateFieldsOnGroupCommand extends Command
|
|||||||
);
|
);
|
||||||
|
|
||||||
$fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output);
|
$fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output)
|
private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output)
|
||||||
|
@@ -35,7 +35,7 @@ class CustomFieldLongChoice extends AbstractCustomField
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly OptionRepository $optionRepository,
|
private readonly OptionRepository $optionRepository,
|
||||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||||
private readonly EngineInterface $templating,
|
private readonly \Twig\Environment $templating,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ class EventSearch extends AbstractSearch
|
|||||||
TokenStorageInterface $tokenStorage,
|
TokenStorageInterface $tokenStorage,
|
||||||
private readonly EntityRepository $er,
|
private readonly EntityRepository $er,
|
||||||
private readonly AuthorizationHelper $helper,
|
private readonly AuthorizationHelper $helper,
|
||||||
private readonly TemplatingEngine $templating,
|
private readonly \Twig\Environment $templating,
|
||||||
private readonly PaginatorFactory $paginationFactory
|
private readonly PaginatorFactory $paginationFactory
|
||||||
) {
|
) {
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
|
@@ -198,7 +198,7 @@ class ChillImportUsersCommand extends Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->tempOutput = $output;
|
$this->tempOutput = $output;
|
||||||
$this->tempInput = $input;
|
$this->tempInput = $input;
|
||||||
@@ -218,6 +218,7 @@ class ChillImportUsersCommand extends Command
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -101,7 +101,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
|
|||||||
->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Subject of the email', 'Recover your password');
|
->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Subject of the email', 'Recover your password');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
@@ -119,6 +119,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command
|
|||||||
|
|
||||||
$this->sendRecoverCode($user);
|
$this->sendRecoverCode($user);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -34,7 +34,7 @@ class ExecuteCronJobCommand extends Command
|
|||||||
->addUsage('');
|
->addUsage('');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
if ([] === $input->getArgument('job')) {
|
if ([] === $input->getArgument('job')) {
|
||||||
$this->cronManager->run();
|
$this->cronManager->run();
|
||||||
|
@@ -80,7 +80,7 @@ class LoadAndUpdateLanguagesCommand extends Command
|
|||||||
*
|
*
|
||||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
$chillAvailableLanguages = $this->availableLanguages;
|
$chillAvailableLanguages = $this->availableLanguages;
|
||||||
@@ -130,5 +130,6 @@ class LoadAndUpdateLanguagesCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ use Doctrine\ORM\EntityManager;
|
|||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Intl\Countries;
|
||||||
use Symfony\Component\Intl\Intl;
|
use Symfony\Component\Intl\Intl;
|
||||||
|
|
||||||
class LoadCountriesCommand extends Command
|
class LoadCountriesCommand extends Command
|
||||||
@@ -32,11 +33,10 @@ class LoadCountriesCommand extends Command
|
|||||||
|
|
||||||
public static function prepareCountryList($languages)
|
public static function prepareCountryList($languages)
|
||||||
{
|
{
|
||||||
$regionBundle = Intl::getRegionBundle();
|
|
||||||
$countries = [];
|
$countries = [];
|
||||||
|
|
||||||
foreach ($languages as $language) {
|
foreach ($languages as $language) {
|
||||||
$countries[$language] = $regionBundle->getCountryNames($language);
|
$countries[$language] = Countries::getNames([$language]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$countryEntities = [];
|
$countryEntities = [];
|
||||||
@@ -73,7 +73,7 @@ class LoadCountriesCommand extends Command
|
|||||||
*
|
*
|
||||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$countries = static::prepareCountryList($this->availableLanguages);
|
$countries = static::prepareCountryList($this->availableLanguages);
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
@@ -90,5 +90,7 @@ class LoadCountriesCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ class LoadPostalCodesCommand extends Command
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$csv = $this->getCSVResource($input);
|
$csv = $this->getCSVResource($input);
|
||||||
|
|
||||||
@@ -105,6 +105,7 @@ class LoadPostalCodesCommand extends Command
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$output->writeln('<info>' . $num . ' were added !</info>');
|
$output->writeln('<info>' . $num . ' were added !</info>');
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addPostalCode($row, OutputInterface $output)
|
private function addPostalCode($row, OutputInterface $output)
|
||||||
|
@@ -63,7 +63,7 @@ class SetPasswordCommand extends Command
|
|||||||
->addArgument('password', InputArgument::OPTIONAL, 'the new password');
|
->addArgument('password', InputArgument::OPTIONAL, 'the new password');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output)
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$user = $this->_getUser($input->getArgument('username'));
|
$user = $this->_getUser($input->getArgument('username'));
|
||||||
|
|
||||||
@@ -81,5 +81,6 @@ class SetPasswordCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->_setPassword($user, $password);
|
$this->_setPassword($user, $password);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -529,7 +529,7 @@ class PermissionsGroupController extends AbstractController
|
|||||||
static fn (Role $role) => $role->getRole(),
|
static fn (Role $role) => $role->getRole(),
|
||||||
$this->roleHierarchy
|
$this->roleHierarchy
|
||||||
->getReachableRoles(
|
->getReachableRoles(
|
||||||
[new Role($roleScope->getRole())]
|
[$roleScope->getRole()]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ use function count;
|
|||||||
|
|
||||||
class SavedExportController
|
class SavedExportController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EngineInterface $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator)
|
public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\Intl\Intl;
|
use Symfony\Component\Intl\Intl;
|
||||||
|
|
||||||
|
use Symfony\Component\Intl\Languages;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,9 +47,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
|
|||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
echo "loading languages... \n";
|
foreach (Languages::getLanguageCodes() as $code) {
|
||||||
|
|
||||||
foreach (Intl::getLanguageBundle()->getLanguageNames() as $code => $language) {
|
|
||||||
if (
|
if (
|
||||||
!in_array($code, $this->regionalVersionToInclude, true)
|
!in_array($code, $this->regionalVersionToInclude, true)
|
||||||
&& !in_array($code, $this->ancientToExclude, true)
|
&& !in_array($code, $this->ancientToExclude, true)
|
||||||
@@ -78,7 +77,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
|
|||||||
$names = [];
|
$names = [];
|
||||||
|
|
||||||
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
|
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
|
||||||
$names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
|
$names[$lang] = Languages::getName($languageCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $names;
|
return $names;
|
||||||
|
@@ -12,8 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Form\Event;
|
namespace Chill\MainBundle\Form\Event;
|
||||||
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
|
class CustomizeFormEvent extends Event
|
||||||
{
|
{
|
||||||
final public const NAME = 'chill_main.customize_form';
|
final public const NAME = 'chill_main.customize_form';
|
||||||
|
|
||||||
|
@@ -69,6 +69,8 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
*
|
*
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
*
|
||||||
|
* @deprecated use @link{\Chill\MainBundle\Form\Type\ScopePickerType:class} instead
|
||||||
*/
|
*/
|
||||||
trait AppendScopeChoiceTypeTrait
|
trait AppendScopeChoiceTypeTrait
|
||||||
{
|
{
|
||||||
@@ -97,7 +99,7 @@ trait AppendScopeChoiceTypeTrait
|
|||||||
*/
|
*/
|
||||||
protected function appendScopeChoices(
|
protected function appendScopeChoices(
|
||||||
FormBuilderInterface $builder,
|
FormBuilderInterface $builder,
|
||||||
Role $role,
|
string $role,
|
||||||
Center $center,
|
Center $center,
|
||||||
User $user,
|
User $user,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
|
@@ -52,7 +52,7 @@ class ScopePickerType extends AbstractType
|
|||||||
array_filter(
|
array_filter(
|
||||||
$this->authorizationHelper->getReachableScopes(
|
$this->authorizationHelper->getReachableScopes(
|
||||||
$this->security->getUser(),
|
$this->security->getUser(),
|
||||||
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
|
$options['role'],
|
||||||
$options['center']
|
$options['center']
|
||||||
),
|
),
|
||||||
static fn (Scope $s) => $s->isActive()
|
static fn (Scope $s) => $s->isActive()
|
||||||
@@ -92,6 +92,6 @@ class ScopePickerType extends AbstractType
|
|||||||
->setAllowedTypes('center', [Center::class, 'array', 'null'])
|
->setAllowedTypes('center', [Center::class, 'array', 'null'])
|
||||||
// create ``role` option
|
// create ``role` option
|
||||||
->setRequired('role')
|
->setRequired('role')
|
||||||
->setAllowedTypes('role', ['string', Role::class]);
|
->setAllowedTypes('role', ['string']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,7 @@ class UserPickerType extends AbstractType
|
|||||||
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class, 'null', 'array'])
|
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class, 'null', 'array'])
|
||||||
// create ``role` option
|
// create ``role` option
|
||||||
->setRequired('role')
|
->setRequired('role')
|
||||||
->setAllowedTypes('role', ['string', \Symfony\Component\Security\Core\Role\Role::class]);
|
->setAllowedTypes('role', ['string']);
|
||||||
|
|
||||||
$resolver
|
$resolver
|
||||||
->setDefault('having_permissions_group_flag', null)
|
->setDefault('having_permissions_group_flag', null)
|
||||||
|
@@ -40,7 +40,7 @@ class Mailer
|
|||||||
* @param $routeParameters
|
* @param $routeParameters
|
||||||
* @param mixed[] $routeParameters
|
* @param mixed[] $routeParameters
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly EngineInterface $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters)
|
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly \Twig\Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -133,11 +133,11 @@ final class NotificationRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
$query = $this->queryByAddressee($addressee)->select('n');
|
$query = $this->queryByAddressee($addressee)->select('n');
|
||||||
|
|
||||||
if ($limit) {
|
if (null !== $limit) {
|
||||||
$query = $query->setMaxResults($limit);
|
$query = $query->setMaxResults($limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($offset) {
|
if (null !== $offset) {
|
||||||
$query = $query->setFirstResult($offset);
|
$query = $query->setFirstResult($offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,8 +34,13 @@ use function get_class;
|
|||||||
*/
|
*/
|
||||||
class AuthorizationHelper implements AuthorizationHelperInterface
|
class AuthorizationHelper implements AuthorizationHelperInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly CenterResolverManagerInterface $centerResolverManager, private readonly LoggerInterface $logger, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly UserACLAwareRepositoryInterface $userACLAwareRepository, private readonly ParentRoleHelper $parentRoleHelper)
|
public function __construct(
|
||||||
{
|
private readonly CenterResolverManagerInterface $centerResolverManager,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
private readonly ScopeResolverDispatcher $scopeResolverDispatcher,
|
||||||
|
private readonly UserACLAwareRepositoryInterface $userACLAwareRepository,
|
||||||
|
private readonly ParentRoleHelper $parentRoleHelper
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,10 +99,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
|
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user instanceof User) {
|
if (!$user instanceof User) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -132,10 +133,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
/**
|
/**
|
||||||
* Return all reachable circle for a given user, center and role.
|
* Return all reachable circle for a given user, center and role.
|
||||||
*
|
*
|
||||||
* @param Center|Center[] $center
|
* @param Center|array<Center> $center
|
||||||
* @return Scope[]
|
* @return Scope[]
|
||||||
*/
|
*/
|
||||||
public function getReachableCircles(UserInterface $user, \Symfony\Component\Security\Core\Role\Role|string $role, \Chill\MainBundle\Entity\Center|array $center)
|
public function getReachableCircles(UserInterface $user, string $role, \Chill\MainBundle\Entity\Center|array $center): array
|
||||||
{
|
{
|
||||||
$scopes = [];
|
$scopes = [];
|
||||||
|
|
||||||
@@ -223,11 +224,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
* the scope is taken into account.
|
* the scope is taken into account.
|
||||||
*
|
*
|
||||||
* @param mixed $entity the entity may also implement HasScopeInterface
|
* @param mixed $entity the entity may also implement HasScopeInterface
|
||||||
* @param Role|string $attribute
|
|
||||||
*
|
|
||||||
* @return bool true if the user has access
|
|
||||||
*/
|
*/
|
||||||
public function userHasAccess(User $user, mixed $entity, \Symfony\Component\Security\Core\Role\Role|string $attribute)
|
public function userHasAccess(User $user, mixed $entity, string $attribute): bool
|
||||||
{
|
{
|
||||||
$centers = $this->centerResolverManager->resolveCenters($entity);
|
$centers = $this->centerResolverManager->resolveCenters($entity);
|
||||||
|
|
||||||
@@ -248,7 +246,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
|||||||
*
|
*
|
||||||
* @return bool true if the child role is granted by parent role
|
* @return bool true if the child role is granted by parent role
|
||||||
*/
|
*/
|
||||||
private function isRoleReached(string $childRole, string $parentRole)
|
private function isRoleReached(string $childRole, string $parentRole): bool
|
||||||
{
|
{
|
||||||
return $this->parentRoleHelper->isRoleReached($childRole, $parentRole);
|
return $this->parentRoleHelper->isRoleReached($childRole, $parentRole);
|
||||||
}
|
}
|
||||||
|
@@ -14,12 +14,16 @@ namespace Chill\MainBundle\Security\Authorization;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
|
|
||||||
final readonly class DefaultVoterHelper implements VoterHelperInterface
|
final readonly class DefaultVoterHelper implements VoterHelperInterface
|
||||||
{
|
{
|
||||||
public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private array $configuration)
|
public function __construct(
|
||||||
{
|
private AuthorizationHelper $authorizationHelper,
|
||||||
|
private CenterResolverManagerInterface $centerResolverDispatcher,
|
||||||
|
private array $configuration
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports($attribute, $subject): bool
|
public function supports($attribute, $subject): bool
|
||||||
|
@@ -12,11 +12,14 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Security\Authorization;
|
namespace Chill\MainBundle\Security\Authorization;
|
||||||
|
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||||
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
|
|
||||||
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
|
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
|
||||||
{
|
{
|
||||||
public function __construct(protected AuthorizationHelper $authorizationHelper, protected CenterResolverDispatcherInterface $centerResolverDispatcher)
|
public function __construct(
|
||||||
{
|
protected AuthorizationHelper $authorizationHelper,
|
||||||
|
protected CenterResolverManagerInterface $centerResolverDispatcher
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generate($context): VoterGeneratorInterface
|
public function generate($context): VoterGeneratorInterface
|
||||||
|
@@ -12,13 +12,16 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Security\Authorization;
|
namespace Chill\MainBundle\Security\Authorization;
|
||||||
|
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||||
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
|
|
||||||
final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
|
final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
|
||||||
{
|
{
|
||||||
private array $configuration = [];
|
private array $configuration = [];
|
||||||
|
|
||||||
public function __construct(private readonly AuthorizationHelper $authorizationHelper, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher)
|
public function __construct(
|
||||||
{
|
private readonly AuthorizationHelper $authorizationHelper,
|
||||||
|
private readonly CenterResolverManagerInterface $centerResolverDispatcher
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addCheckFor(?string $subject, array $attributes): self
|
public function addCheckFor(?string $subject, array $attributes): self
|
||||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Security\PasswordRecover;
|
namespace Chill\MainBundle\Security\PasswordRecover;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class PasswordRecoverEvent extends Event
|
class PasswordRecoverEvent extends Event
|
||||||
{
|
{
|
||||||
|
@@ -64,7 +64,6 @@ class RollingDate
|
|||||||
final public const T_YEAR_PREVIOUS_START = 'year_previous_start';
|
final public const T_YEAR_PREVIOUS_START = 'year_previous_start';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $roll
|
|
||||||
* @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE}
|
* @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE}
|
||||||
* @param DateTimeImmutable $pivotDate Will be "now" if null is given
|
* @param DateTimeImmutable $pivotDate Will be "now" if null is given
|
||||||
*/
|
*/
|
||||||
|
@@ -59,7 +59,7 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabelReturnPath($default)
|
public function getLabelReturnPath(?string $default = null): string|null
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
|
||||||
@@ -68,21 +68,14 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an url with a returnPath parameter to current page.
|
* Build an url with a returnPath parameter to current page.
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @param array $parameters
|
|
||||||
* @param bool $relative
|
|
||||||
* @param mixed|null $label
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getPathAddReturnPath($name, $parameters = [], $relative = false, $label = null)
|
public function getPathAddReturnPath(string $name, array $parameters = [], bool $relative = false, ?string $label = null): string
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
|
||||||
$parameters['returnPath'] = $request->getRequestUri();
|
$parameters['returnPath'] = $request->getRequestUri();
|
||||||
|
|
||||||
if ($label) {
|
if (null !== $label) {
|
||||||
$parameters['returnPathLabel'] = $label;
|
$parameters['returnPathLabel'] = $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,14 +84,8 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an url with a returnPath parameter to current page.
|
* Build an url with a returnPath parameter to current page.
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @param array $parameters
|
|
||||||
* @param bool $relative
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getPathForwardReturnPath($name, $parameters = [], $relative = false)
|
public function getPathForwardReturnPath(string $name, array $parameters = [], bool $relative = false): string
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
|
||||||
@@ -116,14 +103,8 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the return path if it exists, or generate the path if not.
|
* Return the return path if it exists, or generate the path if not.
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* @param array $parameters
|
|
||||||
* @param bool $relative
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getReturnPathOr($name, $parameters = [], $relative = false)
|
public function getReturnPathOr(string $name, array $parameters = [], bool $relative = false): string
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
|
||||||
@@ -134,7 +115,7 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
return $this->originalExtension->getPath($name, $parameters, $relative);
|
return $this->originalExtension->getPath($name, $parameters, $relative);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUrlGenerationSafe(Node $argsNode)
|
public function isUrlGenerationSafe(Node $argsNode): array|string
|
||||||
{
|
{
|
||||||
return $this->originalExtension->isUrlGenerationSafe($argsNode);
|
return $this->originalExtension->isUrlGenerationSafe($argsNode);
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
'extended_infos' => false,
|
'extended_infos' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private readonly EngineInterface $templating, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
public function __construct(private readonly \Twig\Environment $templating, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ class CommentRender implements ChillEntityRenderInterface
|
|||||||
{
|
{
|
||||||
use BoxUtilsChillEntityRenderTrait;
|
use BoxUtilsChillEntityRenderTrait;
|
||||||
|
|
||||||
public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly EngineInterface $engine)
|
public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly \Twig\Environment $engine)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class UserRender implements ChillEntityRenderInterface
|
|||||||
'absence' => true,
|
'absence' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator)
|
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ namespace Chill\MainBundle\Templating\Events;
|
|||||||
|
|
||||||
use ArrayAccess;
|
use ArrayAccess;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is transmitted on event chill_block.*.
|
* This event is transmitted on event chill_block.*.
|
||||||
|
@@ -220,7 +220,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderComplexAddressBE(Address $addr, string $expectedString): void
|
public function testRenderComplexAddressBE(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderComplexAddressFR(Address $addr, string $expectedString): void
|
public function testRenderComplexAddressFR(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderNoFullAddressBE(Address $addr, string $expectedString): void
|
public function testRenderNoFullAddressBE(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderStringSimpleAddressBE(Address $addr, string $expectedString): void
|
public function testRenderStringSimpleAddressBE(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderStringSimpleAddressFR(Address $addr, string $expectedString): void
|
public function testRenderStringSimpleAddressFR(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderWithBuildingAddressBE(Address $addr, string $expectedString): void
|
public function testRenderWithBuildingAddressBE(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderWithBuildingAddressFR(Address $addr, string $expectedString): void
|
public function testRenderWithBuildingAddressFR(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderWithStepsAddressBE(Address $addr, string $expectedString): void
|
public function testRenderWithStepsAddressBE(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderWithStepsAddressFR(Address $addr, string $expectedString): void
|
public function testRenderWithStepsAddressFR(Address $addr, string $expectedString): void
|
||||||
{
|
{
|
||||||
$engine = self::$container->get(EngineInterface::class);
|
$engine = self::$container->get(\Twig\Environment::class);
|
||||||
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
$renderer = new AddressRender($engine, $translatableStringHelper);
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ final class NotificationOnTransitionTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$engine = $this->prophesize(EngineInterface::class);
|
$engine = $this->prophesize(\Twig\Environment::class);
|
||||||
$engine->render(Argument::type('string'), Argument::type('array'))
|
$engine->render(Argument::type('string'), Argument::type('array'))
|
||||||
->willReturn('dummy text');
|
->willReturn('dummy text');
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ use function in_array;
|
|||||||
|
|
||||||
class NotificationOnTransition implements EventSubscriberInterface
|
class NotificationOnTransition implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry)
|
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly \Twig\Environment $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Workflow\Registry;
|
|||||||
|
|
||||||
class SendAccessKeyEventSubscriber
|
class SendAccessKeyEventSubscriber
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MailerInterface $mailer)
|
public function __construct(private readonly \Twig\Environment $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MailerInterface $mailer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
|
class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator)
|
public function __construct(private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class UserRefEventSubscriber implements EventSubscriberInterface
|
class UserRefEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister)
|
public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Actions;
|
namespace Chill\PersonBundle\Actions;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event triggered when an entity attached to a person is removed.
|
* Event triggered when an entity attached to a person is removed.
|
||||||
|
@@ -63,7 +63,7 @@ final class ChillPersonMoveCommand extends Command
|
|||||||
->addOption('delete-entity', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'entity to delete', []);
|
->addOption('delete-entity', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'entity to delete', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$repository = $this->em->getRepository(Person::class);
|
$repository = $this->em->getRepository(Person::class);
|
||||||
$from = $repository->find($input->getOption('from'));
|
$from = $repository->find($input->getOption('from'));
|
||||||
@@ -100,6 +100,7 @@ final class ChillPersonMoveCommand extends Command
|
|||||||
|
|
||||||
$this->chillLogger->notice('Move a person from command line succeeded', $ctxt);
|
$this->chillLogger->notice('Move a person from command line succeeded', $ctxt);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function interact(InputInterface $input, OutputInterface $output)
|
protected function interact(InputInterface $input, OutputInterface $output)
|
||||||
|
@@ -41,7 +41,7 @@ final class ImportSocialWorkMetadata extends Command
|
|||||||
->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language');
|
->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$filepath = $input->getOption('filepath');
|
$filepath = $input->getOption('filepath');
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ use Chill\PersonBundle\Form\AccompanyingCourseType;
|
|||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@@ -39,7 +39,7 @@ use function is_array;
|
|||||||
/**
|
/**
|
||||||
* Class AccompanyingCourseController.
|
* Class AccompanyingCourseController.
|
||||||
*/
|
*/
|
||||||
class AccompanyingCourseController extends Controller
|
class AccompanyingCourseController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator)
|
public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
@@ -1,483 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Form\AccompanyingPeriodType;
|
|
||||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use DateTime;
|
|
||||||
use Doctrine\DBAL\Exception;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
||||||
|
|
||||||
use function array_filter;
|
|
||||||
use function count;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AccompanyingPeriodController.
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriodController extends AbstractController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var EventDispatcherInterface
|
|
||||||
*/
|
|
||||||
protected $eventDispatcher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ValidatorInterface
|
|
||||||
*/
|
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
protected AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
|
|
||||||
EventDispatcherInterface $eventDispatcher,
|
|
||||||
ValidatorInterface $validator
|
|
||||||
) {
|
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
|
||||||
$this->validator = $validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function closeAction(int $person_id, Request $request): Response
|
|
||||||
{
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person');
|
|
||||||
|
|
||||||
if ($person->isOpen() === false) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('error', $this->get('translator')
|
|
||||||
->trans(
|
|
||||||
'Beware period is closed',
|
|
||||||
['%name%' => $person->__toString()]
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$current = $person->getCurrentAccompanyingPeriod();
|
|
||||||
|
|
||||||
$form = $this->createForm(AccompanyingPeriodType::class, $current, [
|
|
||||||
'period_action' => 'close',
|
|
||||||
'center' => $person->getCenter(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$person->close($current);
|
|
||||||
$errors = $this->_validatePerson($person);
|
|
||||||
|
|
||||||
if (count($errors) === 0) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('success', $this->get('translator')
|
|
||||||
->trans('An accompanying period has been closed.', [
|
|
||||||
'%name%' => $person->__toString(),
|
|
||||||
]));
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('error', $this->get('translator')
|
|
||||||
->trans('Error! Period not closed!'));
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('info', $error->getMessage());
|
|
||||||
}
|
|
||||||
} else { //if form is not valid
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add(
|
|
||||||
'error',
|
|
||||||
$this->get('translator')
|
|
||||||
->trans('Pediod closing form is not valid')
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($form->getErrors() as $error) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('info', $error->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
|
|
||||||
'form' => $form->createView(),
|
|
||||||
'person' => $person,
|
|
||||||
'accompanying_period' => $current,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createAction(int $person_id, Request $request): Response
|
|
||||||
{
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
|
||||||
PersonVoter::UPDATE,
|
|
||||||
$person,
|
|
||||||
'You are not allowed to update this person'
|
|
||||||
);
|
|
||||||
|
|
||||||
$accompanyingPeriod = new AccompanyingPeriod(new DateTime('now'));
|
|
||||||
$accompanyingPeriod->setClosingDate(new DateTime('now'));
|
|
||||||
|
|
||||||
$accompanyingPeriod->addPerson($person);
|
|
||||||
//or $person->addAccompanyingPeriod($accompanyingPeriod);
|
|
||||||
|
|
||||||
$form = $this->createForm(
|
|
||||||
AccompanyingPeriodType::class,
|
|
||||||
$accompanyingPeriod,
|
|
||||||
[
|
|
||||||
'period_action' => 'create',
|
|
||||||
'center' => $person->getCenter(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
$errors = $this->_validatePerson($person);
|
|
||||||
$flashBag = $this->get('session')->getFlashBag();
|
|
||||||
|
|
||||||
if (
|
|
||||||
$form->isValid(['Default', 'closed'])
|
|
||||||
&& count($errors) === 0
|
|
||||||
) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->persist($accompanyingPeriod);
|
|
||||||
$em->flush();
|
|
||||||
$flashBag->add(
|
|
||||||
'success',
|
|
||||||
$this->get('translator')->trans(
|
|
||||||
'A period has been created.'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$flashBag->add('error', $this->get('translator')
|
|
||||||
->trans('Error! Period not created!'));
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$flashBag->add('info', $error->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
|
|
||||||
'form' => $form->createView(),
|
|
||||||
'person' => $person,
|
|
||||||
'accompanying_period' => $accompanyingPeriod,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ParamConverter("person", options={"id": "person_id"})
|
|
||||||
*/
|
|
||||||
public function listAction(Person $person): Response
|
|
||||||
{
|
|
||||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $person);
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
|
||||||
'element_class' => AccompanyingPeriod::class,
|
|
||||||
'action' => 'list',
|
|
||||||
]);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
$accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository
|
|
||||||
->findByPerson($person, AccompanyingPeriodVoter::SEE);
|
|
||||||
|
|
||||||
usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() > $a->getOpeningDate());
|
|
||||||
|
|
||||||
// filter visible or not visible
|
|
||||||
$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [
|
|
||||||
'accompanying_periods' => $accompanyingPeriods,
|
|
||||||
'person' => $person,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function openAction(int $person_id, Request $request): Response
|
|
||||||
{
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
|
||||||
PersonVoter::UPDATE,
|
|
||||||
$person,
|
|
||||||
'You are not allowed to update this person'
|
|
||||||
);
|
|
||||||
|
|
||||||
//in case the person is already open
|
|
||||||
if ($person->isOpen()) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('error', $this->get('translator')
|
|
||||||
->trans(
|
|
||||||
'Error! Period %name% is not closed ; it can be open',
|
|
||||||
['%name%' => $person->__toString()]
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$accompanyingPeriod = new AccompanyingPeriod(new DateTime());
|
|
||||||
|
|
||||||
$form = $this->createForm(
|
|
||||||
AccompanyingPeriodType::class,
|
|
||||||
$accompanyingPeriod,
|
|
||||||
[
|
|
||||||
'period_action' => 'open',
|
|
||||||
'center' => $person->getCenter(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$person->open($accompanyingPeriod);
|
|
||||||
|
|
||||||
$errors = $this->_validatePerson($person);
|
|
||||||
|
|
||||||
if (count($errors) <= 0) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('success', $this->get('translator')
|
|
||||||
->trans(
|
|
||||||
'An accompanying period has been opened.',
|
|
||||||
['%name%' => $person->__toString()]
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('error', $this->get('translator')
|
|
||||||
->trans('Period not opened'));
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add('info', $error->getMessage());
|
|
||||||
}
|
|
||||||
} else { // if errors in forms
|
|
||||||
$this->get('session')->getFlashBag()
|
|
||||||
->add(
|
|
||||||
'error',
|
|
||||||
$this->get('translator')
|
|
||||||
->trans('Period not opened : form is invalid')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
|
|
||||||
'form' => $form->createView(),
|
|
||||||
'person' => $person,
|
|
||||||
'accompanying_period' => $accompanyingPeriod,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
|
|
||||||
{
|
|
||||||
/** @var Person $person */
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
/** @var AccompanyingPeriod $period */
|
|
||||||
$period = array_filter(
|
|
||||||
$person->getAccompanyingPeriods(),
|
|
||||||
static fn (AccompanyingPeriod $p) => $p->getId() === ($period_id)
|
|
||||||
)[0] ?? null;
|
|
||||||
|
|
||||||
if (null === $period) {
|
|
||||||
throw $this->createNotFoundException('period not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$confirm = $request->query->getBoolean('confirm', false);
|
|
||||||
|
|
||||||
if (true === $confirm && $period->canBeReOpened($person)) {
|
|
||||||
$period->reOpen();
|
|
||||||
|
|
||||||
$this->_validatePerson($person);
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans(
|
|
||||||
'The period has been re-opened'
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $confirm && $period->canBeReOpened($person)) {
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:re_open.html.twig', [
|
|
||||||
'period' => $period,
|
|
||||||
'person' => $person,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new Response())
|
|
||||||
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
|
||||||
->setContent('You cannot re-open this period');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function updateAction(int $person_id, int $period_id, Request $request): Response
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
/** @var AccompanyingPeriod $accompanyingPeriod */
|
|
||||||
$accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($period_id);
|
|
||||||
|
|
||||||
if (null === $accompanyingPeriod) {
|
|
||||||
throw $this->createNotFoundException('Period with id ' . $period_id . ' is not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var Person $person */
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
// CHECK
|
|
||||||
if (!$accompanyingPeriod->containsPerson($person)) {
|
|
||||||
throw new Exception('Accompanying period ' . $period_id . ' does not contain person ' . $person_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
|
||||||
PersonVoter::UPDATE,
|
|
||||||
$person,
|
|
||||||
'You are not allowed to update this person'
|
|
||||||
);
|
|
||||||
|
|
||||||
$form = $this->createForm(
|
|
||||||
AccompanyingPeriodType::class,
|
|
||||||
$accompanyingPeriod,
|
|
||||||
[
|
|
||||||
'period_action' => 'update',
|
|
||||||
'center' => $person->getCenter(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
$errors = $this->_validatePerson($person);
|
|
||||||
$flashBag = $this->get('session')->getFlashBag();
|
|
||||||
|
|
||||||
if (
|
|
||||||
$form->isValid(['Default', 'closed'])
|
|
||||||
&& count($errors) === 0
|
|
||||||
) {
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
$flashBag->add(
|
|
||||||
'success',
|
|
||||||
$this->get('translator')->trans('An accompanying period has been updated.')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect(
|
|
||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$flashBag->add('error', $this->get('translator')
|
|
||||||
->trans('Error when updating the period'));
|
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$flashBag->add('info', $error->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
|
|
||||||
'form' => $form->createView(),
|
|
||||||
'person' => $person,
|
|
||||||
'accompanying_period' => $accompanyingPeriod,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
|
||||||
*/
|
|
||||||
private function _getPerson(int $id): Person
|
|
||||||
{
|
|
||||||
$person = $this->getDoctrine()->getManager()
|
|
||||||
->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($id);
|
|
||||||
|
|
||||||
if (null === $person) {
|
|
||||||
throw $this->createNotFoundException('Person not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
|
||||||
PersonVoter::SEE,
|
|
||||||
$person,
|
|
||||||
'You are not allowed to see this person'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $person;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _validatePerson(Person $person): ConstraintViolationListInterface
|
|
||||||
{
|
|
||||||
$errors = $this->validator->validate(
|
|
||||||
$person,
|
|
||||||
null,
|
|
||||||
['Default']
|
|
||||||
);
|
|
||||||
|
|
||||||
// Can be disabled with config
|
|
||||||
if (false === $this->container->getParameter('chill_person.allow_multiple_simultaneous_accompanying_periods')) {
|
|
||||||
$errors_accompanying_period = $this->validator->validate(
|
|
||||||
$person,
|
|
||||||
null,
|
|
||||||
['accompanying_period_consistent']
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($errors_accompanying_period as $error) {
|
|
||||||
$errors->add($error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -32,7 +32,7 @@ use Symfony\Component\Templating\EngineInterface;
|
|||||||
|
|
||||||
class AccompanyingPeriodRegulationListController
|
class AccompanyingPeriodRegulationListController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class HouseholdCompositionController extends AbstractController
|
class HouseholdCompositionController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly UrlGeneratorInterface $urlGenerator)
|
public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly UrlGeneratorInterface $urlGenerator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ use Chill\PersonBundle\Repository\PersonRepository;
|
|||||||
use Chill\PersonBundle\Search\SimilarPersonMatcher;
|
use Chill\PersonBundle\Search\SimilarPersonMatcher;
|
||||||
use Chill\TaskBundle\Entity\SingleTask;
|
use Chill\TaskBundle\Entity\SingleTask;
|
||||||
use http\Exception\InvalidArgumentException;
|
use http\Exception\InvalidArgumentException;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -32,10 +33,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
use function count;
|
use function count;
|
||||||
|
|
||||||
class PersonDuplicateController extends Controller
|
class PersonDuplicateController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher)
|
public function __construct(
|
||||||
{
|
private readonly SimilarPersonMatcher $similarPersonMatcher,
|
||||||
|
private readonly TranslatorInterface $translator,
|
||||||
|
private readonly PersonRepository $personRepository,
|
||||||
|
private readonly PersonMove $personMove,
|
||||||
|
private readonly EventDispatcherInterface $eventDispatcher
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function confirmAction($person1_id, $person2_id, Request $request)
|
public function confirmAction($person1_id, $person2_id, Request $request)
|
||||||
|
@@ -40,7 +40,7 @@ use function is_int;
|
|||||||
|
|
||||||
class ReassignAccompanyingPeriodController extends AbstractController
|
class ReassignAccompanyingPeriodController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em)
|
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
|||||||
|
|
||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
|
/** @var array<int, array<int, 1>> $existing */
|
||||||
$existing = [];
|
$existing = [];
|
||||||
|
|
||||||
for ($i = 0; 20 > $i; ++$i) {
|
for ($i = 0; 20 > $i; ++$i) {
|
||||||
@@ -59,15 +60,16 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
|||||||
->setUpdatedAt($date);
|
->setUpdatedAt($date);
|
||||||
|
|
||||||
// remove the potential duplicates
|
// remove the potential duplicates
|
||||||
$set = $relationship->getFromPerson()->getId() < $relationship->getToPerson()->getId() ?
|
$set = [
|
||||||
[$relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()] :
|
min($relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()),
|
||||||
[$relationship->getToPerson()->getId(), $relationship->getFromPerson()->getId()];
|
max($relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()),
|
||||||
|
];
|
||||||
|
|
||||||
if (array_key_exists($set[0], $existing) && array_key_exists($set[1], $existing[$set[0]])) {
|
if (array_key_exists($set[0], $existing) && array_key_exists($set[1], $existing[$set[0]])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$existing[$set[0]][$set[1]] = 1;
|
||||||
|
|
||||||
$existing[$set[0]][$existing[$set[1]]] = 1;
|
|
||||||
$manager->persist($relationship);
|
$manager->persist($relationship);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,6 +26,8 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccompanyingPeriodType.
|
* Class AccompanyingPeriodType.
|
||||||
|
*
|
||||||
|
* @deprecated to be removed
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriodType extends AbstractType
|
class AccompanyingPeriodType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -81,7 +83,7 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
if ('visible' === $this->config['user']) {
|
if ('visible' === $this->config['user']) {
|
||||||
$builder->add('user', UserPickerType::class, [
|
$builder->add('user', UserPickerType::class, [
|
||||||
'center' => $options['center'],
|
'center' => $options['center'],
|
||||||
'role' => new Role(PersonVoter::SEE),
|
'role' => PersonVoter::SEE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -213,7 +213,7 @@ class PersonType extends AbstractType
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($options['cFGroup']) {
|
if (null !== $options['cFGroup']) {
|
||||||
$builder
|
$builder
|
||||||
->add(
|
->add(
|
||||||
'cFData',
|
'cFData',
|
||||||
|
@@ -44,6 +44,8 @@ use function is_array;
|
|||||||
* `Chill\MainBundle\Entity\Center`. By default, all the reachable centers as selected.
|
* `Chill\MainBundle\Entity\Center`. By default, all the reachable centers as selected.
|
||||||
* - with the `role` option, only the people belonging to the reachable center for the
|
* - with the `role` option, only the people belonging to the reachable center for the
|
||||||
* given role are displayed.
|
* given role are displayed.
|
||||||
|
*
|
||||||
|
* @deprecated use @link{\Chill\PersonBundle\Form\Type\PickPersonDynamicType::class} instead
|
||||||
*/
|
*/
|
||||||
class PickPersonType extends AbstractType
|
class PickPersonType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -107,7 +109,7 @@ class PickPersonType extends AbstractType
|
|||||||
->addAllowedTypes('centers', ['array', Center::class, 'null'])
|
->addAllowedTypes('centers', ['array', Center::class, 'null'])
|
||||||
->setDefault('centers', null)
|
->setDefault('centers', null)
|
||||||
->setDefined('role')
|
->setDefined('role')
|
||||||
->addAllowedTypes('role', [Role::class, 'null'])
|
->addAllowedTypes('role', ['string', 'null'])
|
||||||
->setDefault('role', null);
|
->setDefault('role', null);
|
||||||
|
|
||||||
// add the default options
|
// add the default options
|
||||||
|
@@ -32,7 +32,7 @@ namespace Chill\PersonBundle\Privacy;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class AccompanyingPeriodPrivacyEvent extends Event
|
class AccompanyingPeriodPrivacyEvent extends Event
|
||||||
{
|
{
|
||||||
|
@@ -32,8 +32,8 @@ namespace Chill\PersonBundle\Privacy;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
|
||||||
|
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
use function count;
|
use function count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,7 +18,7 @@ use Chill\MainBundle\Entity\Scope;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||||
@@ -35,16 +35,18 @@ use function count;
|
|||||||
|
|
||||||
final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
|
final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
|
||||||
{
|
{
|
||||||
public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private Security $security, private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher)
|
public function __construct(
|
||||||
{
|
private AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||||
|
private Security $security,
|
||||||
|
private AuthorizationHelper $authorizationHelper,
|
||||||
|
private CenterResolverManagerInterface $centerResolverDispatcher
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|PostalCode[]
|
* @param array<PostalCode> $postalCodes
|
||||||
*
|
|
||||||
* @return QueryBuilder
|
|
||||||
*/
|
*/
|
||||||
public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = [])
|
public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = []): QueryBuilder
|
||||||
{
|
{
|
||||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||||
|
|
||||||
@@ -139,7 +141,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin
|
|||||||
->getReachableCircles(
|
->getReachableCircles(
|
||||||
$this->security->getUser(),
|
$this->security->getUser(),
|
||||||
$role,
|
$role,
|
||||||
$this->centerResolverDispatcher->resolveCenter($person)
|
$this->centerResolverDispatcher->resolveCenters($person)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (0 === count($scopes)) {
|
if (0 === count($scopes)) {
|
||||||
|
@@ -45,7 +45,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
|||||||
'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city',
|
'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private readonly EngineInterface $templating, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private readonly PaginatorFactory $paginatorFactory, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository)
|
public function __construct(private readonly \Twig\Environment $templating, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private readonly PaginatorFactory $paginatorFactory, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ class PersonRender implements PersonRenderInterface
|
|||||||
{
|
{
|
||||||
use BoxUtilsChillEntityRenderTrait;
|
use BoxUtilsChillEntityRenderTrait;
|
||||||
|
|
||||||
public function __construct(private readonly ConfigPersonAltNamesHelper $configAltNamesHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator)
|
public function __construct(private readonly ConfigPersonAltNamesHelper $configAltNamesHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ class SocialActionRender implements ChillEntityRenderInterface
|
|||||||
*/
|
*/
|
||||||
final public const SHOW_AND_CHILDREN = 'show_and_children';
|
final public const SHOW_AND_CHILDREN = 'show_and_children';
|
||||||
|
|
||||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator)
|
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ final readonly class SocialIssueRender implements ChillEntityRenderInterface
|
|||||||
*/
|
*/
|
||||||
public const SHOW_AND_CHILDREN = 'show_and_children';
|
public const SHOW_AND_CHILDREN = 'show_and_children';
|
||||||
|
|
||||||
public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator)
|
public function __construct(private TranslatableStringHelper $translatableStringHelper, private \Twig\Environment $engine, private TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -247,7 +247,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildSubscriber(
|
private function buildSubscriber(
|
||||||
?EngineInterface $engine = null,
|
?\Twig\Environment $engine = null,
|
||||||
?NotificationPersisterInterface $notificationPersister = null,
|
?NotificationPersisterInterface $notificationPersister = null,
|
||||||
?Security $security = null,
|
?Security $security = null,
|
||||||
?TranslatorInterface $translator = null
|
?TranslatorInterface $translator = null
|
||||||
@@ -264,7 +264,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $engine) {
|
if (null === $engine) {
|
||||||
$double = $this->prophesize(EngineInterface::class);
|
$double = $this->prophesize(\Twig\Environment::class);
|
||||||
$engine = $double->reveal();
|
$engine = $double->reveal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ class PersonListWidget implements WidgetInterface
|
|||||||
// show only the person from the authorized centers
|
// show only the person from the authorized centers
|
||||||
$and = $qb->expr()->andX();
|
$and = $qb->expr()->andX();
|
||||||
$centers = $this->authorizationHelper
|
$centers = $this->authorizationHelper
|
||||||
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
|
->getReachableCenters($this->getUser(), PersonVoter::SEE);
|
||||||
$and->add($qb->expr()->in('person.center', ':centers'));
|
$and->add($qb->expr()->in('person.center', ':centers'));
|
||||||
$qb->setParameter('centers', $centers);
|
$qb->setParameter('centers', $centers);
|
||||||
|
|
||||||
|
@@ -10,11 +10,6 @@ services:
|
|||||||
$paginatorFactory: '@chill_main.paginator_factory'
|
$paginatorFactory: '@chill_main.paginator_factory'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
Chill\PersonBundle\Controller\AccompanyingPeriodController:
|
|
||||||
autowire: true
|
|
||||||
autoconfigure: true
|
|
||||||
tags: ['controller.service_arguments']
|
|
||||||
|
|
||||||
Chill\PersonBundle\Controller\PersonAddressController:
|
Chill\PersonBundle\Controller\PersonAddressController:
|
||||||
arguments:
|
arguments:
|
||||||
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
||||||
|
@@ -219,7 +219,7 @@ class ReportController extends AbstractController
|
|||||||
$reachableScopes = $this->authorizationHelper
|
$reachableScopes = $this->authorizationHelper
|
||||||
->getReachableScopes(
|
->getReachableScopes(
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
new Role('CHILL_REPORT_SEE'),
|
'CHILL_REPORT_SEE',
|
||||||
$person->getCenter()
|
$person->getCenter()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -555,7 +555,7 @@ class ReportController extends AbstractController
|
|||||||
),
|
),
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'cFGroup' => $cFGroup,
|
'cFGroup' => $cFGroup,
|
||||||
'role' => new Role('CHILL_REPORT_CREATE'),
|
'role' => 'CHILL_REPORT_CREATE',
|
||||||
'center' => $person->getCenter(),
|
'center' => $person->getCenter(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -577,7 +577,7 @@ class ReportController extends AbstractController
|
|||||||
),
|
),
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'cFGroup' => $entity->getCFGroup(),
|
'cFGroup' => $entity->getCFGroup(),
|
||||||
'role' => new Role('CHILL_REPORT_UPDATE'),
|
'role' => 'CHILL_REPORT_UPDATE',
|
||||||
'center' => $entity->getPerson()->getCenter(),
|
'center' => $entity->getPerson()->getCenter(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -198,21 +198,23 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$picked = $this->pickChoice($choices);
|
|
||||||
|
|
||||||
if ($other) {
|
return $picked;
|
||||||
$result = ['_other' => null, '_choices' => $picked];
|
}
|
||||||
|
$picked = $this->pickChoice($choices);
|
||||||
|
|
||||||
if ('_other' === $picked) {
|
if ($other) {
|
||||||
$result['_other'] = $this->faker->realText(70);
|
$result = ['_other' => null, '_choices' => $picked];
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
if ('_other' === $picked) {
|
||||||
|
$result['_other'] = $this->faker->realText(70);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \LogicException("should not happens");
|
return $picked;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,10 +229,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* pick a choice within a 'choices' options (for choice type).
|
* pick a choice within a 'choices' options (for choice type).
|
||||||
*
|
|
||||||
* @return the slug of the selected choice
|
|
||||||
*/
|
*/
|
||||||
private function pickChoice(array $choices)
|
private function pickChoice(array $choices): string
|
||||||
{
|
{
|
||||||
return $choices[array_rand($choices)]['slug'];
|
return $choices[array_rand($choices)]['slug'];
|
||||||
}
|
}
|
||||||
|
@@ -1,159 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\ReportBundle\Search;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
use Chill\MainBundle\Search\AbstractSearch;
|
|
||||||
use Chill\MainBundle\Search\ParsingException;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
use function array_key_exists;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search amongst reports.
|
|
||||||
*/
|
|
||||||
class ReportSearch extends AbstractSearch implements ContainerAwareInterface
|
|
||||||
{
|
|
||||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Chill\MainBundle\Entity\User
|
|
||||||
*/
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
private readonly EntityManagerInterface $em,
|
|
||||||
private readonly AuthorizationHelper $helper,
|
|
||||||
TokenStorageInterface $tokenStorage
|
|
||||||
) {
|
|
||||||
if (!$tokenStorage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) {
|
|
||||||
throw new RuntimeException('an user must be associated with token');
|
|
||||||
}
|
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrder()
|
|
||||||
{
|
|
||||||
return 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isActiveByDefault()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = [], $format = 'html')
|
|
||||||
{
|
|
||||||
return $this->container->get('templating')->render('ChillReportBundle:Search:results.html.twig', [
|
|
||||||
'reports' => $this->getReports($terms, $start, $limit),
|
|
||||||
'total' => $this->count($terms),
|
|
||||||
'pattern' => $this->recomposePattern($terms, ['date'], 'report'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supports($domain, $format = 'html')
|
|
||||||
{
|
|
||||||
return 'report' === $domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addACL(QueryBuilder $qb)
|
|
||||||
{
|
|
||||||
//adding join
|
|
||||||
$qb->join('r.person', 'p');
|
|
||||||
|
|
||||||
$role = new Role('CHILL_REPORT_SEE');
|
|
||||||
$reachableCenters = $this->helper->getReachableCenters($this->user, $role);
|
|
||||||
|
|
||||||
$whereElement = $qb->expr()->orX();
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
foreach ($reachableCenters as $center) {
|
|
||||||
$reachableScopesId = array_map(
|
|
||||||
static fn (Scope $scope) => $scope->getId(),
|
|
||||||
$this->helper->getReachableScopes($this->user, $role, $center)
|
|
||||||
);
|
|
||||||
$whereElement->add(
|
|
||||||
$qb->expr()->andX(
|
|
||||||
$qb->expr()->eq('p.center', ':center_' . $i),
|
|
||||||
$qb->expr()->in('r.scope', ':reachable_scopes_' . $i)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$qb->setParameter('center_' . $i, $center);
|
|
||||||
$qb->setParameter('reachable_scopes_' . $i, $reachableScopesId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $whereElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $terms the terms
|
|
||||||
*
|
|
||||||
* @return \Doctrine\ORM\QueryBuilder
|
|
||||||
*/
|
|
||||||
private function buildQuery(array $terms)
|
|
||||||
{
|
|
||||||
$query = $this->em->createQueryBuilder();
|
|
||||||
|
|
||||||
$query->from('ChillReportBundle:Report', 'r');
|
|
||||||
|
|
||||||
//throw a parsing exception if key 'date' and default is set
|
|
||||||
if (array_key_exists('date', $terms) && '' !== $terms['_default']) {
|
|
||||||
throw new ParsingException('You may not set a date argument and a date in default');
|
|
||||||
}
|
|
||||||
//throw a parsing exception if no argument except report
|
|
||||||
if (!array_key_exists('date', $terms) && '' === $terms['_default']) {
|
|
||||||
throw new ParsingException('You must provide either a date:YYYY-mm-dd argument or a YYYY-mm-dd default search');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('date', $terms)) {
|
|
||||||
$query->andWhere($query->expr()->eq('r.date', ':date'))
|
|
||||||
->setParameter('date', $this->parseDate($terms['date']));
|
|
||||||
} elseif (array_key_exists('_default', $terms)) {
|
|
||||||
$query->andWhere($query->expr()->eq('r.date', ':date'))
|
|
||||||
->setParameter('date', $this->parseDate($terms['_default']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$query->andWhere($this->addACL($query));
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function count(array $terms)
|
|
||||||
{
|
|
||||||
$qb = $this->buildQuery($terms);
|
|
||||||
|
|
||||||
$qb->select('COUNT(r.id)');
|
|
||||||
|
|
||||||
return $qb->getQuery()->getSingleScalarResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getReports(array $terms, $start, $limit)
|
|
||||||
{
|
|
||||||
$qb = $this->buildQuery($terms);
|
|
||||||
|
|
||||||
$qb->select('r')
|
|
||||||
->setMaxResults($limit)
|
|
||||||
->setFirstResult($start)
|
|
||||||
->orderBy('r.date', 'desc');
|
|
||||||
|
|
||||||
$reportQuery = $qb->getQuery();
|
|
||||||
$reportQuery->setFetchMode(\Chill\ReportBundle\Entity\Report::class, 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER);
|
|
||||||
|
|
||||||
return $reportQuery->getResult();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -3,18 +3,6 @@ services:
|
|||||||
# class: Chill\ReportBundle\Example
|
# class: Chill\ReportBundle\Example
|
||||||
# arguments: [@service_id, "plain_value", %parameter%]
|
# arguments: [@service_id, "plain_value", %parameter%]
|
||||||
services:
|
services:
|
||||||
|
|
||||||
chill.report.search:
|
|
||||||
class: Chill\ReportBundle\Search\ReportSearch
|
|
||||||
arguments:
|
|
||||||
- '@doctrine.orm.entity_manager'
|
|
||||||
- '@chill.main.security.authorization.helper'
|
|
||||||
- '@security.token_storage'
|
|
||||||
calls:
|
|
||||||
- [setContainer, ["@service_container"]]
|
|
||||||
tags:
|
|
||||||
- { name: chill.search, alias: 'report' }
|
|
||||||
|
|
||||||
chill.report.timeline:
|
chill.report.timeline:
|
||||||
class: Chill\ReportBundle\Timeline\TimelineReportProvider
|
class: Chill\ReportBundle\Timeline\TimelineReportProvider
|
||||||
arguments:
|
arguments:
|
||||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\TaskBundle\Controller;
|
namespace Chill\TaskBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
use Chill\MainBundle\Serializer\Model\Collection;
|
||||||
use Chill\MainBundle\Serializer\Model\Counter;
|
use Chill\MainBundle\Serializer\Model\Counter;
|
||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||||
@@ -39,7 +39,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use function array_map;
|
use function array_map;
|
||||||
@@ -47,8 +46,15 @@ use function array_merge;
|
|||||||
|
|
||||||
final class SingleTaskController extends AbstractController
|
final class SingleTaskController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly PaginatorFactory $paginatorFactory, private readonly SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly TimelineBuilder $timelineBuilder, private readonly LoggerInterface $logger, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory)
|
public function __construct(
|
||||||
{
|
private readonly PaginatorFactory $paginatorFactory,
|
||||||
|
private readonly SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
|
||||||
|
private readonly TranslatorInterface $translator,
|
||||||
|
private readonly EventDispatcherInterface $eventDispatcher,
|
||||||
|
private readonly TimelineBuilder $timelineBuilder,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,9 +265,8 @@ final class SingleTaskController extends AbstractController
|
|||||||
* name="chill_task_singletask_list"
|
* name="chill_task_singletask_list"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function listAction(
|
public function listAction()
|
||||||
Request $request
|
{
|
||||||
) {
|
|
||||||
$this->denyAccessUnlessGranted(TaskVoter::SHOW, null);
|
$this->denyAccessUnlessGranted(TaskVoter::SHOW, null);
|
||||||
|
|
||||||
$filterOrder = $this->buildFilterOrder();
|
$filterOrder = $this->buildFilterOrder();
|
||||||
@@ -303,9 +308,7 @@ final class SingleTaskController extends AbstractController
|
|||||||
* name="chill_task_singletask_by-course_list")
|
* name="chill_task_singletask_by-course_list")
|
||||||
*/
|
*/
|
||||||
public function listCourseTasks(
|
public function listCourseTasks(
|
||||||
AccompanyingPeriod $course,
|
AccompanyingPeriod $course
|
||||||
FormFactoryInterface $formFactory,
|
|
||||||
Request $request
|
|
||||||
): Response {
|
): Response {
|
||||||
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $course);
|
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $course);
|
||||||
|
|
||||||
@@ -398,7 +401,6 @@ final class SingleTaskController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Response
|
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{_locale}/task/single-task/list/my",
|
* "/{_locale}/task/single-task/list/my",
|
||||||
* name="chill_task_singletask_my_tasks",
|
* name="chill_task_singletask_my_tasks",
|
||||||
@@ -409,7 +411,7 @@ final class SingleTaskController extends AbstractController
|
|||||||
* defaults={"_format": "json"}
|
* defaults={"_format": "json"}
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function myTasksAction(string $_format, Request $request)
|
public function myTasksAction(string $_format, Request $request): Response
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\TaskBundle\Event;
|
namespace Chill\TaskBundle\Event;
|
||||||
|
|
||||||
use Chill\TaskBundle\Entity\AbstractTask;
|
use Chill\TaskBundle\Entity\AbstractTask;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class TaskEvent extends Event
|
class TaskEvent extends Event
|
||||||
{
|
{
|
||||||
|
@@ -12,10 +12,10 @@ declare(strict_types=1);
|
|||||||
namespace Chill\TaskBundle\Event\UI;
|
namespace Chill\TaskBundle\Event\UI;
|
||||||
|
|
||||||
use Chill\TaskBundle\Entity\AbstractTask;
|
use Chill\TaskBundle\Entity\AbstractTask;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Workflow\Transition;
|
use Symfony\Component\Workflow\Transition;
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class UIEvent extends Event
|
class UIEvent extends Event
|
||||||
{
|
{
|
||||||
|
@@ -1,276 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\TaskBundle\Form;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
|
||||||
use Chill\PersonBundle\Form\Type\PickPersonType;
|
|
||||||
use Chill\TaskBundle\Entity\SingleTask;
|
|
||||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
|
||||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
|
||||||
use Chill\TaskBundle\Workflow\TaskWorkflowManager;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
use function array_combine;
|
|
||||||
use function array_map;
|
|
||||||
use function count;
|
|
||||||
|
|
||||||
class SingleTaskListType extends AbstractType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EntityManagerInterface
|
|
||||||
*/
|
|
||||||
protected $em;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TaskWorkflowManager
|
|
||||||
*/
|
|
||||||
protected $taskWorkflowManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
protected $tokenStorage;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
EntityManagerInterface $em,
|
|
||||||
TokenStorageInterface $tokenStorage,
|
|
||||||
AuthorizationHelper $authorizationHelper,
|
|
||||||
TaskWorkflowManager $taskWorkflowManager
|
|
||||||
) {
|
|
||||||
$this->em = $em;
|
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
$this->taskWorkflowManager = $taskWorkflowManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
||||||
{
|
|
||||||
$statuses = [
|
|
||||||
'Tasks not started' => SingleTaskRepository::DATE_STATUS_NOT_STARTED,
|
|
||||||
'Tasks with expired deadline' => SingleTaskRepository::DATE_STATUS_ENDED,
|
|
||||||
'Tasks with warning deadline reached' => SingleTaskRepository::DATE_STATUS_WARNING,
|
|
||||||
'Current tasks' => SingleTaskRepository::DATE_STATUS_CURRENT,
|
|
||||||
'Closed tasks' => 'closed',
|
|
||||||
];
|
|
||||||
|
|
||||||
$builder
|
|
||||||
->add('user_id', ChoiceType::class, [
|
|
||||||
'choices' => $this->getUserChoices($options),
|
|
||||||
'placeholder' => 'Any user',
|
|
||||||
'required' => false,
|
|
||||||
'label' => 'Assignee',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($options['add_status']) {
|
|
||||||
$builder
|
|
||||||
->add('status', ChoiceType::class, [
|
|
||||||
'choices' => $statuses,
|
|
||||||
'expanded' => true,
|
|
||||||
'multiple' => true,
|
|
||||||
'label' => 'status',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($options['add_type']) {
|
|
||||||
$types = $this->getTaskTypesChoices($options);
|
|
||||||
|
|
||||||
if (count($types) > 0) {
|
|
||||||
$builder->add('types', ChoiceType::class, [
|
|
||||||
'choices' => $types,
|
|
||||||
'required' => false,
|
|
||||||
'expanded' => true,
|
|
||||||
'multiple' => true,
|
|
||||||
'label' => 'Task types',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $options['person']) {
|
|
||||||
$builder
|
|
||||||
->add('person_id', PickPersonType::class, [
|
|
||||||
'centers' => $this->authorizationHelper
|
|
||||||
->getReachableCenters(
|
|
||||||
$this->tokenStorage->getToken()->getUser(),
|
|
||||||
new Role(TaskVoter::SHOW)
|
|
||||||
),
|
|
||||||
'required' => false,
|
|
||||||
'label' => 'Associated person',
|
|
||||||
]);
|
|
||||||
$reachablesCenters = $this->getReachablesCenters();
|
|
||||||
|
|
||||||
if (count($reachablesCenters) > 1) {
|
|
||||||
$builder
|
|
||||||
->add('center_id', EntityType::class, [
|
|
||||||
'class' => \Chill\MainBundle\Entity\Center::class,
|
|
||||||
'choices' => $reachablesCenters,
|
|
||||||
'label' => 'Center',
|
|
||||||
'required' => false,
|
|
||||||
'placeholder' => 'All centers',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// add a hidden field
|
|
||||||
$builder
|
|
||||||
->add('person_id', HiddenType::class);
|
|
||||||
$builder->get('person_id')
|
|
||||||
->addModelTransformer(new PersonToIdTransformer($this->em));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver
|
|
||||||
->setDefined('person')
|
|
||||||
->setDefault('person', null)
|
|
||||||
->setAllowedTypes('person', [Person::class, 'null'])
|
|
||||||
->setDefined('accompanyingCourse')
|
|
||||||
->setDefined('add_status')
|
|
||||||
->setDefault('add_status', false)
|
|
||||||
->setAllowedTypes('add_status', ['bool'])
|
|
||||||
->setDefined('add_type')
|
|
||||||
->setDefault('add_type', false)
|
|
||||||
->setAllowedTypes('add_type', ['bool']);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getReachablesCenters()
|
|
||||||
{
|
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
|
||||||
$role = new Role(TaskVoter::SHOW);
|
|
||||||
|
|
||||||
return $this->authorizationHelper->getReachableCenters($user, $role);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getTaskTypesChoices($options)
|
|
||||||
{
|
|
||||||
$qb = $this->em->createQueryBuilder();
|
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
|
||||||
$role = new Role(TaskVoter::SHOW);
|
|
||||||
$centers = $this->authorizationHelper->getReachableCenters($user, $role);
|
|
||||||
|
|
||||||
$qb->select('DISTINCT task.type AS type')
|
|
||||||
->from(SingleTask::class, 'task')
|
|
||||||
->join('task.person', 'person');
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$orCenters = $qb->expr()->orX();
|
|
||||||
|
|
||||||
foreach ($centers as $center) {
|
|
||||||
$circles = $this->authorizationHelper->getReachableCircles($user, $role, $center);
|
|
||||||
|
|
||||||
if (count($circles) > 0) {
|
|
||||||
$andX = $qb->expr()->andX();
|
|
||||||
$andX
|
|
||||||
->add($qb->expr()->eq('person.center', ':center_' . $i))
|
|
||||||
->add($qb->expr()->in('task.circle', ':circles_' . $i));
|
|
||||||
$orCenters->add($andX);
|
|
||||||
|
|
||||||
$qb
|
|
||||||
->setParameter('center_' . $i, $center)
|
|
||||||
->setParameter('circles_' . $i, $circles);
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < $i) {
|
|
||||||
$qb->where($orCenters);
|
|
||||||
}
|
|
||||||
|
|
||||||
$types = $qb->getQuery()->getResult();
|
|
||||||
|
|
||||||
$choices = [];
|
|
||||||
|
|
||||||
foreach ($types as $row) {
|
|
||||||
$fake = (new SingleTask())->setType($row['type']);
|
|
||||||
$label = $this->taskWorkflowManager->getWorkflowMetadata($fake, 'definition.name');
|
|
||||||
$choices[$label] = $row['type'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $choices;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getUserChoices($options)
|
|
||||||
{
|
|
||||||
$users = $this->getUsersAssigneedToTask($options);
|
|
||||||
$choices = array_combine(
|
|
||||||
// get usernames
|
|
||||||
array_map(static fn (User $user) => $user->getUsername(), $users),
|
|
||||||
// get ids
|
|
||||||
array_map(static fn (User $user) => $user->getId(), $users)
|
|
||||||
);
|
|
||||||
$choices['Unassigned'] = '_unassigned';
|
|
||||||
|
|
||||||
return $choices;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a list of user having a task assigned.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return User[]
|
|
||||||
*/
|
|
||||||
protected function getUsersAssigneedToTask(mixed $options)
|
|
||||||
{
|
|
||||||
$qb = $this->em->createQueryBuilder();
|
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
|
||||||
$role = new Role(TaskVoter::SHOW);
|
|
||||||
$centers = $this->authorizationHelper->getReachableCenters($user, $role);
|
|
||||||
|
|
||||||
$qb->select('DISTINCT user')
|
|
||||||
->from(User::class, 'user')
|
|
||||||
->join(SingleTask::class, 'task', \Doctrine\ORM\Query\Expr\Join::WITH, 'task.assignee = user')
|
|
||||||
->join('task.person', 'person')
|
|
||||||
->where("user.enabled = 'TRUE'");
|
|
||||||
|
|
||||||
if (null !== $options['person']) {
|
|
||||||
$qb
|
|
||||||
->andWhere($qb->expr()->eq('task.person', ':person'))
|
|
||||||
->setParameter('person', $options['person']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$circleCenterCond = $qb->expr()->orX();
|
|
||||||
|
|
||||||
foreach ($centers as $center) {
|
|
||||||
$circles = $this->authorizationHelper->getReachableCircles($user, $role, $center);
|
|
||||||
// add condition about person and circle
|
|
||||||
$circleCenterCond->add(
|
|
||||||
$qb->expr()->andX()
|
|
||||||
->add($qb->expr()->eq('person.center', ':center_' . $i))
|
|
||||||
->add($qb->expr()->in('task.circle', ':circles_' . $i))
|
|
||||||
);
|
|
||||||
|
|
||||||
$qb->setParameter('center_' . $i, $center)
|
|
||||||
->setParameter('circles_' . $i, $circles);
|
|
||||||
// increase counter
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
$qb->andWhere($circleCenterCond);
|
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\DateIntervalType;
|
|||||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||||
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
@@ -28,17 +29,17 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
|
|
||||||
class SingleTaskType extends AbstractType
|
class SingleTaskType extends AbstractType
|
||||||
{
|
{
|
||||||
public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher)
|
public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$center = null;
|
$centers = null;
|
||||||
$isScopeConcerned = false;
|
$isScopeConcerned = false;
|
||||||
|
|
||||||
if (null !== $task = $options['data']) {
|
if (null !== $task = $options['data']) {
|
||||||
$center = $this->centerResolverDispatcher->resolveCenter($task);
|
$centers = $this->centerResolverDispatcher->resolveCenters($task);
|
||||||
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($task);
|
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ class SingleTaskType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('assignee', UserPickerType::class, [
|
->add('assignee', UserPickerType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'center' => $center,
|
'center' => $centers,
|
||||||
'role' => TaskVoter::SHOW,
|
'role' => TaskVoter::SHOW,
|
||||||
'placeholder' => 'Not assigned',
|
'placeholder' => 'Not assigned',
|
||||||
'attr' => ['class' => ' select2 '],
|
'attr' => ['class' => ' select2 '],
|
||||||
@@ -67,7 +68,7 @@ class SingleTaskType extends AbstractType
|
|||||||
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
|
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
|
||||||
$builder
|
$builder
|
||||||
->add('circle', ScopePickerType::class, [
|
->add('circle', ScopePickerType::class, [
|
||||||
'center' => $center,
|
'center' => $centers,
|
||||||
'role' => $options['role'],
|
'role' => $options['role'],
|
||||||
'required' => true,
|
'required' => true,
|
||||||
]);
|
]);
|
||||||
@@ -78,6 +79,6 @@ class SingleTaskType extends AbstractType
|
|||||||
{
|
{
|
||||||
$resolver
|
$resolver
|
||||||
->setRequired('role')
|
->setRequired('role')
|
||||||
->setAllowedTypes('role', [Role::class, 'string']);
|
->setAllowedTypes('role', ['string']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -159,7 +159,7 @@ class SingleTaskRepository extends EntityRepository
|
|||||||
. '`setAuthorizationHelper`');
|
. '`setAuthorizationHelper`');
|
||||||
}
|
}
|
||||||
|
|
||||||
$role = new Role(TaskVoter::SHOW);
|
$role = TaskVoter::SHOW;
|
||||||
$qb->join('st.person', 'p');
|
$qb->join('st.person', 'p');
|
||||||
|
|
||||||
$centers = $this->authorizationHelper
|
$centers = $this->authorizationHelper
|
||||||
|
@@ -14,8 +14,8 @@ namespace Chill\TaskBundle\Security\Authorization;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\TaskBundle\Entity\AbstractTask;
|
use Chill\TaskBundle\Entity\AbstractTask;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
class AuthorizationEvent extends Event
|
class AuthorizationEvent extends Event
|
||||||
{
|
{
|
||||||
|
@@ -168,7 +168,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
|||||||
foreach (
|
foreach (
|
||||||
$this->authorizationHelper->getReachableCenters(
|
$this->authorizationHelper->getReachableCenters(
|
||||||
$this->security->getUser(),
|
$this->security->getUser(),
|
||||||
new Role(ActivityVoter::SEE_DETAILS)
|
ActivityVoter::SEE_DETAILS
|
||||||
) as $center
|
) as $center
|
||||||
) {
|
) {
|
||||||
if (false === in_array($center, $centers, true)) {
|
if (false === in_array($center, $centers, true)) {
|
||||||
@@ -181,7 +181,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
|||||||
// we loop over circles
|
// we loop over circles
|
||||||
$circles = $this->authorizationHelper->getReachableCircles(
|
$circles = $this->authorizationHelper->getReachableCircles(
|
||||||
$this->security->getUser(),
|
$this->security->getUser(),
|
||||||
new Role(ActivityVoter::SEE_DETAILS),
|
ActivityVoter::SEE_DETAILS,
|
||||||
$center
|
$center
|
||||||
);
|
);
|
||||||
$circleIds = [];
|
$circleIds = [];
|
||||||
@@ -234,7 +234,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
|
|||||||
// we loop over circles
|
// we loop over circles
|
||||||
$circles = $this->authorizationHelper->getReachableCircles(
|
$circles = $this->authorizationHelper->getReachableCircles(
|
||||||
$this->security->getUser(),
|
$this->security->getUser(),
|
||||||
new Role(ActivityVoter::SEE_DETAILS),
|
ActivityVoter::SEE_DETAILS,
|
||||||
$personArg->getCenter()
|
$personArg->getCenter()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -3,12 +3,3 @@ services:
|
|||||||
resource: '../../Form/'
|
resource: '../../Form/'
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
|
|
||||||
Chill\TaskBundle\Form\SingleTaskListType:
|
|
||||||
arguments:
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
|
||||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
|
||||||
$taskWorkflowManager: '@Chill\TaskBundle\Workflow\TaskWorkflowManager'
|
|
||||||
tags:
|
|
||||||
- { name: form.type }
|
|
||||||
|
@@ -25,7 +25,7 @@ class ThirdPartyRender implements ChillEntityRenderInterface
|
|||||||
{
|
{
|
||||||
use BoxUtilsChillEntityRenderTrait;
|
use BoxUtilsChillEntityRenderTrait;
|
||||||
|
|
||||||
public function __construct(protected EngineInterface $engine, protected TranslatableStringHelper $translatableStringHelper)
|
public function __construct(protected \Twig\Environment $engine, protected TranslatableStringHelper $translatableStringHelper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ use Twig\Environment;
|
|||||||
*/
|
*/
|
||||||
final readonly class Editor
|
final readonly class Editor
|
||||||
{
|
{
|
||||||
public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private EngineInterface $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router)
|
public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private \Twig\Environment $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
55
tests/Kernel.php
Normal file
55
tests/Kernel.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||||
|
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||||
|
|
||||||
|
class Kernel extends BaseKernel
|
||||||
|
{
|
||||||
|
use MicroKernelTrait;
|
||||||
|
|
||||||
|
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
||||||
|
|
||||||
|
public function registerBundles(): iterable
|
||||||
|
{
|
||||||
|
$contents = require __DIR__ . '/app/config/bundles.php';
|
||||||
|
|
||||||
|
foreach ($contents as $class => $envs) {
|
||||||
|
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
|
||||||
|
yield new $class();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProjectDir()
|
||||||
|
{
|
||||||
|
return \dirname(__DIR__);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||||
|
{
|
||||||
|
$confDir = $this->getProjectDir().'/tests/app/config';
|
||||||
|
|
||||||
|
$routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||||
|
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||||
|
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
|
||||||
|
{
|
||||||
|
$container->addResource(new FileResource($this->getProjectDir().'/tests/app/config/bundles.php'));
|
||||||
|
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
|
||||||
|
$container->setParameter('container.dumper.inline_factories', true);
|
||||||
|
$confDir = $this->getProjectDir().'/tests/app/config';
|
||||||
|
|
||||||
|
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
|
||||||
|
$loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
|
||||||
|
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
|
||||||
|
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
|
||||||
|
}
|
||||||
|
}
|
Submodule tests/app deleted from 5e478fdfbf
23
tests/app/config/bootstrap.php
Normal file
23
tests/app/config/bootstrap.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
|
||||||
|
require dirname(__DIR__).'/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
if (!class_exists(Dotenv::class)) {
|
||||||
|
throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load cached env vars if the .env.local.php file exists
|
||||||
|
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
|
||||||
|
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
|
||||||
|
(new Dotenv(false))->populate($env);
|
||||||
|
} else {
|
||||||
|
// load all the .env files
|
||||||
|
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/../../.env.test');
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SERVER += $_ENV;
|
||||||
|
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
|
||||||
|
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
|
||||||
|
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
|
39
tests/app/config/bundles.php
Normal file
39
tests/app/config/bundles.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
ChampsLibres\AsyncUploaderBundle\ChampsLibresAsyncUploaderBundle::class => ['all' => true],
|
||||||
|
Chill\ActivityBundle\ChillActivityBundle::class => ['all' => true],
|
||||||
|
Chill\AsideActivityBundle\ChillAsideActivityBundle::class => ['all' => true],
|
||||||
|
Chill\CalendarBundle\ChillCalendarBundle::class => ['all' => true],
|
||||||
|
Chill\CustomFieldsBundle\ChillCustomFieldsBundle::class => ['all' => true],
|
||||||
|
Chill\DocGeneratorBundle\ChillDocGeneratorBundle::class => ['all' => true],
|
||||||
|
Chill\DocStoreBundle\ChillDocStoreBundle::class => ['all' => true],
|
||||||
|
Chill\EventBundle\ChillEventBundle::class => ['all' => true],
|
||||||
|
Chill\MainBundle\ChillMainBundle::class => ['all' => true],
|
||||||
|
Chill\PersonBundle\ChillPersonBundle::class => ['all' => true],
|
||||||
|
Chill\ReportBundle\ChillReportBundle::class => ['all' => true],
|
||||||
|
Chill\TaskBundle\ChillTaskBundle::class => ['all' => true],
|
||||||
|
Chill\ThirdPartyBundle\ChillThirdPartyBundle::class => ['all' => true],
|
||||||
|
Chill\BudgetBundle\ChillBudgetBundle::class => ['all' => true],
|
||||||
|
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||||
|
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||||
|
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
||||||
|
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||||
|
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||||
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||||
|
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||||
|
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||||
|
//Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
|
||||||
|
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
|
||||||
|
Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true],
|
||||||
|
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
||||||
|
loophp\PsrHttpMessageBridgeBundle\PsrHttpMessageBridgeBundle::class => ['all' => true],
|
||||||
|
\Misd\PhoneNumberBundle\MisdPhoneNumberBundle::class => ['all' => true],
|
||||||
|
ChampsLibres\WopiBundle\WopiBundle::class => ['all' => true],
|
||||||
|
Chill\WopiBundle\ChillWopiBundle::class => ['all' => true],
|
||||||
|
\Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
|
||||||
|
|
||||||
|
];
|
3
tests/app/config/packages/assets.yaml
Normal file
3
tests/app/config/packages/assets.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
framework:
|
||||||
|
assets:
|
||||||
|
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
|
33
tests/app/config/packages/cache.yaml
Normal file
33
tests/app/config/packages/cache.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
framework:
|
||||||
|
cache:
|
||||||
|
# Unique name of your app: used to compute stable namespaces for cache keys.
|
||||||
|
#prefix_seed: your_vendor_name/app_name
|
||||||
|
|
||||||
|
# The "app" cache stores to the filesystem by default.
|
||||||
|
# The data in this cache should persist between deploys.
|
||||||
|
# Other options include:
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
#app: cache.adapter.redis
|
||||||
|
#default_redis_provider: redis://localhost
|
||||||
|
|
||||||
|
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||||
|
#app: cache.adapter.apcu
|
||||||
|
|
||||||
|
# Namespaced pools use the above "app" backend by default
|
||||||
|
#pools:
|
||||||
|
#my.dedicated.cache: null
|
||||||
|
|
||||||
|
default_redis_provider: '%env(resolve:REDIS_URL)%'
|
||||||
|
|
||||||
|
pools:
|
||||||
|
cache.user_data:
|
||||||
|
adapter: cache.adapter.redis
|
||||||
|
public: true
|
||||||
|
default_lifetime: 300 # 5 minutes
|
||||||
|
|
||||||
|
# will be used in chill_main.tag_aware_cache service
|
||||||
|
cache.tags:
|
||||||
|
adapter: cache.adapter.redis
|
||||||
|
public: false
|
||||||
|
default_lifetime: 300
|
14
tests/app/config/packages/champs-libres.yaml
Normal file
14
tests/app/config/packages/champs-libres.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
champs_libres_async_uploader:
|
||||||
|
openstack:
|
||||||
|
os_username: '%env(resolve:OS_USERNAME)%' # Required
|
||||||
|
os_password: '%env(resolve:OS_PASSWORD)%' # Required
|
||||||
|
os_tenant_id: '%env(resolve:OS_TENANT_ID)%' # Required
|
||||||
|
os_region_name: '%env(resolve:OS_REGION_NAME)%' # Required
|
||||||
|
os_auth_url: '%env(resolve:OS_AUTH_URL)%' # Required
|
||||||
|
temp_url:
|
||||||
|
temp_url_key: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_KEY)%' # Required
|
||||||
|
container: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_CONTAINER)%' # Required
|
||||||
|
temp_url_base_path: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_BASE_PATH)%' # Required. Do not forget a trailing slash
|
||||||
|
max_post_file_size: 15000000 # 15Mo (bytes)
|
||||||
|
max_expires_delay: 180
|
||||||
|
max_submit_delay: 3600
|
23
tests/app/config/packages/chill.yaml
Normal file
23
tests/app/config/packages/chill.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
chill_main:
|
||||||
|
available_languages: [ '%env(resolve:LOCALE)%' ]
|
||||||
|
notifications:
|
||||||
|
from_email: 'test@yopmail.com'
|
||||||
|
from_name: 'TEST CHILL'
|
||||||
|
host: 'localhost'
|
||||||
|
redis:
|
||||||
|
host: '%env(resolve:REDIS_HOST)%'
|
||||||
|
port: '%env(resolve:REDIS_PORT)%'
|
||||||
|
phone_helper:
|
||||||
|
twilio_sid: '%env(resolve:TWILIO_SID)%'
|
||||||
|
twilio_secret: '%env(resolve:TWILIO_SECRET)%'
|
||||||
|
default_carrier_code: '%env(resolve:DEFAULT_CARRIER_CODE)%'
|
||||||
|
|
||||||
|
chill_custom_fields:
|
||||||
|
show_empty_values_in_views: false
|
||||||
|
|
||||||
|
# Enable/disable specific libraries (css and js)
|
||||||
|
twig:
|
||||||
|
globals:
|
||||||
|
active_bootstrap: false
|
||||||
|
active_forkawesome: true
|
||||||
|
active_ckeditor: false
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user