本文整理汇总了PHP中Drupal::moduleHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Drupal::moduleHandler方法的具体用法?PHP Drupal::moduleHandler怎么用?PHP Drupal::moduleHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal
的用法示例。
在下文中一共展示了Drupal::moduleHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
function setUp()
{
parent::setUp();
$this->installSchema('system', array('url_alias', 'router'));
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->installConfig(array('field', 'language'));
// Add English as a language.
$english = new Language(array('id' => 'en', 'name' => 'English'));
language_save($english);
// Add German as a language.
$german = new Language(array('id' => 'de', 'name' => 'Deutsch', 'weight' => -1));
language_save($german);
// Create the test text field.
entity_create('field_storage_config', array('name' => 'field_test_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_text', 'bundle' => 'entity_test', 'translatable' => FALSE))->save();
// Create the test translatable field.
entity_create('field_storage_config', array('name' => 'field_test_translatable_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_translatable_text', 'bundle' => 'entity_test', 'translatable' => TRUE))->save();
// Create the test entity reference field.
entity_create('field_storage_config', array('name' => 'field_test_entity_reference', 'entity_type' => 'entity_test', 'type' => 'entity_reference', 'settings' => array('target_type' => 'entity_test')))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test', 'translatable' => TRUE))->save();
$entity_manager = \Drupal::entityManager();
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager));
$chain_resolver = new ChainEntityResolver(array(new UuidResolver($entity_manager), new TargetIdResolver()));
// Set up the mock serializer.
$normalizers = array(new ContentEntityNormalizer($link_manager, $entity_manager, \Drupal::moduleHandler()), new EntityReferenceItemNormalizer($link_manager, $chain_resolver), new FieldItemNormalizer(), new FieldNormalizer());
$encoders = array(new JsonEncoder());
$this->serializer = new Serializer($normalizers, $encoders);
}
示例2: getModuleHandler
/**
* Get the module handler.
*
* @return \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler.
*/
protected function getModuleHandler()
{
if (!isset($this->moduleHandler)) {
$this->moduleHandler = \Drupal::moduleHandler();
}
return $this->moduleHandler;
}
示例3: insertTokenList
/**
* Inserts a form element with a list of available tokens.
*
* @param $form
* The form array to append the token list to.
* @param array $types
* An array of token types to use.
*/
public function insertTokenList(&$form, array $types = array()) {
if (\Drupal::moduleHandler()->moduleExists('token')) {
// Add the token tree UI.
$form['token_tree'] = array(
'#theme' => 'token_tree',
'#token_types' => $types,
'#dialog' => TRUE,
'#weight' => -90,
);
}
else {
$token_items = array();
foreach ($this->getAvailableTokens($types) as $type => $tokens) {
foreach ($tokens as $name => $info) {
$token_description = !empty($info['description']) ? $info['description'] : '';
$token_items[$type . ':' . $name] = "[$type:$name]" . ' - ' . $info['name'] . ': ' . $token_description;
}
}
if (count($token_items)) {
$form['tokens'] = array(
'#type' => 'details',
'#title' => t('Available tokens'),
'#weight' => -90,
);
$form['tokens']['list'] = array(
'#theme' => 'item_list',
'#items' => $token_items,
);
}
}
}
示例4: testViewsUiAutocompleteTag
/**
* Tests the views_ui_autocomplete_tag function.
*/
public function testViewsUiAutocompleteTag()
{
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
// Save 15 views with a tag.
$tags = array();
for ($i = 0; $i < 16; $i++) {
$suffix = $i % 2 ? 'odd' : 'even';
$tag = 'autocomplete_tag_test_' . $suffix . $this->randomMachineName();
$tags[] = $tag;
entity_create('view', array('tag' => $tag, 'id' => $this->randomMachineName()))->save();
}
// Make sure just ten results are returns.
$controller = ViewsUIController::create($this->container);
$request = $this->container->get('request_stack')->getCurrentRequest();
$request->query->set('q', 'autocomplete_tag_test');
$result = $controller->autocompleteTag($request);
$matches = (array) json_decode($result->getContent());
$this->assertEqual(count($matches), 10, 'Make sure the maximum amount of tag results is 10.');
// Make sure that matching by a certain prefix works.
$request->query->set('q', 'autocomplete_tag_test_even');
$result = $controller->autocompleteTag($request);
$matches = (array) json_decode($result->getContent());
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
foreach ($matches as $tag) {
$this->assertTrue(array_search($tag, $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag)));
}
// Make sure an invalid result doesn't return anything.
$request->query->set('q', $this->randomMachineName());
$result = $controller->autocompleteTag($request);
$matches = (array) json_decode($result->getContent());
$this->assertEqual(count($matches), 0, "Make sure an invalid tag doesn't return anything.");
}
示例5: testEntityInfoCacheModulesEnabled
/**
* Tests entity info cache after enabling a module with a dependency on an entity providing module.
*
* @see entity_cache_test_modules_enabled()
*/
function testEntityInfoCacheModulesEnabled()
{
\Drupal::moduleHandler()->install(array('entity_cache_test'));
$entity_type = \Drupal::state()->get('entity_cache_test');
$this->assertEqual($entity_type->getLabel(), 'Entity Cache Test', 'Entity info label is correct.');
$this->assertEqual($entity_type->getStorageClass(), 'Drupal\\Core\\Entity\\EntityDatabaseStorage', 'Entity controller class info is correct.');
}
示例6: createTestViews
/**
* Create test views from config.
*
* @param string $class
* The name of the test class. Installs the listed test views *in order*.
* @param array $modules
* The module directories to look in for test views.
*/
public static function createTestViews($class, array $modules)
{
$views = array();
while ($class) {
if (property_exists($class, 'testViews')) {
$views = array_merge($views, $class::$testViews);
}
$class = get_parent_class($class);
}
if (!empty($views)) {
$storage = \Drupal::entityManager()->getStorage('view');
$module_handler = \Drupal::moduleHandler();
foreach ($modules as $module) {
$config_dir = drupal_get_path('module', $module) . '/test_views';
if (!is_dir($config_dir) || !$module_handler->moduleExists($module)) {
continue;
}
$file_storage = new FileStorage($config_dir);
$available_views = $file_storage->listAll('views.view.');
foreach ($views as $id) {
$config_name = 'views.view.' . $id;
if (in_array($config_name, $available_views)) {
$storage->create($file_storage->read($config_name))->save();
}
}
}
}
// Rebuild the router once.
\Drupal::service('router.builder')->rebuild();
}
示例7: query
public function query()
{
// This can only work if we're authenticated in.
if (!\Drupal::currentUser()->isAuthenticated()) {
return;
}
// Don't filter if we're exposed and the checkbox isn't selected.
if (!empty($this->options['exposed']) && empty($this->value)) {
return;
}
// Hey, Drupal kills old history, so nodes that haven't been updated
// since HISTORY_READ_LIMIT are bzzzzzzzt outta here!
$limit = REQUEST_TIME - HISTORY_READ_LIMIT;
$this->ensureMyTable();
$field = "{$this->tableAlias}.{$this->realField}";
$node = $this->query->ensureTable('node_field_data', $this->relationship);
$clause = '';
$clause2 = '';
if (\Drupal::moduleHandler()->moduleExists('comment')) {
$ces = $this->query->ensureTable('comment_entity_statistics', $this->relationship);
$clause = "OR {$ces}.last_comment_timestamp > (***CURRENT_TIME*** - {$limit})";
$clause2 = "OR {$field} < {$ces}.last_comment_timestamp";
}
// NULL means a history record doesn't exist. That's clearly new content.
// Unless it's very very old content. Everything in the query is already
// type safe cause none of it is coming from outside here.
$this->query->addWhereExpression($this->options['group'], "({$field} IS NULL AND ({$node}.changed > (***CURRENT_TIME*** - {$limit}) {$clause})) OR {$field} < {$node}.changed {$clause2}");
}
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$enabled_link = Link::fromTextAndUrl(t('enabled'), Url::fromRoute('system.modules_list'));
$form['#attached']['library'][] = 'system/drupal.system';
$form['exclude_node_title_search'] = ['#type' => 'checkbox', '#title' => $this->t('Remove node title from search pages'), '#description' => $this->t('Select if you wish to remove title from search pages. You need to have Search module @link.', ['@link' => $enabled_link]), '#default_value' => $this->excludeNodeTitleManager->isSearchExcluded(), '#disabled' => !\Drupal::moduleHandler()->moduleExists('search')];
$form['content_type'] = ['#type' => 'fieldset', '#title' => $this->t('Exclude title by content types'), '#description' => $this->t('Define title excluding settings for each content type.'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE];
foreach ($this->bundleInfo->getBundleInfo('node') as $node_type => $node_type_info) {
$form['#attached']['drupalSettings']['exclude_node_title']['content_types'][$node_type] = $node_type_info['label'];
$form['content_type'][$node_type]['content_type_value'] = ['#type' => 'select', '#title' => $node_type_info['label'], '#default_value' => $this->excludeNodeTitleManager->getBundleExcludeMode($node_type), '#options' => ['none' => $this->t('None'), 'all' => $this->t('All nodes...'), 'user' => $this->t('User defined nodes...')]];
$entity_view_modes = $this->entityDisplayRepository->getViewModes('node');
$modes = [];
foreach ($entity_view_modes as $view_mode_name => $view_mode_info) {
$modes[$view_mode_name] = $view_mode_info['label'];
}
$modes += ['nodeform' => $this->t('Node form')];
switch ($form['content_type'][$node_type]['content_type_value']['#default_value']) {
case 'all':
$title = $this->t('Exclude title from all nodes in the following view modes:');
break;
case 'user defined':
$title = $this->t('Exclude title from user defined nodes in the following view modes:');
break;
default:
$title = $this->t('Exclude from:');
}
$form['content_type'][$node_type]['content_type_modes'] = ['#type' => 'checkboxes', '#title' => $title, '#default_value' => $this->excludeNodeTitleManager->getExcludedViewModes($node_type), '#options' => $modes, '#states' => ['invisible' => ['select[name="content_type[' . $node_type . '][content_type_value]"]' => ['value' => 'none']]]];
}
$form['#attached']['library'][] = 'exclude_node_title/drupal.exclude_node_title.admin';
return parent::buildForm($form, $form_state);
}
示例9: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Invoke hook_uc_order($op = 'submit') to test to make sure the order can
// be completed... used for auto payment in uc_credit.module.
$order = $form_state->get('uc_order');
$error = FALSE;
// Invoke it on a per-module basis instead of all at once.
$module_handler = \Drupal::moduleHandler();
foreach ($module_handler->getImplementations('uc_order') as $module) {
$function = $module . '_uc_order';
if (function_exists($function)) {
// $order must be passed by reference.
$result = $function('submit', $order, NULL);
$msg_type = 'status';
if ($result[0]['pass'] === FALSE) {
$error = TRUE;
$msg_type = 'error';
}
if (!empty($result[0]['message'])) {
drupal_set_message($result[0]['message'], $msg_type);
}
// Stop invoking the hooks if there was an error.
if ($error) {
break;
}
}
}
if ($error) {
$form_state->setRedirect('uc_cart.checkout_review');
} else {
unset($_SESSION['uc_checkout'][$order->id()]['do_review']);
$_SESSION['uc_checkout'][$order->id()]['do_complete'] = TRUE;
$form_state->setRedirect('uc_cart.checkout_complete');
}
}
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('uc_product.settings');
$form['product-settings'] = array('#type' => 'vertical_tabs');
$form['product'] = array('#type' => 'details', '#title' => $this->t('Product settings'), '#group' => 'product-settings', '#weight' => -10);
$form['product']['empty'] = array('#markup' => t('There are currently no settings choices for your products. When enabled, the Cart module and other modules that provide product features (such as Role assignment and File downloads) will add settings choices here.'));
$form['#submit'][] = array($this, 'submitForm');
if (\Drupal::moduleHandler()->moduleExists('uc_cart')) {
unset($form['product']['empty']);
$form['product']['uc_product_add_to_cart_qty'] = array('#type' => 'checkbox', '#title' => $this->t('Display an optional quantity field in the <em>Add to Cart</em> form.'), '#default_value' => $config->get('add_to_cart_qty'));
$form['product']['uc_product_update_node_view'] = array('#type' => 'checkbox', '#title' => $this->t('Update product display based on customer selections'), '#default_value' => $config->get('update_node_view'), '#description' => $this->t('Check this box to dynamically update the display of product information such as display-price or weight based on customer input on the add-to-cart form (e.g. selecting a particular attribute option).'));
}
foreach (\Drupal::moduleHandler()->invokeAll('uc_product_feature') as $feature) {
unset($form['product']['empty']);
if (isset($feature['settings']) && function_exists($feature['settings'])) {
$form[$feature['id']] = array('#type' => 'details', '#title' => $this->t('@feature settings', ['@feature' => $feature['title']]), '#group' => 'product-settings');
$form[$feature['id']] += $feature['settings']([], $form_state);
if (function_exists($feature['settings'] . '_validate')) {
$form['#validate'][] = $feature['settings'] . '_validate';
}
if (function_exists($feature['settings'] . '_submit')) {
$form['#submit'][] = $feature['settings'] . '_submit';
}
}
}
return parent::buildForm($form, $form_state);
}
示例11: alterForm
/**
* {@inheritdoc}
*/
public function alterForm(&$form)
{
$config = $this->getConfiguration();
// Add prefix
$form['lb'] = array('#type' => 'textfield', '#title' => t('Label'), '#size' => '10', '#default_value' => $config['lb']);
// Add prefix
$form['prefix'] = array('#type' => 'textfield', '#title' => t('Prefix'), '#size' => '100', '#description' => t('You can enter any html in here.'), '#default_value' => isset($config['prefix']) ? $config['prefix'] : '', '#prefix' => '<div class="field-prefix">', '#suffix' => '</div>');
$wrappers = array('lbw' => array('title' => t('Label wrapper')), 'ow' => array('title' => t('Outer wrapper')), 'fis' => array('title' => t('Field items')), 'fi' => array('title' => t('Field item')));
foreach ($wrappers as $wrapper_key => $value) {
$form[$wrapper_key] = array('#type' => 'checkbox', '#title' => $value['title'], '#prefix' => '<div class="ft-group ' . $wrapper_key . '">', '#default_value' => $config[$wrapper_key]);
$form[$wrapper_key . '-el'] = array('#type' => 'textfield', '#title' => t('Element'), '#size' => '10', '#description' => t('E.g. div, span, h2 etc.'), '#default_value' => $config[$wrapper_key . '-el'], '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
$form[$wrapper_key . '-cl'] = array('#type' => 'textfield', '#title' => t('Classes'), '#size' => '10', '#default_value' => $config[$wrapper_key . '-cl'], '#description' => t('E.g.') . ' field-expert', '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
$form[$wrapper_key . '-at'] = array('#type' => 'textfield', '#title' => t('Attributes'), '#size' => '20', '#default_value' => $config[$wrapper_key . '-at'], '#description' => t('E.g. name="anchor"'), '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
// Hide colon.
if ($wrapper_key == 'lbw') {
$form['lb-col'] = array('#type' => 'checkbox', '#title' => t('Show label colon'), '#default_value' => $config['lb-col'], '#attributes' => array('class' => array('colon-checkbox')), '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
}
if ($wrapper_key != 'lbw') {
$form[$wrapper_key . '-def-at'] = array('#type' => 'checkbox', '#title' => t('Add default attributes'), '#default_value' => $config[$wrapper_key . '-def-at'], '#suffix' => $wrapper_key == 'ow' ? '' : '</div><div class="clearfix"></div>', '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
} else {
$form['ft'][$wrapper_key . '-def-at'] = array('#markup' => '</div><div class="clearfix"></div>');
}
// Default classes for outer wrapper.
if ($wrapper_key == 'ow') {
$form[$wrapper_key . '-def-cl'] = array('#type' => 'checkbox', '#title' => t('Add default classes'), '#default_value' => $config[$wrapper_key . '-def-cl'], '#suffix' => '</div><div class="clearfix"></div>', '#states' => array('visible' => array(':input[name$="[' . $wrapper_key . ']"]' => array('checked' => TRUE))));
}
}
// Add suffix
$form['suffix'] = array('#type' => 'textfield', '#title' => t('Suffix'), '#size' => '100', '#description' => t('You can enter any html in here.'), '#default_value' => isset($config['suffix']) ? $config['suffix'] : '', '#prefix' => '<div class="field-suffix">', '#suffix' => '</div>');
// Token support.
if (\Drupal::moduleHandler()->moduleExists('token')) {
$form['tokens'] = array('#title' => t('Tokens'), '#type' => 'container', '#states' => array('invisible' => array('input[name="use_token"]' => array('checked' => FALSE))));
$form['tokens']['help'] = array('#theme' => 'token_tree', '#token_types' => 'all', '#global_types' => FALSE, '#dialog' => TRUE);
}
}
示例12: getOperations
/**
* {@inheritdoc}
*/
public function getOperations(EntityInterface $entity)
{
$operations = parent::getOperations($entity);
$destination = drupal_get_destination();
$default = $entity->isDefault();
$id = $entity->id();
// Get CSRF token service.
$token_generator = \Drupal::csrfToken();
// @TODO: permission checks.
if ($entity->status() && !$default) {
$operations['disable'] = array('title' => $this->t('Disable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'disable', 'domain' => $id)), 'weight' => 50);
} elseif (!$default) {
$operations['enable'] = array('title' => $this->t('Enable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'enable', 'domain' => $id)), 'weight' => 40);
}
if (!$default) {
$operations['default'] = array('title' => $this->t('Make default'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'default', 'domain' => $id)), 'weight' => 30);
$operations['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute('entity.domain.delete_form', array('domain' => $id)), 'weight' => 20);
}
// @TODO: inject this service?
$operations += \Drupal::moduleHandler()->invokeAll('domain_operations', array($entity));
foreach ($operations as $key => $value) {
if (isset($value['query']['token'])) {
$operations[$key]['query'] += $destination;
}
}
$default = \Drupal::service('domain.loader')->loadDefaultDomain();
// Deleting the site default domain is not allowed.
if ($id == $default->id()) {
unset($operations['delete']);
}
return $operations;
}
示例13: testFieldPermissions
function testFieldPermissions() {
$fields = array(
'fields[body][region]' => 'right',
'fields[test_field][region]' => 'left',
);
$this->config('ds_extras.settings')->set('field_permissions', TRUE)->save();
\Drupal::moduleHandler()->resetImplementations();
$this->dsSelectLayout();
$this->dsConfigureUI($fields);
// Create a node.
$settings = array('type' => 'article');
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertRaw('group-right', 'Template found (region right)');
$this->assertNoText('Test code field on node ' . $node->id(), 'Test code field not found');
// Give permissions.
$edit = array(
'authenticated[view node_author on node]' => 1,
'authenticated[view test_field on node]' => 1,
);
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
$this->drupalGet('node/' . $node->id());
$this->assertRaw('group-left', 'Template found (region left)');
$this->assertText('Test field plugin on node ' . $node->id(), 'Test field plugin found');
}
示例14: endpoint
/**
* {@inheritdoc}
*/
public function endpoint($hash)
{
$return = 0;
if (!empty($_POST)) {
$data = $_POST['data'];
$type = $_POST['type'];
switch ($type) {
case 'unsubscribe':
case 'profile':
case 'cleaned':
mailchimp_get_memberinfo($data['list_id'], $data['email'], TRUE);
break;
case 'upemail':
mailchimp_cache_clear_member($data['list_id'], $data['old_email']);
mailchimp_get_memberinfo($data['list_id'], $data['new_email'], TRUE);
break;
case 'campaign':
mailchimp_cache_clear_list_activity($data['list_id']);
mailchimp_cache_clear_campaign($data['id']);
break;
}
// Allow other modules to act on a webhook.
\Drupal::moduleHandler()->invokeAll('mailchimp_process_webhook', array($type, $data));
// Log event.
\Drupal::logger('mailchimp')->info('Webhook type {type} has been processed.', array('type' => $type));
$return = 1;
}
// TODO: There should be a better way of doing this.
// D8 routing doesn't seem to allow us to return a single character
// or string from a controller.
echo $return;
exit;
}
示例15: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$form = parent::form($form, $form_state);
/** @var \Drupal\commerce_product\Entity\ProductVariationTypeInterface $variation_type */
$variation_type = $this->entity;
$form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $variation_type->label(), '#required' => TRUE];
$form['id'] = ['#type' => 'machine_name', '#default_value' => $variation_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductVariationType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH];
$form['generateTitle'] = ['#type' => 'checkbox', '#title' => t('Generate variation titles based on attribute values.'), '#default_value' => $variation_type->shouldGenerateTitle()];
if (\Drupal::moduleHandler()->moduleExists('commerce_order')) {
// Prepare a list of line item types used to purchase product variations.
$line_item_type_storage = $this->entityTypeManager->getStorage('commerce_line_item_type');
$line_item_types = $line_item_type_storage->loadMultiple();
$line_item_types = array_filter($line_item_types, function ($line_item_type) {
return $line_item_type->getPurchasableEntityTypeId() == 'commerce_product_variation';
});
$line_item_types = array_map(function ($line_item_type) {
return $line_item_type->label();
}, $line_item_types);
$form['lineItemType'] = ['#type' => 'select', '#title' => $this->t('Line item type'), '#default_value' => $variation_type->getLineItemTypeId(), '#options' => $line_item_types, '#empty_value' => '', '#required' => TRUE];
}
if ($this->moduleHandler->moduleExists('language')) {
$form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings'];
$form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product_variation', 'bundle' => $variation_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product_variation', $variation_type->id())];
$form['#submit'][] = 'language_configuration_element_submit';
}
return $this->protectBundleIdElement($form);
}