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


PHP Entity\ConfigurableLanguage类代码示例

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


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

示例1: testWeight

 /**
  * @covers ::getWeight
  * @covers ::setWeight
  */
 public function testWeight()
 {
     // The weight, an integer. Used to order languages with larger positive
     // weights sinking items toward the bottom of lists.
     $configurableLanguage = new ConfigurableLanguage(array('weight' => -5), 'configurable_language');
     $this->assertEquals($configurableLanguage->getWeight(), -5);
     $this->assertEquals($configurableLanguage->setWeight(13)->getWeight(), 13);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ConfigurableLanguageUnitTest.php

示例2: testName

 /**
  * Tests configurable language name methods.
  */
 public function testName()
 {
     $name = $this->randomMachineName();
     $language_code = $this->randomMachineName(2);
     $configurableLanguage = new ConfigurableLanguage(array('label' => $name, 'id' => $language_code), 'configurable_language');
     $this->assertEqual($configurableLanguage->getName(), $name);
     $this->assertEqual($configurableLanguage->setName('Test language')->getName(), 'Test language');
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:11,代码来源:ConfigurableLanguageTest.php

示例3: 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

示例4: setUp

 function setUp()
 {
     parent::setUp();
     // Add two new languages.
     ConfigurableLanguage::createFromLangcode('fr')->save();
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Set up term names.
     $this->termNames = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
     // Create a vocabulary.
     $this->vocabulary = Vocabulary::create(['name' => 'Views testing tags', 'vid' => 'views_testing_tags']);
     $this->vocabulary->save();
     // Add a translatable field to the vocabulary.
     $field = FieldStorageConfig::create(array('field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'type' => 'text'));
     $field->save();
     FieldConfig::create(['field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'label' => 'Foo', 'bundle' => 'views_testing_tags'])->save();
     // Create term with translations.
     $taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
     foreach (array('es', 'fr') as $langcode) {
         $translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
         $translation->description->value = $this->termNames[$langcode];
         $translation->field_foo->value = $this->termNames[$langcode];
     }
     $taxonomy->save();
     Views::viewsData()->clear();
     ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
     $this->container->get('router.builder')->rebuild();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:27,代码来源:TaxonomyFieldFilterTest.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: testConfigTranslationImport

 /**
  * Test update changes configuration translations if enabled after language.
  */
 public function testConfigTranslationImport()
 {
     $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions'));
     $this->drupalLogin($admin_user);
     // Add a language. The Afrikaans translation file of locale_test_translate
     // (test.af.po) has been prepared with a configuration translation.
     ConfigurableLanguage::createFromLangcode('af')->save();
     // Enable locale module.
     $this->container->get('module_installer')->install(array('locale'));
     $this->resetAll();
     // Enable import of translations. By default this is disabled for automated
     // tests.
     $this->config('locale.settings')->set('translation.import_enabled', TRUE)->save();
     // Add translation permissions now that the locale module has been enabled.
     $edit = array('authenticated[translate interface]' => 'translate interface');
     $this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
     // Check and update the translation status. This will import the Afrikaans
     // translations of locale_test_translate module.
     $this->drupalGet('admin/reports/translations/check');
     // Override the Drupal core translation status to be up to date.
     // Drupal core should not be a subject in this test.
     $status = locale_translation_get_status();
     $status['drupal']['af']->type = 'current';
     \Drupal::state()->set('locale.translation_status', $status);
     $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
     // Check if configuration translations have been imported.
     $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'system.maintenance');
     $this->assertEqual($override->get('message'), 'Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees.');
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:32,代码来源:LocaleConfigTranslationImportTest.php

示例7: testSiteNameTranslation

 /**
  * Tests translating the site name.
  */
 function testSiteNameTranslation()
 {
     $adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages'));
     $this->drupalLogin($adminUser);
     // Add a custom language.
     $langcode = 'xx';
     $name = $this->randomMachineName(16);
     $edit = array('predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR);
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
     \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'system.site')->set('name', 'XX site name')->save();
     $this->drupalLogout();
     // The home page in English should not have the override.
     $this->drupalGet('');
     $this->assertNoText('XX site name');
     // During path resolution the system.site configuration object is used to
     // determine the front page. This occurs before language negotiation causing
     // the configuration factory to cache an object without the correct
     // overrides. We are testing that the configuration factory is
     // re-initialised after language negotiation. Ensure that it applies when
     // we access the XX front page.
     // @see \Drupal\Core\PathProcessor::processInbound()
     $this->drupalGet('xx');
     $this->assertText('XX site name');
     // Set the xx language to be the default language and delete the English
     // language so the site is no longer multilingual and confirm configuration
     // overrides still work.
     $language_manager = \Drupal::languageManager()->reset();
     $this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.');
     $this->config('system.site')->set('default_langcode', 'xx')->save();
     ConfigurableLanguage::load('en')->delete();
     $this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.');
     $this->drupalGet('xx');
     $this->assertText('XX site name');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:37,代码来源:ConfigLanguageOverrideWebTest.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
     $this->drupalLogin($test_user);
     // Add a new language.
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Set up times to be applied to the English and Spanish translations of the
     // node create time, so that they are filtered in/out in the
     // search_date_query_alter test module.
     $created_time_en = new \DateTime('February 10 2016 10PM');
     $created_time_es = new \DateTime('March 19 2016 10PM');
     $default_format = filter_default_format();
     $node = $this->drupalCreateNode(['title' => 'Node EN', 'type' => 'page', 'body' => ['value' => $this->randomMachineName(32), 'format' => $default_format], 'langcode' => 'en', 'created' => $created_time_en->format('U')]);
     // Add Spanish translation to the node.
     $translation = $node->addTranslation('es', ['title' => 'Node ES']);
     $translation->body->value = $this->randomMachineName(32);
     $translation->created->value = $created_time_es->format('U');
     $node->save();
     // Update the index.
     $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     $plugin->updateIndex();
     search_update_totals();
 }
开发者ID:systemick3,项目名称:systemick.co.uk,代码行数:25,代码来源:SearchDateIntervalTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $permissions = array('access administration pages', 'administer site configuration');
     $this->drupalLogin($this->drupalCreateUser($permissions));
     ConfigurableLanguage::createFromLangcode('es')->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:7,代码来源:AdminPathEntityConverterLanguageTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     // Set up an additional language.
     $this->langcodes = array(language_default()->getId(), 'es');
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Create a content type.
     $this->bundle = $this->randomMachineName();
     $this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
     // Enable translation for the current entity type and ensure the change is
     // picked up.
     content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedBundles();
     \Drupal::service('router.builder')->rebuild();
     // Add a translatable field to the content type.
     entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
     entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
     // Enable content translation.
     $configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
     language_save_default_configuration('node', $this->bundle, $configuration);
     // Create a translator user.
     $permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
     $this->translator = $this->drupalCreateUser($permissions);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:26,代码来源:ContentTranslationContextualLinksTest.php

示例11: 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

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_mulrev');
     $this->installEntitySchema('configurable_language');
     ConfigurableLanguage::createFromLangcode('es')->save();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:EntityNonRevisionableTranslatableFieldTest.php

示例13: setUp

 function setUp()
 {
     parent::setUp();
     // Create Page content type.
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     }
     // Add two new languages.
     ConfigurableLanguage::createFromLangcode('fr')->save();
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Make the body field translatable. The title is already translatable by
     // definition.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $field_storage->translatable = TRUE;
     $field_storage->save();
     // Set up node titles.
     $this->node_titles = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
     // Create node with translations.
     $node = $this->drupalCreateNode(array('title' => $this->node_titles['en'], 'langcode' => 'en', 'type' => 'page', 'body' => array(array('value' => $this->node_titles['en']))));
     foreach (array('es', 'fr') as $langcode) {
         $translation = $node->addTranslation($langcode, array('title' => $this->node_titles[$langcode]));
         $translation->body->value = $this->node_titles[$langcode];
     }
     $node->save();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:NodeFieldFilterTest.php

示例14: setUp

  public function setUp() {
    parent::setup();

    $this->installConfig(array('pathauto', 'taxonomy', 'system', 'node'));

    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installEntitySchema('taxonomy_term');

    ConfigurableLanguage::createFromLangcode('fr')->save();

    $this->installSchema('node', array('node_access'));
    $this->installSchema('system', array('url_alias', 'sequences', 'router'));

    $type = NodeType::create(['type' => 'page']);
    $type->save();
    node_add_body_field($type);

    $this->nodePattern = $this->createPattern('node', '/content/[node:title]');
    $this->userPattern = $this->createPattern('user', '/users/[user:name]');

    \Drupal::service('router.builder')->rebuild();

    $this->currentUser = entity_create('user', array('name' => $this->randomMachineName()));
    $this->currentUser->save();
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:26,代码来源:PathautoUnitTest.php

示例15: 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


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