-
Notifications
You must be signed in to change notification settings - Fork 3
/
commerce_xattributes.module
34 lines (31 loc) · 1.7 KB
/
commerce_xattributes.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* @file
* Contains commerce_xattributes.module.
*/
use Drupal\commerce_xattributes\Entity\XattributesProductAttribute;
use Drupal\commerce_xattributes\Form\XattributesProductAttributeForm;
use Drupal\commerce_xattributes\XattributesProductAttributeListBuilder;
use Drupal\commerce_xattributes\Form\XattributesProductVariationTypeForm;
/**
* Implements hook_entity_type_alter().
*/
function commerce_xattributes_entity_type_alter(array &$entity_types) {
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
$entity_keys = $entity_types["commerce_product_attribute"]->get('entity_keys');
$entity_keys['elementLabel'] = 'elementLabel';
$entity_types["commerce_product_attribute"]->set('entity_keys', $entity_keys);
$config_export = $entity_types["commerce_product_attribute"]->get('config_export');
$config_export[] = 'elementLabel';
$entity_types["commerce_product_attribute"]->set('config_export', $config_export);
$entity_types["commerce_product_attribute"]->setClass(XattributesProductAttribute::class);
$form = $entity_types["commerce_product_attribute"]->getHandlerClasses()['form'];
$form['add'] = XattributesProductAttributeForm::class;
$form['edit'] = XattributesProductAttributeForm::class;
$entity_types["commerce_product_attribute"]->setHandlerClass('form', $form);
$entity_types["commerce_product_attribute"]->setListBuilderClass(XattributesProductAttributeListBuilder::class);
$form = $entity_types["commerce_product_variation_type"]->getHandlerClasses()['form'];
$form['add'] = XattributesProductVariationTypeForm::class;
$form['edit'] = XattributesProductVariationTypeForm::class;
$entity_types["commerce_product_variation_type"]->setHandlerClass('form', $form);
}