Skip to content

Instantly share code, notes, and snippets.

@mortenson
Created May 12, 2017 21:40
Show Gist options
  • Save mortenson/04bc8e84f3fefbd7ac9404d047d50526 to your computer and use it in GitHub Desktop.
Save mortenson/04bc8e84f3fefbd7ac9404d047d50526 to your computer and use it in GitHub Desktop.
Have some 8.2 module/distro config for form or view displays? Use this to add a region to all your fields. Buyer beware!
<?php
# Run this with drush scr, silly!
use Drupal\Core\Serialization\Yaml;
foreach (file_scan_directory('.', '/core\.entity_.*display.*\.yml/') as $file) {
$filepath = realpath($file->uri);
$yml = Yaml::decode(file_get_contents($filepath));
if (isset($yml['content'])) {
foreach ($yml['content'] as &$field) {
if (!isset($field['region'])) {
$field['region'] = 'content';
}
}
}
file_put_contents($filepath, Yaml::encode($yml));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment