mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'feature/change-parcours-status' into 'master'
Feature/change parcours status See merge request Chill-Projet/chill-bundles!527
This commit is contained in:
@@ -30,6 +30,7 @@ use Chill\MainBundle\Search\SearchApiInterface;
|
||||
use Chill\MainBundle\Security\ProvideRoleInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverInterface;
|
||||
use Chill\MainBundle\Security\Resolver\ScopeResolverInterface;
|
||||
use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoProviderInterface;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
|
||||
@@ -62,6 +63,8 @@ class ChillMainBundle extends Bundle
|
||||
->addTag('chill_main.workflow_handler');
|
||||
$container->registerForAutoconfiguration(CronJobInterface::class)
|
||||
->addTag('chill_main.cron_job');
|
||||
$container->registerForAutoconfiguration(ViewEntityInfoProviderInterface::class)
|
||||
->addTag('chill_main.entity_info_provider');
|
||||
|
||||
$container->addCompilerPass(new SearchableServicesCompilerPass());
|
||||
$container->addCompilerPass(new ConfigConsistencyCompilerPass());
|
||||
|
@@ -0,0 +1,40 @@
|
||||
<?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\MainBundle\Command;
|
||||
|
||||
use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SynchronizeEntityInfoViewsCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ViewEntityInfoManager $viewEntityInfoManager,
|
||||
) {
|
||||
parent::__construct('chill:db:sync-views');
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDescription('Update or create sql views which provide info for various entities');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->viewEntityInfoManager->synchronizeOnDB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@@ -41,12 +41,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
||||
{
|
||||
$object = $args->getObject();
|
||||
|
||||
if (
|
||||
$object instanceof TrackCreationInterface
|
||||
&& $this->security->getUser() instanceof User
|
||||
) {
|
||||
$object->setCreatedBy($this->security->getUser());
|
||||
if ($object instanceof TrackCreationInterface) {
|
||||
$object->setCreatedAt(new DateTimeImmutable('now'));
|
||||
|
||||
if ($this->security->getUser() instanceof User) {
|
||||
$object->setCreatedBy($this->security->getUser());
|
||||
}
|
||||
}
|
||||
|
||||
$this->onUpdate($object);
|
||||
@@ -61,12 +61,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber
|
||||
|
||||
protected function onUpdate(object $object): void
|
||||
{
|
||||
if (
|
||||
$object instanceof TrackUpdateInterface
|
||||
&& $this->security->getUser() instanceof User
|
||||
) {
|
||||
$object->setUpdatedBy($this->security->getUser());
|
||||
if ($object instanceof TrackUpdateInterface) {
|
||||
$object->setUpdatedAt(new DateTimeImmutable('now'));
|
||||
|
||||
if ($this->security->getUser() instanceof User) {
|
||||
$object->setUpdatedBy($this->security->getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?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\MainBundle\Service\EntityInfo;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class ViewEntityInfoManager
|
||||
{
|
||||
public function __construct(
|
||||
/**
|
||||
* @var ViewEntityInfoProviderInterface[]
|
||||
*/
|
||||
private iterable $vienEntityInfoProviders,
|
||||
private Connection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
public function synchronizeOnDB(): void
|
||||
{
|
||||
$this->connection->transactional(function (Connection $conn): void {
|
||||
foreach ($this->vienEntityInfoProviders as $viewProvider) {
|
||||
foreach ($this->createOrReplaceViewSQL($viewProvider, $viewProvider->getViewName()) as $sql) {
|
||||
$conn->executeQuery($sql);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
private function createOrReplaceViewSQL(ViewEntityInfoProviderInterface $viewProvider, string $viewName): array
|
||||
{
|
||||
return [
|
||||
"DROP VIEW IF EXISTS {$viewName}",
|
||||
sprintf("CREATE VIEW {$viewName} AS %s", $viewProvider->getViewQuery())
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?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\MainBundle\Service\EntityInfo;
|
||||
|
||||
interface ViewEntityInfoProviderInterface
|
||||
{
|
||||
public function getViewQuery(): string;
|
||||
|
||||
public function getViewName(): string;
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
parameters:
|
||||
# cl_chill_main.example.class: Chill\MainBundle\Example
|
||||
|
||||
imports:
|
||||
- ./services/clock.yaml
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
@@ -118,3 +121,7 @@ services:
|
||||
lazy: true
|
||||
arguments:
|
||||
$jobs: !tagged_iterator chill_main.cron_job
|
||||
|
||||
Chill\MainBundle\Service\EntityInfo\ViewEntityInfoManager:
|
||||
arguments:
|
||||
$vienEntityInfoProviders: !tagged_iterator chill_main.entity_info_provider
|
||||
|
4
src/Bundle/ChillMainBundle/config/services/clock.yaml
Normal file
4
src/Bundle/ChillMainBundle/config/services/clock.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
# temporary, waiting for symfony 6.0 to load clock
|
||||
services:
|
||||
Symfony\Component\Clock\NativeClock: ~
|
||||
Symfony\Component\Clock\ClockInterface: '@Symfony\Component\Clock\NativeClock'
|
@@ -67,3 +67,7 @@ services:
|
||||
autowire: true
|
||||
tags:
|
||||
- {name: console.command }
|
||||
|
||||
Chill\MainBundle\Command\SynchronizeEntityInfoViewsCommand:
|
||||
tags:
|
||||
- {name: console.command}
|
||||
|
@@ -564,6 +564,7 @@ export:
|
||||
_as_string: Adresse formattée
|
||||
confidential: Adresse confidentielle ?
|
||||
isNoAddress: Adresse incomplète ?
|
||||
steps: Escaliers
|
||||
_lat: Latitude
|
||||
_lon: Longitude
|
||||
|
||||
|
Reference in New Issue
Block a user