You are here

price.install in Price 2.0.x

Same filename and directory in other branches
  1. 8 price.install
  2. 3.x price.install
  3. 2.x price.install
  4. 3.0.x price.install

Contains install and update functions for Price.

File

price.install
View 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

Namesort descending Description
price_install Implements hook_install().
price_requirements Implements hook_requirements().