Skip to content

Instantly share code, notes, and snippets.

@plepe

plepe/copy.php

Last active Mar 15, 2019
Embed
What would you like to do?
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
You can’t perform that action at this time.