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

Deprecate exporter class and service #4029

Merged
merged 8 commits into from
Mar 12, 2017

Conversation

greg0ire
Copy link
Contributor

@greg0ire greg0ire commented Jul 29, 2016

I am targetting this branch, because this is BC

Closes #3124 , #1550 (I think)

Changelog

### Changed
- The export and list actions now integrate the sonata exporter bundle

### Deprecated
- Exporter class and service : use equivalents from `sonata-project/exporter` instead.

To do

  • Wait for 1.6.0 to be released
  • Fix symfony 2.3 compatibility problem (the deprecated tag is not supported)
  • Wait for 1.7.0 to be released
  • Refactor CrudController::exportAction() to use a dedicated, unit-tested service when available
  • Create the sonata.admin.admin_exporter service when the exporter bundle is registered
  • Use getAvailableFormats() to display the formats list
  • Document all this

Subject

This deprecates the export class and service

@greg0ire greg0ire force-pushed the deprecate_exporter branch 4 times, most recently from 1d2a922 to 1d06d9b Compare July 30, 2016 11:44
@greg0ire
Copy link
Contributor Author

Shit, I can't deprecate services in old versions of symfony…

@greg0ire greg0ire force-pushed the deprecate_exporter branch 2 times, most recently from c903a46 to b51fb4b Compare July 30, 2016 16:57
@greg0ire
Copy link
Contributor Author

greg0ire commented Aug 1, 2016

Fixed. Please review @sonata-project/contributors

@greg0ire
Copy link
Contributor Author

greg0ire commented Aug 16, 2016

Hmmm… there is another problem : getExportFormats() I think this method should be taken into account only if it differs from the default formats, and I need sonata-project/exporter@0f642e1 to get them. @soullivaneuh , can you release exporter 1.7.0 ? Also, can I require 1.7.0 without this being considered major? Won't solve my problem since you have to register the bundle to get the service…
Otherwise the code will get really ugly, b/c I will have to check that the service exists AND that the getAvailableFormats() method exists. I'll add a conflict in composer.json.

@OskarStark
Copy link
Member

OskarStark commented Aug 17, 2016

getAvailableFormats is now available in 1.7.0 @greg0ire

@greg0ire
Copy link
Contributor Author

I know, but I realized that I took it into account when POSTing, but must also make sure the format list in the combo box is updated too.

use Exporter\Exporter;
use Sonata\AdminBundle\Admin\AdminInterface;

final class AdminExporter
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonata-project/contributors : if you have a better name for this service I'm all ears. I extracted this from CrudController::exportAction so that it can be easily unit tested.

@@ -66,6 +66,7 @@
)\\\(.*)@x';

const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw';
const DEFAULT_EXPORT_FORMATS = array('json', 'xml', 'csv', 'xls');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We can't override this constant and we only use it once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three times you mean. On the getter, in the new service, and in the test for the new service

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just read the diff...

You extracted a new constant which is only used once. So why did we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it, it is actually used 3 times now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay then 👍

@SonataCI
Copy link
Collaborator

Could you please rebase your PR and fix merge conflicts?

@core23
Copy link
Member

core23 commented Mar 12, 2017

Please rebase, so we can merge this @greg0ire

@greg0ire
Copy link
Contributor Author

@core23 done

@greg0ire
Copy link
Contributor Author

@sonata-project/contributors please merge

@@ -176,16 +176,19 @@ file that was distributed with this source code.
</div>


{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.getExportFormats) %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure, admin.getExportFormats will work the same as admin.getExportFormats()?

AFAIK you can do something like admin.exportFormats at twig will pick the getter.

If this works also, lets merge this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works also, but I can change it to your solution, which is more graceful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your decision, tell me when you want me to merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge when the build is green.

@jordisala1991 jordisala1991 merged commit f880155 into sonata-project:3.x Mar 12, 2017
@jordisala1991
Copy link
Member

Thanks @greg0ire !!

@greg0ire greg0ire deleted the deprecate_exporter branch March 12, 2017 11:12
@greg0ire
Copy link
Contributor Author

Finally! Thanks everyone!

@OskarStark
Copy link
Member

@greg0ire it would be great if you could remove the deprecated code afterwards on master

@greg0ire
Copy link
Contributor Author

@OskarStark will do!

@@ -65,6 +65,12 @@ All files under the ``Tests`` directory are now correctly handled as internal te
You can't extend them anymore, because they are only loaded when running internal tests.
More information can be found in the [composer docs](https://getcomposer.org/doc/04-schema.md#autoload-dev).

### Exporter service and class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again on the wrong place. Please be careful.

A check bot is very necessary for this IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh! Sorry…

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

Successfully merging this pull request may close these issues.

None yet

7 participants