commerce_shipping-8.x-2.0-rc2/commerce_shipping.module

commerce_shipping.module
<?php

/**
 * @file
 * Provides core shipping functionality.
 */

use Drupal\commerce_shipping\Hook\CommerceShippingHooks;
use Drupal\commerce_shipping\Hook\CommerceShippingThemeHooks;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\Core\Session\AccountInterface;

/**
 * Implements hook_commerce_entity_trait_info_alter().
 */
#[LegacyHook]
function commerce_shipping_commerce_entity_trait_info_alter(array &$definitions): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->commerceEntityTraitInfoAlter($definitions);
}

/**
 * Implements hook_entity_base_field_info().
 */
#[LegacyHook]
function commerce_shipping_entity_base_field_info(EntityTypeInterface $entity_type): array {
  return \Drupal::service(CommerceShippingHooks::class)
    ->entityBaseFieldInfo($entity_type);
}

/**
 * Implements hook_entity_bundle_info_alter().
 */
#[LegacyHook]
function commerce_shipping_entity_bundle_info_alter(array &$bundles): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->entityBundleInfoAlter($bundles);
}

/**
 * Implements hook_entity_form_display_alter().
 */
#[LegacyHook]
function commerce_shipping_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->entityFormDisplayAlter($form_display, $context);
}

/**
 * Implements hook_field_widget_single_element_form_alter().
 */
#[LegacyHook]
function commerce_shipping_field_widget_single_element_form_alter(array &$element, FormStateInterface $form_state, array $context): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->fieldWidgetSingleElementFormAlter($element, $form_state, $context);
}

/**
 * Implements hook_commerce_inline_form_PLUGIN_ID_alter().
 */
#[LegacyHook]
function commerce_shipping_commerce_inline_form_customer_profile_alter(array &$inline_form, FormStateInterface $form_state, array &$complete_form): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->commerceInlineFormCustomerProfileAlter($inline_form, $form_state, $complete_form);
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
#[LegacyHook]
function commerce_shipping_form_commerce_order_type_form_alter(array &$form, FormStateInterface $form_state): void {
  \Drupal::service(CommerceShippingHooks::class)
    ->formCommerceOrderTypeFormAlter($form, $form_state);
}

/**
 * Implements hook_entity_operation().
 */
#[LegacyHook]
function commerce_shipping_entity_operation(EntityInterface $entity): array {
  return \Drupal::service(CommerceShippingHooks::class)
    ->entityOperation($entity);
}

/**
 * Implements hook_theme().
 */
#[LegacyHook]
function commerce_shipping_theme(): array {
  return \Drupal::service(CommerceShippingThemeHooks::class)->theme();
}

/**
 * Implements hook_theme_suggestions_HOOK().
 */
#[LegacyHook]
function commerce_shipping_theme_suggestions_commerce_shipment(array $variables): array {
  return \Drupal::service(CommerceShippingThemeHooks::class)
    ->themeSuggestionsCommerceShipment($variables);
}

/**
 * Implements hook_entity_field_access().
 */
#[LegacyHook]
function commerce_shipping_entity_field_access(string $operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL): AccessResultInterface {
  return \Drupal::service(CommerceShippingHooks::class)
    ->entityFieldAccess($operation, $field_definition, $account, $items);
}

/**
 * Implements hook_preprocess_HOOK().
 */
#[LegacyHook]
function commerce_shipping_preprocess_commerce_order(array &$variables): void {
  \Drupal::service(CommerceShippingThemeHooks::class)->preprocessCommerceOrder($variables);
}

/**
 * Implements hook_preprocess_HOOK().
 */
#[LegacyHook]
function commerce_shipping_preprocess_commerce_order_receipt(array &$variables): void {
  \Drupal::service(CommerceShippingThemeHooks::class)->preprocessCommerceOrderReceipt($variables);
}

/**
 * Prepares variables for shipment templates.
 *
 * Default template: commerce-shipment.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - elements: An associative array containing rendered fields.
 *   - attributes: HTML attributes for the containing element.
 */
function template_preprocess_commerce_shipment(array &$variables) {
  \Drupal::service(CommerceShippingThemeHooks::class)->preprocessCommerceShipment($variables);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc