Problem/Motivation
It's useful to be able to specify bundles to export rather than exporting all bundles for an entity type. Patch attached adds a --bundles option to the drush 'dcer' command.
Steps to reproduce
drush dcer --help
Could not open input file: vendor/bin/drush
/var/www/html/web $ drush dcer --help
Exports an entity and all its referenced entities.
Arguments:
entity_type The entity type to export.
entity_id The ID of the entity to export.
Options:
--bundles=<article,page> A comma-separated list of bundles to limit export to.
--folder Folder to export to, entities are grouped by entity type into
directories.
Proposed resolution
Limiting queries by bundle list, throw exception when filter is not applicable (missing bundle field)
Remaining tasks
review/commit
User interface changes
no
API changes
no
Comments
Comment #2
nashkrammer commentedTested on core 8.5.8 for menu_link_content entity with bundle main. Patch works for with option --bundle
Comment #3
berdirI've recently created the 2.0.x branch, see the project page on all the improvements in the 2.0.x branch. Testing that and providing feedback would be very welcome. The 1.x branch isn't actively maintained and won't receive new features anymore.
I'm changing this to 2.x as it would be a useful feature there as well, but it needs to be rerolled and support for Drush9+ needs to be handled as well.
Comment #4
sonnyktThis patch checks for bundle support and adds support for Drush 9.
Comment #5
andypost++ to get this feature in but better configurable - to allow a list of bundles
Also tuned a bit new option documentation
Comment #6
sonnyktHi @andypost,
I see that you use
entityTypeManagerinstead of the originalentityQuery. TheexportContentWithReferencesmethod of the exporter expects an ID of the entity to export instead of the entity object. Is it an issue?Comment #7
andypost@sonnykt because no reason to instantiate storage handler twice
Better title and summary
Comment #8
johnwebdev commentedWe should use sprintf() to be consistent with the rest of the code base. Should this be an InvalidArgumentException instead?
Comment #9
andypost++ to #8
Comment #10
andypostHere's fixed patch
Comment #11
johnwebdev commentedComment #12
andypostLatest core patches using
sprintf()but the final decision is not made, see related #3118957: Evaluate replacing all usage of sprintf by dot concatenation or variable inside stringComment #13
johnwebdev commentedYes, but within Default Content we're currently using sprintf(), and that make this change consistent. So if core re-evaluates its use of sprintf, so can we, but in a follow up issue imo.
Comment #17
andypost@Rajeshreeputra any reason you're created MR? last patch applies
Comment #18
bladeduI confirm that patch #10 works perfectly.
Thanks!
Comment #19
berdirThere is a large overlap between this issue and #2786479: Drush comand to export all items from entity with defined criteria . This is easier to use for bundles and supports multiple values, but doesn't support common use cases like all links of a given menu. I recommend to join forces over there and address my review and merge in the useful bits from this like multiple values.
Comment #20
pearls commented+1 for the approach to this issue compared to the other one( #2786479).
I think bundle limit is useful and necessary.