commerce-8.x-2.8/modules/product/tests/modules/commerce_product_test/commerce_product_test.module

modules/product/tests/modules/commerce_product_test/commerce_product_test.module
<?php

/**
 * @file
 * Test module for Commerce Product.
 */

use Drupal\commerce_product\Entity\ProductVariationInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Implements hook_entity_access().
 */
function commerce_product_test_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($entity instanceof ProductVariationInterface) {
    if ($operation == 'view') {
      return AccessResult::forbiddenIf(strpos($entity->getSku(), 'DENY') !== FALSE);
    }
  }
  return AccessResult::neutral();
}

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

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