You are here

uc_cart.install in Ubercart 8.4

Install, update and uninstall functions for the uc_cart module.

File

uc_cart/uc_cart.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the uc_cart module.
 */
use Drupal\Core\Url;
use Drupal\image\Entity\ImageStyle;
use Drupal\uc_order\Entity\OrderStatus;

/**
 * Implements hook_uninstall().
 */
function uc_cart_uninstall() {
  $statuses = OrderStatus::loadMultiple([
    'abandoned',
  ]);
  if (!empty($statuses)) {
    $status_names = [];
    foreach ($statuses as $status) {
      $status_names[] = $status
        ->label();

      // Allow this status to be deleted manually.
      $status
        ->setLocked(FALSE)
        ->save();
    }
    \Drupal::messenger()
      ->addWarning(\Drupal::translation()
      ->formatPlural(count($status_names), 'The order status %status has not been deleted. If you need to delete it, <a href=":url">please do so manually</a>.', 'The order statuses %statuses have not been deleted. If you need to delete them, <a href=":url">please do so manually</a>.', [
      '%status' => $status_names[0],
      '%statuses' => implode(', ', $status_names),
      ':url' => Url::fromRoute('uc_order.workflow')
        ->toString(),
    ]));
  }
  $styles = ImageStyle::loadMultiple([
    'uc_cart',
  ]);
  if (!empty($styles)) {
    $style_names = [];
    foreach ($styles as $style) {
      $style_names[] = $style
        ->label();
    }
    \Drupal::messenger()
      ->addWarning(\Drupal::translation()
      ->formatPlural(count($style_names), 'The image style %style has not been deleted. If you need to delete it, <a href=":url">please do so manually</a>.', 'The image styles %styles have not been deleted. If you need to delete them, <a href=":url">please do so manually</a>.', [
      '%style' => $style_names[0],
      '%styles' => implode(', ', $style_names),
      ':url' => Url::fromRoute('entity.image_style.collection')
        ->toString(),
    ]));
  }
}

Functions

Namesort descending Description
uc_cart_uninstall Implements hook_uninstall().