|
|
@@ -21,12 +21,10 @@ use Twig\Environment;
|
|
|
*/
|
|
|
abstract class BaseExporter implements ExporterInterface
|
|
|
{
|
|
|
- const TEMPLATE = '';
|
|
|
-
|
|
|
// dependencies injections
|
|
|
protected AccessRepository $accessRepository;
|
|
|
protected Environment $twig;
|
|
|
- protected EncoderIterator $encoderHandler;
|
|
|
+ protected EncoderIterator $encoderIterator;
|
|
|
protected EntityManagerInterface $entityManager;
|
|
|
protected TemporaryFileStorage $storage;
|
|
|
protected LoggerInterface $logger;
|
|
|
@@ -36,7 +34,7 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
#[Required]
|
|
|
public function setTwig(Environment $twig) { $this->twig = $twig; }
|
|
|
#[Required]
|
|
|
- public function setEncoderHandler(EncoderIterator $encoderHandler) { $this->encoderHandler = $encoderHandler; }
|
|
|
+ public function setEncoderIterator(EncoderIterator $encoderIterator) { $this->encoderIterator = $encoderIterator; }
|
|
|
#[Required]
|
|
|
public function setEntityManager(EntityManagerInterface $entityManager) { $this->entityManager = $entityManager; }
|
|
|
#[Required]
|
|
|
@@ -111,7 +109,7 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
* @return ExportModelInterface
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- function buildModel(ExportRequest $exportRequest): ExportModelInterface
|
|
|
+ protected function buildModel(ExportRequest $exportRequest): ExportModelInterface
|
|
|
{
|
|
|
throw new Exception('not implemented error');
|
|
|
}
|
|
|
@@ -125,8 +123,14 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
*/
|
|
|
protected function getBasename(): string
|
|
|
{
|
|
|
+ $arr = explode('\\', static::class);
|
|
|
+ $classname = end($arr);
|
|
|
return StringsUtils::camelToSnake(
|
|
|
- preg_replace('/^([\w\d]+)Exporter$/', '$1', self::class, 1)
|
|
|
+ preg_replace(
|
|
|
+ '/^([\w\d]+)Exporter$/',
|
|
|
+ '$1',
|
|
|
+ $classname,
|
|
|
+ 1)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -145,11 +149,11 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
* @return string Rendu HTML
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- function render(ExportModelInterface $model): string
|
|
|
+ protected function render(ExportModelInterface $model): string
|
|
|
{
|
|
|
try {
|
|
|
return $this->twig->render(
|
|
|
- '@templates/export/licence_cmf.html.twig',
|
|
|
+ $this->getTemplatePath(),
|
|
|
['model' => $model]
|
|
|
);
|
|
|
}
|
|
|
@@ -168,7 +172,7 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
*/
|
|
|
protected function encode(string $html, string $format): string
|
|
|
{
|
|
|
- $encoder = $this->encoderHandler->getEncoderFor($format);
|
|
|
+ $encoder = $this->encoderIterator->getEncoderFor($format);
|
|
|
return $encoder->encode($html);
|
|
|
}
|
|
|
|
|
|
@@ -189,7 +193,7 @@ abstract class BaseExporter implements ExporterInterface
|
|
|
* @return mixed
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- function store(string $name, string $content): string
|
|
|
+ protected function store(string $name, string $content): string
|
|
|
{
|
|
|
return $this->storage->write($name, $content);
|
|
|
}
|