rewrite export controller and manager

- upgrade to symfony 4 ;
- add support for directExportInterface
This commit is contained in:
2019-01-15 20:18:47 +01:00
parent f937e9d12c
commit 6741eb949c
3 changed files with 130 additions and 48 deletions

View File

@@ -0,0 +1,15 @@
<?php
/*
*
*/
namespace Chill\MainBundle\Export;
use Symfony\Component\HttpFoundation\Response;
/**
*
*/
interface DirectExportInterface extends ExportElementInterface
{
//put your code here
}

View File

@@ -148,12 +148,18 @@ class ExportManager
*
* @internal used by DI
*
* @param ExportInterface $export
* @param ExportInterface|DirectExportInterface $export
* @param type $alias
*/
public function addExport(ExportInterface $export, $alias)
public function addExport($export, $alias)
{
$this->exports[$alias] = $export;
if ($export instanceof ExportInterface || $export instanceof DirectExportInterface) {
$this->exports[$alias] = $export;
} else {
throw new \InvalidArgumentException(sprintf("The export with alias %s "
. "does not implements %s or %s.", $alias, ExportInterface::class,
DirectExportInterface::class));
}
}
/**
@@ -426,6 +432,11 @@ class ExportManager
//$qb = $this->em->createQueryBuilder();
$centers = $this->getPickedCenters($pickedCentersData);
if ($export instanceof DirectExportInterface) {
return $export->generate($this->buildCenterReachableScopes($centers, $export),
$data[ExportType::EXPORT_KEY]);
}
$query = $export->initiateQuery(
$this->retrieveUsedModifiers($data),
$this->buildCenterReachableScopes($centers, $export),