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


PHP ConfigurableLanguage::create方法代码示例

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


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Enable translation for the entity_test module.
     \Drupal::state()->set('entity_test.translation', TRUE);
     $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
     $this->installEntitySchema('entity_test_mul');
     // Create the default languages.
     $this->installConfig(array('language'));
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         /** @var \Drupal\language\Entity\ConfigurableLanguage $language */
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => 'language - ' . $i, 'weight' => $i));
         $this->langcodes[$i] = $language->getId();
         $language->save();
     }
     // Do not use a batch for tracking the initial items after creating an
     // index when running the tests via the GUI. Otherwise, it seems Drupal's
     // Batch API gets confused and the test fails.
     \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
     // Create a test server.
     $this->server = Server::create(array('name' => 'Test Server', 'id' => 'test_server', 'status' => 1, 'backend' => 'search_api_test_backend'));
     $this->server->save();
     // Create a test index.
     $this->index = Index::create(array('name' => 'Test Index', 'id' => 'test_index', 'status' => 1, 'datasource_settings' => array('entity:' . $this->testEntityTypeId => array('plugin_id' => 'entity:' . $this->testEntityTypeId, 'settings' => array())), 'tracker_settings' => array('default' => array('plugin_id' => 'default', 'settings' => array())), 'server' => $this->server->id(), 'options' => array('index_directly' => FALSE)));
     $this->index->save();
 }
开发者ID:curveagency,项目名称:intranet,代码行数:30,代码来源:LanguageKernelTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', array('url_alias', 'router'));
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test');
     $this->installConfig(array('field', 'language'));
     // Add German as a language.
     ConfigurableLanguage::create(array('id' => 'de', 'label' => 'Deutsch', 'weight' => -1))->save();
     // Create the test text field.
     entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
     entity_create('field_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('field_name' => 'field_test_translatable_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
     entity_create('field_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('field_name' => 'field_test_entity_reference', 'entity_type' => 'entity_test', 'type' => 'entity_reference', 'settings' => array('target_type' => 'entity_test')))->save();
     entity_create('field_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);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:NormalizerTestBase.php

示例3: setUp

 protected 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 fields in all entity variations.
     foreach (entity_test_entity_types() as $entity_type) {
         entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save();
         $this->field[$entity_type] = entity_load('field_config', $entity_type . '.' . $entity_type . '.' . $this->field_name);
         entity_create('field_storage_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save();
         entity_create('field_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save();
     }
     // Create the default languages.
     $this->installConfig(array('language'));
     // Create test languages.
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i));
         $this->langcodes[$i] = $language->getId();
         $language->save();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:EntityLanguageTestBase.php

示例4: testContentTranslationForm

 /**
  * Tests content translation form translatability constraints messages.
  */
 public function testContentTranslationForm()
 {
     $this->loginAsAdmin(['administer languages', 'administer content translation', 'create content translations', 'translate any entity']);
     // Check warning message is displayed.
     $this->drupalGet('admin/config/regional/content-language');
     $this->assertText('(* unsupported) Paragraphs fields do not support translation.');
     $this->addParagraphedContentType('paragraphed_test', 'paragraphs_field');
     // Check error message is displayed.
     $this->drupalGet('admin/config/regional/content-language');
     $this->assertText('(* unsupported) Paragraphs fields do not support translation.');
     $this->assertRaw('<div class="messages messages--error');
     // Add a second language.
     ConfigurableLanguage::create(['id' => 'de'])->save();
     // Enable translation for paragraphed content type.
     $edit = ['entity_types[node]' => TRUE, 'settings[node][paragraphed_test][translatable]' => TRUE, 'settings[node][paragraphed_test][fields][paragraphs_field]' => FALSE];
     $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
     // Check content type field management warning.
     $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs_field');
     $this->assertText('Paragraphs fields do not support translation.');
     // Make the paragraphs field translatable.
     $edit = ['entity_types[node]' => TRUE, 'settings[node][paragraphed_test][translatable]' => TRUE, 'settings[node][paragraphed_test][fields][paragraphs_field]' => TRUE];
     $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
     // Check content type field management error.
     $this->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs_field');
     $this->assertText('Paragraphs fields do not support translation.');
     $this->assertRaw('<div class="messages messages--error');
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:30,代码来源:ParagraphsConfigTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('language'));
     // Create another language beside English.
     ConfigurableLanguage::create(array('id' => 'xx-lolspeak', 'label' => 'Lolspeak'))->save();
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:7,代码来源:LanguageTestBase.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer menu')));
     // Add some custom languages.
     foreach (array('aa', 'bb', 'cc', 'cs') as $language_code) {
         ConfigurableLanguage::create(array('id' => $language_code, 'label' => $this->randomMachineName()))->save();
     }
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:9,代码来源:MenuLanguageTest.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     $definitions = \Drupal::service('plugin.manager.config_translation.mapper')->getDefinitions();
     $this->pluginId = key($definitions);
     $this->langcode = 'xx';
     ConfigurableLanguage::create(array('id' => $this->langcode, 'label' => 'XX'))->save();
     \Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:9,代码来源:ConfigTranslationFormTest.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
     // Add some custom languages.
     ConfigurableLanguage::create(array('id' => 'aa', 'label' => $this->randomMachineName()))->save();
     ConfigurableLanguage::create(array('id' => 'bb', 'label' => $this->randomMachineName()))->save();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:9,代码来源:VocabularyLanguageTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test');
     $this->installEntitySchema('entity_test_mul');
     \Drupal::service('router.builder')->rebuild();
     // Adding german language.
     ConfigurableLanguage::create(['id' => 'de'])->save();
     $this->config('language.types')->setData(['configurable' => ['language_interface'], 'negotiation' => ['language_interface' => ['enabled' => ['language-url' => 0]]]])->save();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:PathNoCanonicalLinkTest.php

示例10: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installEntitySchema('simplenews_subscriber');
     $this->installSchema('system', array('sequences', 'sessions'));
     $this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
     $this->config('simplenews.settings')->set('subscriber.sync_fields', TRUE)->save();
     ConfigurableLanguage::create(array('id' => 'fr'))->save();
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:13,代码来源:SimplenewsSynchronizeFieldsTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create test languages.
     $this->langcodes = array(ConfigurableLanguage::load('en'));
     for ($i = 1; $i < 3; ++$i) {
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString()));
         $language->save();
         $this->langcodes[$i] = $language;
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:11,代码来源:BlockLanguageCacheTest.php

示例12: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     ConfigurableLanguage::create(['id' => 'es'])->save();
     ConfigurableLanguage::create(['id' => 'fr'])->save();
     // In order to reflect the changes for a multilingual site in the container
     // we have to rebuild it.
     $this->rebuildContainer();
     $this->createTranslatableEntity();
     $user = $this->drupalCreateUser(array('view test entity'));
     $this->drupalLogin($user);
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:15,代码来源:LanguageNegotiationContentEntityTest.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create an administrative user.
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
     // Create a vocabulary to which the terms will be assigned.
     $this->vocabulary = $this->createVocabulary();
     // Add some custom languages.
     foreach (array('aa', 'bb', 'cc') as $language_code) {
         ConfigurableLanguage::create(array('id' => $language_code, 'label' => $this->randomMachineName()))->save();
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:12,代码来源:TermLanguageTest.php

示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     $node_type = NodeType::create(['type' => 'article', 'label' => 'Article']);
     $node_type->save();
     /** @var \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager */
     $content_translation_manager = \Drupal::service('content_translation.manager');
     $content_translation_manager->setEnabled('node', 'article', TRUE);
     $language = ConfigurableLanguage::create(['id' => 'es', 'label' => 'Spanish']);
     $language->save();
     // Rebuild the container to setup the language path processors.
     $this->rebuildContainer();
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:16,代码来源:FieldEntityTranslationTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     // Enable translations for the test entity type.
     \Drupal::state()->set('entity_test.translation', TRUE);
     // Create test languages.
     $this->langcodes = array();
     for ($i = 0; $i < 2; ++$i) {
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString()));
         $this->langcodes[$i] = $language->id();
         $language->save();
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:EntityTranslationFormTest.php


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