Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.4.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Feb 17, 2025
2 parents 19a286b + 3eeac99 commit f85dd1d
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to Roadiz will be documented in this file.

## [2.4.15](https://github.com/roadiz/core-bundle-dev-app/compare/v2.4.14...v2.4.15) - 2025-02-17

### Bug Fixes

- **(RozierBundle)** Added configurable csv_encoder_options - ([ebb7fab](https://github.com/roadiz/core-bundle-dev-app/commit/ebb7fab7d9c462a69a7b10769bed1ea3eb86308c))

## [2.4.14](https://github.com/roadiz/core-bundle-dev-app/compare/v2.4.13...v2.4.14) - 2025-02-13

### Bug Fixes
Expand Down
2 changes: 2 additions & 0 deletions config/packages/roadiz_rozier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ parameters:
env(OPEN_ID_CLIENT_SECRET): ''
roadiz_rozier:
theme_dir: 'lib/Rozier/src'
csv_encoder_options:
csv_delimiter: ';'
open_id:
# Verify User info in JWT at each login
verify_user_info: false
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
roadiz_core.cms_version: '2.4.14'
roadiz_core.cms_version: '2.4.15'
roadiz_core.cms_version_prefix: 'main'
env(APP_NAMESPACE): "roadiz"
env(APP_VERSION): "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions lib/RoadizRozierBundle/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
$allowNodeTypeEdition: '%kernel.debug%'
$forceSslOnRedirectUri: '%roadiz_rozier.open_id.force_ssl_on_redirect_uri%'
$useGravatar: '%roadiz_core.use_gravatar%'
$csvEncoderOptions: '%roadiz_rozier.csv_encoder_options%'

RZ\Roadiz\RozierBundle\:
resource: '../src/'
Expand Down
39 changes: 33 additions & 6 deletions lib/RoadizRozierBundle/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace RZ\Roadiz\RozierBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Themes\Rozier\Forms\Node\AddNodeType;
use Themes\Rozier\Forms\NodeType;

class Configuration implements ConfigurationInterface
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down Expand Up @@ -59,15 +58,13 @@ public function getConfigTreeBuilder(): TreeBuilder
->end() // entries
->end()
->append($this->addOpenIdNode())
->append($this->addCsvNode())
;

return $builder;
}

/**
* @return ArrayNodeDefinition|NodeDefinition
*/
protected function addOpenIdNode()
protected function addOpenIdNode(): NodeDefinition
{
$builder = new TreeBuilder('open_id');
$node = $builder->getRootNode();
Expand Down Expand Up @@ -151,4 +148,34 @@ protected function addOpenIdNode()

return $node;
}

protected function addCsvNode(): NodeDefinition
{
$builder = new TreeBuilder('csv_encoder_options');
$node = $builder->getRootNode();
$builder->getRootNode()->addDefaultsIfNotSet()
->info('https://symfony.com/doc/6.4/serializer/encoders.html#the-csvencoder')
->children()
->scalarNode('csv_delimiter')
->defaultValue(',')
->end()
->scalarNode('csv_enclosure')
->defaultValue('"')
->end()
->scalarNode('csv_escape_char')
->defaultValue('')
->end()
->scalarNode('csv_end_of_line')
->defaultValue("\n")
->end()
->scalarNode('csv_key_separator')
->defaultValue('.')
->end()
->booleanNode('output_utf8_bom')
->defaultFalse()
->end()
->end();

return $node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function load(array $configs, ContainerBuilder $container): void
$projectDir.DIRECTORY_SEPARATOR.trim($config['theme_dir'], "/ \t\n\r\0\x0B")
);

$container->setParameter(
'roadiz_rozier.csv_encoder_options',
$config['csv_encoder_options'],
);

$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/../config'));
$loader->load('services.yaml');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(
private readonly TranslatorInterface $translator,
private readonly CustomFormAnswerSerializer $customFormAnswerSerializer,
private readonly SerializerInterface $serializer,
private readonly array $csvEncoderOptions,
) {
}

Expand Down Expand Up @@ -54,6 +55,7 @@ public function exportAction(Request $request, int $id): Response

$response = new StreamedResponse(function () use ($answersArray, $keys) {
echo $this->serializer->serialize($answersArray, 'csv', [
...$this->csvEncoderOptions,
'csv_headers' => $keys,
]);
});
Expand Down
2 changes: 2 additions & 0 deletions lib/Rozier/src/Controllers/Nodes/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ExportController extends RozierApp
public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly SerializerInterface $serializer,
private readonly array $csvEncoderOptions,
) {
}

Expand Down Expand Up @@ -64,6 +65,7 @@ public function exportAllAction(int $translationId, ?int $parentNodeId = null):

$response = new StreamedResponse(function () use ($sources) {
echo $this->serializer->serialize($sources, 'csv', [
...$this->csvEncoderOptions,
'groups' => [
'nodes_sources',
'urls',
Expand Down
2 changes: 2 additions & 0 deletions lib/Rozier/src/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function __construct(
protected readonly ManagerRegistry $managerRegistry,
protected readonly FormFactoryInterface $formFactory,
protected readonly SerializerInterface $serializer,
protected readonly array $csvEncoderOptions,
) {
}

Expand Down Expand Up @@ -376,6 +377,7 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
$filename = 'search-'.$nodetype->getName().'-'.date('YmdHis').'.csv';
$response = new StreamedResponse(function () use ($entities) {
echo $this->serializer->serialize($entities, 'csv', [
...$this->csvEncoderOptions,
'groups' => [
'nodes_sources',
'urls',
Expand Down

0 comments on commit f85dd1d

Please sign in to comment.