Skip to content

Instantly share code, notes, and snippets.

@plepe
Last active March 15, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plepe/7757ee936b08ea40909dd8a96f2cebb9 to your computer and use it in GitHub Desktop.
Save plepe/7757ee936b08ea40909dd8a96f2cebb9 to your computer and use it in GitHub Desktop.
Drupal 8: A script to copy settings from manage display for "search result" of bibcite to all other bibcite types.
<?php
$db = new PDO('mysql:dbname=drupal8', '', '');
$res = $db->query("select * from config where name='core.entity_view_display.bibcite_reference.conference_paper.search_result'");
$elem = $res->fetch();
$orig_data = unserialize($elem['data']);
$res = $db->query("select * from config where name like 'bibcite_entity.bibcite_reference_type.%'");
$types = array();
while ($elem = $res->fetch()) {
$type = substr($elem['name'], 38);
if ($type !== 'conference_paper') {
$types[] = $type;
}
}
foreach ($types as $type) {
$id = "core.entity_view_display.bibcite_reference.{$type}.search_result";
$res = $db->query("select * from config where name=" . $db->quote($id));
$elem = $res->fetch();
$data = unserialize($elem['data']);
$data['third_party_settings'] = $orig_data['third_party_settings'];
$data['content'] = $orig_data['content'];
$new_data = serialize($data);
$db->query("update config set data=" . $db->quote($new_data) . " where name=" . $db->quote($id));
}
print "Don't forget to clear the cache (drush cr)!\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment