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

Support the ignore of config collections #17

Open
wants to merge 2 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

jnpwebdeveloper
Copy link
Contributor

@jnpwebdeveloper jnpwebdeveloper commented Aug 1, 2017

We have a situation where we wish to ignore entire collections. An example would be having languages turned on but we don't necessarily want this all to be exported to config. Currently there is now way to ignore those with the file_scan_directory method using patterns. So I have added an additional option to specify a collection to ignore.

Example:

ignore_collection:
  - language.sw

Would ignore and remove the Swedish language collection and also remove the collection root directory if empty.

Have also fixed a few formatting issues where there were two spaces instead of one after the equals sign.

@yareckon
Copy link

Having this would be great thanks! We also want to ignore a whole language collection. Is there a current workaround to do this? If not, it would be very important to get this functionality in.

@larowlan
Copy link
Member

Hey, I'm not familiar with collections - can you give me some more background/link to some docs?

Thanks

@jnpwebdeveloper
Copy link
Contributor Author

Hi @larowlan, been a while but I'll try to explain it as best as I can. Basically for languages for example you can have multiple variations of the same variables for languages. In that instance I was referring to, we had for instance one code base for multiple languages. We didn't want to commit each language to the repository so we wanted to ignore entire collections. E.g. sw for the swedish language. Here is perhaps a better description as to its purpose:
https://www.drupal.org/node/2268523

Copy link
Member

@larowlan larowlan left a comment

Choose a reason for hiding this comment

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

Thanks, I didn't know that collections existed - so thanks for the learning opportunity.

Couple of minor comments

@@ -87,24 +88,40 @@ function drush_drush_cmi_tools_config_export_plus($destination = NULL) {
catch (InvalidDataTypeException $e) {
$ignore_list_error = TRUE;
}
if (!isset($parsed['ignore']) || !is_array($parsed['ignore'])) {
if (!isset($parsed['ignore']) || !is_array($parsed['ignore']) || !isset($parsed['ignore_collection']) || !is_array($parsed['ignore_collection'])) {
Copy link
Member

Choose a reason for hiding this comment

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

this is a hard break - can we make existing config-ignore.yml files that don't have the ignore_collection key continue to work?

e.g. we could

$parsed += ['ignore_collection' => []];
``

}
$collection_directories = explode('/', $collection_dir);
$collection_root_dir = $destination_dir . '/' . reset($collection_directories);
if (is_dir($collection_root_dir) && (count(scandir($collection_root_dir)) == 2)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a comment here about what this is doing? The 2 seems magical.

Can we use glob here - if all we're doing is removing directories that match the ignore_collection key?

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

Successfully merging this pull request may close these issues.

3 participants