bibcite-8.x-1.x-dev/bibcite.install
bibcite.install
<?php
/**
* @file
* Module installation hooks implementation.
*/
/**
* Implements hook_requirements().
*/
function bibcite_requirements($phase) {
$requirements = [];
switch ($phase) {
case 'runtime':
case 'install':
if (!class_exists('\Seboettg\CiteProc\CiteProc') || !class_exists('\ADCI\FullNameParser\Parser')) {
$requirements['bibcite_dependencies'] = [
'title' => t('Bibliography & Citation dependencies'),
'description' => t("Bibliography & Citation requires the seboettg/citeproc-php and adci/full-name-parser libraries. See the module's README.md file for more information."),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Delete "links" from bibcite.settings configuration.
*/
function bibcite_update_8001() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('bibcite.settings');
$config->clear('links');
$config->save(TRUE);
}
/**
* Add config_export property to CSL style config entity.
*/
function bibcite_update_8002() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
// Update CSL style entity.
$bibcite_csl_style = $definition_update_manager->getEntityType('bibcite_csl_style');
$bibcite_csl_style->set('config_export', [
'id',
'parent',
'label',
'csl',
'updated',
'custom',
'url_id',
'override',
'preview_mode',
'citekey_pattern',
'fields',
]);
$definition_update_manager->updateEntityType($bibcite_csl_style);
}
