mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Partage d'export enregistré et génération asynchrone des exports
This commit is contained in:
@@ -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\Utils\Rector\Tests\ChillBundleAddNormalizationMethodsOnExportRector;
|
||||
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ChillBundleAddNormalizationMethodsOnExportRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData
|
||||
*/
|
||||
public function test(string $file): void
|
||||
{
|
||||
$this->doTestFile($file);
|
||||
}
|
||||
|
||||
public static function provideData(): \Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__.'/Fixture');
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
return __DIR__.'/config/config.php';
|
||||
}
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('field', ChoiceType::class, [
|
||||
'choices' => ['one', 'two', 'three', 'four', 'five'],
|
||||
'multiple' => false,
|
||||
])
|
||||
->add('entity', EntityType::class, [])
|
||||
->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, [])
|
||||
->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class)
|
||||
->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
use \Chill\MainBundle\Export\ExportDataNormalizerTrait;
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('field', ChoiceType::class, [
|
||||
'choices' => ['one', 'two', 'three', 'four', 'five'],
|
||||
'multiple' => false,
|
||||
])
|
||||
->add('entity', EntityType::class, [])
|
||||
->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, [])
|
||||
->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class)
|
||||
->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
|
||||
}
|
||||
public function getNormalizationVersion(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public function normalizeFormData(array $formData): array
|
||||
{
|
||||
return ['field' => $formData['field'], 'entity' => $this->normalizeDoctrineEntity($formData['entity']), 'user' => $this->normalizeDoctrineEntity($formData['user']), 'rolling_date' => $formData['rolling_date']->normalize(), 'date' => $this->normalizeDate($formData['date'])];
|
||||
}
|
||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||
{
|
||||
return ['field' => $formData['field'], 'entity' => $this->denormalizeDoctrineEntity($formData['entity'], $this->someRepository), 'user' => $this->denormalizeDoctrineEntity($formData['user'], $this->someRepository), 'rolling_date' => \Chill\MainBundle\Service\RollingDate\RollingDate::fromNormalized($formData['rolling_date']), 'date' => $this->denormalizeDate($formData['date'])];
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('field', ChoiceType::class, [
|
||||
'choices' => ['one', 'two', 'three', 'four', 'five'],
|
||||
'multiple' => false,
|
||||
]);
|
||||
|
||||
$builder->add('entity', EntityType::class, []);
|
||||
|
||||
$builder->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []);
|
||||
|
||||
$builder->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class);
|
||||
|
||||
$builder->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
use \Chill\MainBundle\Export\ExportDataNormalizerTrait;
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('field', ChoiceType::class, [
|
||||
'choices' => ['one', 'two', 'three', 'four', 'five'],
|
||||
'multiple' => false,
|
||||
]);
|
||||
|
||||
$builder->add('entity', EntityType::class, []);
|
||||
|
||||
$builder->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []);
|
||||
|
||||
$builder->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class);
|
||||
|
||||
$builder->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
|
||||
}
|
||||
public function getNormalizationVersion(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public function normalizeFormData(array $formData): array
|
||||
{
|
||||
return ['field' => $formData['field'], 'entity' => $this->normalizeDoctrineEntity($formData['entity']), 'user' => $this->normalizeDoctrineEntity($formData['user']), 'rolling_date' => $formData['rolling_date']->normalize(), 'date' => $this->normalizeDate($formData['date'])];
|
||||
}
|
||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||
{
|
||||
return ['field' => $formData['field'], 'entity' => $this->denormalizeDoctrineEntity($formData['entity'], $this->someRepository), 'user' => $this->denormalizeDoctrineEntity($formData['user'], $this->someRepository), 'rolling_date' => \Chill\MainBundle\Service\RollingDate\RollingDate::fromNormalized($formData['rolling_date']), 'date' => $this->denormalizeDate($formData['date'])];
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\MainBundle\Export\ExportDataNormalizerTrait;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
use ExportDataNormalizerTrait;
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('entity', EntityType::class, []);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\MainBundle\Export\ExportDataNormalizerTrait;
|
||||
|
||||
class MyFilter implements FilterInterface
|
||||
{
|
||||
use ExportDataNormalizerTrait;
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('entity', EntityType::class, []);
|
||||
}
|
||||
public function getNormalizationVersion(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public function normalizeFormData(array $formData): array
|
||||
{
|
||||
return ['entity' => $this->normalizeDoctrineEntity($formData['entity'])];
|
||||
}
|
||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||
{
|
||||
return ['entity' => $this->denormalizeDoctrineEntity($formData['entity'], $this->someRepository)];
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
|
||||
class MyFilterUpdated implements FilterInterface
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "some title";
|
||||
}
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function normalizeFormData(array $formData): array
|
||||
{
|
||||
return $formData;
|
||||
}
|
||||
|
||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||
{
|
||||
return $formData;
|
||||
}
|
||||
|
||||
public function getNormalizationVersion(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return ['something'];
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function doSomething(): void
|
||||
{
|
||||
// dummy
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
return static function (Rector\Config\RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->rule(Chill\Utils\Rector\Rector\ChillBundleAddNormalizationMethodsOnExportRector::class);
|
||||
};
|
Reference in New Issue
Block a user