price.install in Price 2.x
Same filename and directory in other branches
Contains install and update functions for Price.
File
price.installView source
<?php
/**
* @file
* Contains install and update functions for Price.
*/
/**
* Implements hook_requirements().
*/
function price_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
if (!class_exists('\\CommerceGuys\\Intl\\Currency\\CurrencyRepository')) {
$requirements['price_intl'] = [
'title' => t('Intl library'),
'description' => t("Price requires the commerceguys/intl library."),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
function price_install() {
if (!\Drupal::isConfigSyncing()) {
// Import a currency to speed up initial store setup.
// If no default country is set, import the US Dollar, since it's common.
$default_country = \Drupal::config('system.date')
->get('country.default');
$default_country = $default_country ?: 'US';
$currency_importer = \Drupal::service('price.currency_importer');
$currency_importer
->importByCountry($default_country);
}
}
Functions
Name | Description |
---|---|
price_install | Implements hook_install(). |
price_requirements | Implements hook_requirements(). |