Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entry Point for Admin and Extensions to change Exported Data #1711

Open
Hanmac opened this issue Jan 16, 2023 · 5 comments
Open

Entry Point for Admin and Extensions to change Exported Data #1711

Hanmac opened this issue Jan 16, 2023 · 5 comments

Comments

@Hanmac
Copy link

Hanmac commented Jan 16, 2023

Feature Request

  • i got Fields with DateTime data. And i use Sonata-intl to change the timezone it displays to my defined one. (php timezone is UTC, while intl one is "Europe/Berlin")
  • I also changed the Filter to use the intl timezone was view_timezone so the Form used in the filter shows the intl time while still using the php time for the query (would be nice to better automate that, but that's a problem for later)
  • But that doesn't work for the Export Fields, i currently see no easy way to change the time getting exported from the php timezone to the intl one

so it would be nice to have a way to alter the data between getting it from the query and exporting it into the Exporter for csv or xml data

@Hanmac Hanmac added the feature label Jan 16, 2023
@VincentLanglet
Copy link
Member

You can implement your own DataSource, similar to https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/4.x/src/Exporter/DataSource.php#L21 which return the custom Iterator you want based on https://github.com/sonata-project/exporter/blob/3.x/src/Source/AbstractPropertySourceIterator.php with the override needed for the method getValue.

What could be done would be to change

return new DoctrineORMQuerySourceIterator($query->getDoctrineQuery(), $fields);

in SonataDoctrineORMAdminBundle to

$this->dataSourceIteratorFactory->createIterator($query->getDoctrineQuery(), $field);

in order to introduce a new extension point.

I move this to SonataDoctrineORMAdminBundle

@VincentLanglet VincentLanglet transferred this issue from sonata-project/SonataAdminBundle Jan 17, 2023
@Hanmac
Copy link
Author

Hanmac commented Jan 20, 2023

Interesting point out to the SourceIterator ... i especially find the DateTimeFormat interesting that maybe could be extended with DateTimeTimezone

@Hanmac
Copy link
Author

Hanmac commented Jan 23, 2023

Hm one thing that confuses me is why DoctrineORMQuerySourceIterator is part of the exporter module and not part of the SonataDoctrineORMAdminBundle 🤷

@VincentLanglet
Copy link
Member

Hm one thing that confuses me is why DoctrineORMQuerySourceIterator is part of the exporter module and not part of the SonataDoctrineORMAdminBundle 🤷

Because like any other sourceIterator (https://github.com/sonata-project/exporter/tree/1877816a03b96cadf1be03d1857d9ef11088778a/src/Source), it can be used without sonataAdmin

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants