Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
is it possible to create another folder while executing hook_features_export_render()? I have to export additional files that shall be saved as a file and not inline.
Comments
Comment #1
hefox CreditAttribution: hefox commentedOff top of head, I doubt it as it'd need to call mkdir if the directory doesn't exist, and if no one else is already doing it, it's unlikely the code is in it to do it.
Comment #2
mpotter CreditAttribution: mpotter commentedCan you explain your use-case in more detail?
Comment #3
Andre-BI tried to export files from some content types and did not want them to be inline.
Comment #4
mpotter CreditAttribution: mpotter commentedYou mean fields? A content type is just a few lines of code. No reason to put those into separate files. Maybe you want to export them to different features to get them into different files? Sounds like maybe your feature is too big?
Comment #5
donquixote CreditAttribution: donquixote as a volunteer commentedFor the record: If you are programming your own module with a new features component type, you can implement hook_features_export_files() to add additional files.
@mpotter is right, a content type itself is just a few lines of code.
However all the strongarm, field_instance and field_base exported along with it leads to notoriously huge files, and are a frequent cause of merge conflicts.
Having this split up into one file per item (per field instance, etc) would be a huge DX improvement.
Something I noticed (how I found this thread) is that the mkdir in _drush_features_export() is not recursive, so it only creates one level of directories. See #3060408: Support nested subdirectories for $files['_files'].