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


PHP LanguageManagerInterface::reset方法代码示例

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


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

示例1: onConfigSave

 /**
  * Causes the container to be rebuilt on the next request.
  *
  * This event subscriber assumes that the new default langcode and old default
  * langcode are valid langcodes. If the schema definition of either
  * system.site:default_langcode or language.negotiation::url.prefixes changes
  * then this event must be changed to work with both the old and new schema
  * definition so this event is update safe.
  *
  * @param ConfigCrudEvent $event
  *   The configuration event.
  */
 public function onConfigSave(ConfigCrudEvent $event)
 {
     $saved_config = $event->getConfig();
     if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) {
         $new_default_langcode = $saved_config->get('default_langcode');
         $default_language = $this->configFactory->get('language.entity.' . $new_default_langcode);
         // During an import the language might not exist yet.
         if (!$default_language->isNew()) {
             $this->languageDefault->set(new Language($default_language->get()));
             $this->languageManager->reset();
             // Directly update language negotiation settings instead of calling
             // language_negotiation_url_prefixes_update() to ensure that the code
             // obeys the hook_update_N() restrictions.
             $negotiation_config = $this->configFactory->getEditable('language.negotiation');
             $negotiation_changed = FALSE;
             $url_prefixes = $negotiation_config->get('url.prefixes');
             $old_default_langcode = $saved_config->getOriginal('default_langcode');
             if (empty($url_prefixes[$old_default_langcode])) {
                 $negotiation_config->set('url.prefixes.' . $old_default_langcode, $old_default_langcode);
                 $negotiation_changed = TRUE;
             }
             if (empty($url_prefixes[$new_default_langcode])) {
                 $negotiation_config->set('url.prefixes.' . $new_default_langcode, '');
                 $negotiation_changed = TRUE;
             }
             if ($negotiation_changed) {
                 $negotiation_config->save(TRUE);
             }
         }
         // Trigger a container rebuild on the next request by invalidating it.
         ConfigurableLanguageManager::rebuildServices();
     }
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:45,代码来源:ConfigSubscriber.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('language'));
     $this->state = $this->container->get('state');
     // Ensure we are building a new Language object for each test.
     $this->languageManager = $this->container->get('language_manager');
     $this->languageManager->reset();
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:12,代码来源:LanguageTestBase.php

示例3: onConfigSave

 /**
  * Causes the container to be rebuilt on the next request.
  *
  * @param ConfigCrudEvent $event
  *   The configuration event.
  */
 public function onConfigSave(ConfigCrudEvent $event)
 {
     $saved_config = $event->getConfig();
     if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) {
         $language = $this->languageManager->getLanguage($saved_config->get('default_langcode'));
         // During an import the language might not exist yet.
         if ($language) {
             $this->languageDefault->set($language);
             $this->languageManager->reset();
             language_negotiation_url_prefixes_update();
         }
         // Trigger a container rebuild on the next request by invalidating it.
         ConfigurableLanguageManager::rebuildServices();
     }
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:21,代码来源:ConfigSubscriber.php

示例4: onConfigSave

 /**
  * Causes the container to be rebuilt on the next request.
  *
  * @param ConfigCrudEvent $event
  *   The configuration event.
  */
 public function onConfigSave(ConfigCrudEvent $event)
 {
     $saved_config = $event->getConfig();
     if ($saved_config->getName() == 'system.site' && $event->isChanged('langcode')) {
         $language = $this->languageManager->getLanguage($saved_config->get('langcode'));
         // During an import the language might not exist yet.
         if ($language) {
             $this->languageDefault->set($language);
             $this->languageManager->reset();
             language_negotiation_url_prefixes_update();
         }
         // Trigger a container rebuild on the next request by deleting compiled
         // from PHP storage.
         PhpStorageFactory::get('service_container')->deleteAll();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:22,代码来源:ConfigSubscriber.php

示例5: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     // Save the default language if changed.
     $new_id = $form_state->getValue('site_default_language');
     if ($new_id != $this->languageManager->getDefaultLanguage()->getId()) {
         $this->configFactory->getEditable('system.site')->set('default_langcode', $new_id)->save();
         $this->languageManager->reset();
     }
     if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) {
         $this->languageManager->updateLockedLanguageWeights();
     }
     drupal_set_message(t('Configuration saved.'));
     // Force the redirection to the page with the language we have just
     // selected as default.
     $form_state->setRedirectUrl($this->entities[$new_id]->urlInfo('collection', array('language' => $this->entities[$new_id])));
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:20,代码来源:LanguageListBuilder.php

示例6: translateFilters

 /**
  * Lists locale translation filters that can be applied.
  */
 protected function translateFilters()
 {
     $filters = array();
     // Get all languages, except English.
     $this->languageManager->reset();
     $languages = $this->languageManager->getLanguages();
     $language_options = array();
     foreach ($languages as $langcode => $language) {
         if (locale_is_translatable($langcode)) {
             $language_options[$langcode] = $language->getName();
         }
     }
     // Pick the current interface language code for the filter.
     $default_langcode = $this->languageManager->getCurrentLanguage()->getId();
     if (!isset($language_options[$default_langcode])) {
         $available_langcodes = array_keys($language_options);
         $default_langcode = array_shift($available_langcodes);
     }
     $filters['string'] = array('title' => $this->t('String contains'), 'description' => $this->t('Leave blank to show all strings. The search is case sensitive.'), 'default' => '');
     $filters['langcode'] = array('title' => $this->t('Translation language'), 'options' => $language_options, 'default' => $default_langcode);
     $filters['translation'] = array('title' => $this->t('Search in'), 'options' => array('all' => $this->t('Both translated and untranslated strings'), 'translated' => $this->t('Only translated strings'), 'untranslated' => $this->t('Only untranslated strings')), 'default' => 'all');
     $filters['customized'] = array('title' => $this->t('Translation type'), 'options' => array('all' => $this->t('All'), LOCALE_NOT_CUSTOMIZED => $this->t('Non-customized translation'), LOCALE_CUSTOMIZED => $this->t('Customized translation')), 'states' => array('visible' => array(':input[name=translation]' => array('value' => 'translated'))), 'default' => 'all');
     return $filters;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:27,代码来源:TranslateFormBase.php


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