当前位置: 首页>>代码示例>>PHP>>正文


PHP LanguageManagerInterface::getDefaultLockedLanguages方法代码示例

本文整理汇总了PHP中Drupal\Core\Language\LanguageManagerInterface::getDefaultLockedLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManagerInterface::getDefaultLockedLanguages方法的具体用法?PHP LanguageManagerInterface::getDefaultLockedLanguages怎么用?PHP LanguageManagerInterface::getDefaultLockedLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Language\LanguageManagerInterface的用法示例。


在下文中一共展示了LanguageManagerInterface::getDefaultLockedLanguages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 function setUp()
 {
     parent::setUp();
     $this->languageManager = $this->container->get('language_manager');
     $this->installEntitySchema('entity_test_rev');
     $this->installEntitySchema('entity_test_mul');
     $this->installEntitySchema('entity_test_mulrev');
     $this->installConfig(array('language'));
     // Create the test field.
     entity_test_install();
     // Enable translations for the test entity type.
     $this->state->set('entity_test.translation', TRUE);
     // Create a translatable test field.
     $this->field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create an untranslatable test field.
     $this->untranslatable_field_name = drupal_strtolower($this->randomMachineName() . '_field_name');
     // Create field instances in all entity variations.
     foreach (entity_test_entity_types() as $entity_type) {
         entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
         $this->instance[$entity_type] = entity_load('field_instance_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
         entity_create('field_storage_config', array('name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_instance_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
     }
     // Create the default languages.
     $default_language = language_save($this->languageManager->getDefaultLanguage());
     $languages = $this->languageManager->getDefaultLockedLanguages($default_language->weight);
     foreach ($languages as $language) {
         language_save($language);
     }
     // Create test languages.
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         $language = new Language(array('id' => 'l' . $i, 'name' => $this->randomString(), 'weight' => $i));
         $this->langcodes[$i] = $language->id;
         language_save($language);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:38,代码来源:EntityLanguageTestBase.php


注:本文中的Drupal\Core\Language\LanguageManagerInterface::getDefaultLockedLanguages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。