commerce_price.install in Commerce Core 8.2
Same filename and directory in other branches
Contains install and update functions for Price.
File
modules/price/commerce_price.installView source
<?php
/**
* @file
* Contains install and update functions for Price.
*/
/**
* Implements hook_requirements().
*/
function commerce_price_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
if (!class_exists('\\CommerceGuys\\Intl\\Currency\\CurrencyRepository')) {
$requirements['commerce_price_intl'] = [
'title' => t('Intl library'),
'description' => t("Commerce Price requires the commerceguys/intl library."),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
function commerce_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('commerce_price.currency_importer');
$currency_importer
->importByCountry($default_country);
}
}
Functions
Name | Description |
---|---|
commerce_price_install | Implements hook_install(). |
commerce_price_requirements | Implements hook_requirements(). |