commerce_inventory-8.x-1.0-alpha6/modules/commerce_inventory_store/commerce_inventory_store.module

modules/commerce_inventory_store/commerce_inventory_store.module
<?php

/**
 * @file
 * Contains commerce_inventory_store.module.
 */

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function commerce_inventory_store_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the commerce_inventory_store module.
    case 'help.page.commerce_inventory_store':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Allows Commerce Inventory to work with Commerce Store entities.') . '</p>';
      return $output;

    default:
  }
}

/**
 * Implements hook_entity_base_field_info().
 */
function commerce_inventory_store_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'commerce_store') {
    $fields = [];
    $fields['commerce_inventory_locations'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Inventory Locations'))
      ->setDescription(t('Allow this store to use inventory from certain locations. Order locations by preferred use.'))
      ->setCardinality(-1)
      ->setSetting('target_type', 'commerce_inventory_location')
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
    return $fields;
  }
}

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

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